private void addEnumConstants(JsonNode node, JDefinedClass _enum, JsonNode customNames, JType type) { Collection<String> existingConstantNames = new ArrayList<>(); for (int i = 0; i < node.size(); i++) { JsonNode value = node.path(i); if (!value.isNull()) { String constantName = getConstantName(value.asText(), customNames.path(i).asText()); constantName = makeUnique(constantName, existingConstantNames); existingConstantNames.add(constantName); JEnumConstant constant = _enum.enumConstant(constantName); constant.arg(DefaultRule.getDefaultValue(type, value)); ruleFactory.getAnnotator().enumConstant(_enum, constant, value.asText()); } } }
private void addEnumConstants(JsonNode node, JDefinedClass _enum) { for (Iterator<JsonNode> values = node.elements(); values.hasNext();) { JsonNode value = values.next(); if (!value.isNull()) { JEnumConstant constant = _enum.enumConstant(getConstantName(value.asText())); constant.arg(JExpr.lit(value.asText())); } } }
private void addEnumConstants(JsonNode node, JDefinedClass _enum, JsonNode customNames, JType type) { Collection<String> existingConstantNames = new ArrayList<>(); for (int i = 0; i < node.size(); i++) { JsonNode value = node.path(i); if (!value.isNull()) { String constantName = getConstantName(value.asText(), customNames.path(i).asText()); constantName = makeUnique(constantName, existingConstantNames); existingConstantNames.add(constantName); JEnumConstant constant = _enum.enumConstant(constantName); constant.arg(DefaultRule.getDefaultValue(type, value)); ruleFactory.getAnnotator().enumConstant(_enum, constant, value.asText()); } } }
public <T> EnumBuilder withEnum(T name, Class<T> type) { pojoCreationCheck(); String cleaned = NamingHelper.cleanNameForJavaEnum(name.toString()); if (!doesEnumContainField(type, cleaned)) { withValueField(type); ENUM_CACHE.put(cleaned, true); logger.debug("Adding field: {} to {}", name, this.pojo.name()); if (StringUtils.hasText(cleaned)) { JEnumConstant enumConstant = this.pojo.enumConstant(cleaned); if (type.equals(Integer.class)) { enumConstant.arg(JExpr.lit((Integer) name)); } else if (type.equals(Boolean.class)) { enumConstant.arg(JExpr.lit((Boolean) name)); } else if (type.equals(Double.class)) { enumConstant.arg(JExpr.lit((Double) name)); } else if (type.equals(Float.class)) { enumConstant.arg(JExpr.lit((Float) name)); } else if (type.equals(Long.class)) { enumConstant.arg(JExpr.lit((Long) name)); } else { enumConstant.arg(JExpr.lit(name.toString())); enumConstant.annotate(JsonProperty.class).param("value", name.toString()); } } } return this; }
protected void addEnumConstants() { // TODO optionally add an ILLEGAL_VALUE constant, which could be returned from the findValue() method for (SmiNamedNumber namedNumber : type.getNamedNumbers()) { JEnumConstant ec = definedClass.enumConstant(namedNumber.getCodeId()); ec.arg(JExpr.lit(namedNumber.getId())); ec.arg(JExpr.lit(namedNumber.getValue().intValue())); ec.javadoc().add("<pre>" + namedNumber.toString() + "</pre>"); } }
private void addOidValue(SmiOidValue v) { SmiPrimitiveType primitiveType = determinePrimitiveType(v); // -1 for variables that are not scalars or columns: byte berValue = primitiveType != null ? primitiveType.getVarBindField().getBerTagValue() : -1; JEnumConstant ec = definedClass.enumConstant(v.getCodeId()) .arg(JExpr.lit(v.getId())) .arg(JExpr.lit(v.getOidStr())) .arg(JExpr.lit(berValue)); ec.javadoc().append("<pre>" + v.getId() + ": " + v.getOidStr() + "</pre>\n\n"); if (primitiveType != null) { ec.javadoc().append("<pre>Type:" + primitiveType + "<pre>\n\n"); } if (v instanceof SmiObjectType) { SmiObjectType objectType = (SmiObjectType) v; ec.javadoc().append("<pre>" + objectType.getDescription() + "</pre>"); } if (v instanceof SmiNotificationType) { SmiNotificationType notificationType = (SmiNotificationType) v; ec.javadoc().append("<pre>" + notificationType.getDescription() + "</pre>"); } // TODO add link to generated enum type, if applicable }
for (Option o: param.getOption()) { JEnumConstant c = $enum.enumConstant(makeConstantName(o.getValue())); c.arg(JExpr.lit(o.getValue())); javaDoc.generateEnumConstantDoc(o, c);
enumConstant.arg(JExpr.lit((String) attributeVal)); enumConstant.arg(JExpr.lit((Integer) attributeVal)); enumConstant.arg(JExpr.lit((Float) attributeVal)); enumConstant.arg(JExpr.lit((Double) attributeVal)); enumConstant.arg(JExpr.lit((Short) attributeVal)); enumConstant.arg(JExpr.lit((Boolean) attributeVal)); enumConstant.arg(JExpr.lit((Character) attributeVal));
constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));