Tabnine Logo
JDefinedClass.enumConstant
Code IndexAdd Tabnine to your IDE (free)

How to use
enumConstant
method
in
com.sun.codemodel.JDefinedClass

Best Java code snippets using com.sun.codemodel.JDefinedClass.enumConstant (Showing top 18 results out of 315)

origin: joelittlejohn/jsonschema2pojo

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());
    }
  }
}
origin: mulesoft-labs/raml-jaxrs-codegen

public JDefinedClass createResourceEnum(final JDefinedClass resourceInterface,
                    final String name,
                    final List<String> values) throws Exception
{
  final JDefinedClass _enum = resourceInterface._enum(name);
  for (final String value : values)
  {
    _enum.enumConstant(value);
  }
  return _enum;
}
origin: com.googlecode.jsonschema2pojo/jsonschema2pojo-core

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()));
    }
  }
}
origin: org.jsonschema2pojo/jsonschema2pojo-core

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());
    }
  }
}
origin: org.raml/raml-jaxrs-codegen-core

/**
 * <p>createResourceEnum.</p>
 *
 * @param resourceInterface a {@link com.sun.codemodel.JDefinedClass} object.
 * @param name a {@link java.lang.String} object.
 * @param values a {@link java.util.List} object.
 * @return a {@link com.sun.codemodel.JDefinedClass} object.
 * @throws java.lang.Exception if any.
 */
public JDefinedClass createResourceEnum(final JDefinedClass resourceInterface,
                    final String name,
                    final List<String> values) throws Exception
{
  JClass[] listClasses = resourceInterface.listClasses();
  for (JClass c:listClasses){
    if (c.name().equals(name)){
      return (JDefinedClass) c;
    }
  }
  final JDefinedClass _enum = resourceInterface._enum(name);
  for (final String value : values)
  {
    _enum.enumConstant(value);
  }
  return _enum;
}
/**
origin: phoenixnap/springmvc-raml-plugin

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;
}
origin: org.jvnet.ws.wadl/wadl-core

javaDoc.generateEnumDoc(param, $enum);
for (Option o: param.getOption()) {
  JEnumConstant c = $enum.enumConstant(makeConstantName(o.getValue()));
  c.arg(JExpr.lit(o.getValue()));
  javaDoc.generateEnumConstantDoc(o, c);
origin: org.jsmiparser/jsmiparser-codegen

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>");
  }
}
origin: org.jboss.shrinkwrap.descriptors/shrinkwrap-descriptors-metadata-parser

/**
 * Generates all enumeration classes.
 *
 * @param metadata
 * @throws JClassAlreadyExistsException
 * @throws IOException
 */
public void generateEnums() throws JClassAlreadyExistsException, IOException {
  final JCodeModel cm = new JCodeModel();
  for (final MetadataEnum metadataEnum : metadata.getEnumList()) {
    final String fqnEnum = metadataEnum.getPackageApi() + "." + getPascalizeCase(metadataEnum.getName());
    final JDefinedClass dc = cm._class(fqnEnum, ClassType.ENUM);
    final JDocComment javaDocComment = dc.javadoc();
    final Map<String, String> part = javaDocComment.addXdoclet("author");
    part.put("<a href", "'mailto:ralf.battenfeld@bluewin.ch'>Ralf Battenfeld</a>");
    for (final String enumConstant : metadataEnum.getValueList()) {
      dc.enumConstant(getEnumConstantName(enumConstant));
    }
    final JMethod toStringMethod = dc.method(1, String.class, "toString");
    toStringMethod.body()._return(JExpr.direct("name().substring(1)"));
  }
  final File file = new File("./src/test/java");
  file.mkdirs();
  cm.build(file);
}
origin: org.projectodd.shrinkwrap.descriptors/shrinkwrap-descriptors-metadata-parser

/**
 * Generates all enumeration classes.
 *
 * @param metadata
 * @throws JClassAlreadyExistsException
 * @throws IOException
 */
public void generateEnums() throws JClassAlreadyExistsException, IOException {
  final JCodeModel cm = new JCodeModel();
  for (final MetadataEnum metadataEnum : metadata.getEnumList()) {
    final String fqnEnum = metadataEnum.getPackageApi() + "." + getPascalizeCase(metadataEnum.getName());
    final JDefinedClass dc = cm._class(fqnEnum, ClassType.ENUM);
    final JDocComment javaDocComment = dc.javadoc();
    final Map<String, String> part = javaDocComment.addXdoclet("author");
    part.put("<a href", "'mailto:ralf.battenfeld@bluewin.ch'>Ralf Battenfeld</a>");
    for (final String enumConstant : metadataEnum.getValueList()) {
      dc.enumConstant(getEnumConstantName(enumConstant));
    }
    final JMethod toStringMethod = dc.method(1, String.class, "toString");
    toStringMethod.body()._return(JExpr.direct("name().substring(1)"));
  }
  final File file = new File("./src/test/java");
  file.mkdirs();
  cm.build(file);
}
origin: org.jsmiparser/jsmiparser-codegen

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
}
origin: jpmml/jpmml

JEnumConstant continueAction = visitorActionClazz.enumConstant("CONTINUE");
JEnumConstant skipAction = visitorActionClazz.enumConstant("SKIP");
JEnumConstant terminateAction = visitorActionClazz.enumConstant("TERMINATE");
origin: yeshodhan/android-jaxb

enumClass.enumConstant(enumConstant);
JEnumConstant enumConstant = enumClass.enumConstant(attributeValue.getKey());
List<Object> attributeValues = attributeValue.getAttributes();
int index = 0;
origin: sun-jaxb/jaxb-xjc

JEnumConstant constRef = type.enumConstant(constName);
if(needsValue)
  constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
origin: org.andromda.thirdparty.jaxb2_commons/jaxb-xjc

JEnumConstant constRef = type.enumConstant(constName);
if(needsValue)
  constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
origin: org.glassfish.metro/webservices-tools

JEnumConstant constRef = type.enumConstant(constName);
if (needsValue) {
  constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc

JEnumConstant constRef = type.enumConstant(constName);
if (needsValue) {
  constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
origin: apache/servicemix-bundles

JEnumConstant constRef = type.enumConstant(constName);
if (needsValue) {
  constRef.arg(e.base.createConstant(this, new XmlString(mem.getLexicalValue())));
com.sun.codemodelJDefinedClassenumConstant

Javadoc

If the named enum already exists, the reference to it is returned. Otherwise this method generates a new enum reference with the given name and returns it.

Popular methods of JDefinedClass

  • method
  • _extends
  • field
  • _implements
  • name
    JClass name accessor. For example, for java.util.List, this method returns "List""
  • constructor
    Adds a constructor to this class.
  • fields
    Returns all the fields declred in this class. The returned Map is a read-only live view.
  • annotate
    Adding ability to annotate a class
  • fullName
    Gets the fully qualified name of this class.
  • methods
  • owner
  • javadoc
    Creates, if necessary, and returns the class javadoc for this JDefinedClass
  • owner,
  • javadoc,
  • _class,
  • getMethod,
  • _package,
  • dotclass,
  • staticInvoke,
  • staticRef,
  • init

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now