Codota Logo
JDefinedClass.fields
Code IndexAdd Codota to your IDE (free)

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

Best Java code snippets using com.sun.codemodel.JDefinedClass.fields (Showing top 20 results out of 378)

  • Common ways to obtain JDefinedClass
private void myMethod () {
JDefinedClass j =
  • Codota IconJCodeModel codeModel;String fullyqualifiedName;codeModel._class(fullyqualifiedName)
  • Codota IconJClassAlreadyExistsException e;e.getExistingClass()
  • Codota IconJCodeModel cm;String fullyqualifiedName;ClassType t;cm._class(fullyqualifiedName, t)
  • Smart code suggestions by Codota
}
origin: joelittlejohn/jsonschema2pojo

private JFieldVar searchClassAndSuperClassesForField(String property, JDefinedClass jclass) {
  Map<String, JFieldVar> fields = jclass.fields();
  JFieldVar field = fields.get(property);
  if (field == null) {
    return searchSuperClassesForField(property, jclass);
  }
  return field;
}
origin: joelittlejohn/jsonschema2pojo

/**
 * @see EnumRule
 */
private static JExpression getDefaultEnum(JType fieldType, JsonNode node) {
  JDefinedClass enumClass = (JDefinedClass) fieldType;
  JType backingType = enumClass.fields().get("value").type();
  JInvocation invokeFromValue = enumClass.staticInvoke("fromValue");
  invokeFromValue.arg(getDefaultValue(backingType, node));
  return invokeFromValue;
}
origin: joelittlejohn/jsonschema2pojo

TreeSet<String> fieldNames = new TreeSet<>(jclass.fields().keySet());
for (String fieldName : fieldNames) {
  JFieldVar fieldVar = jclass.fields().get(fieldName);
    processFieldVarForSerializableSupport(jclass.fields().get(fieldName), dataOutputStream);
origin: joelittlejohn/jsonschema2pojo

JFieldVar field = jclass.fields().get(fieldName);
origin: joelittlejohn/jsonschema2pojo

JInvocation superInvocation = constructorBody.invoke("super");
Map<String, JFieldVar> fields = jclass.fields();
Map<String, JVar> classFieldParams = new HashMap<>();
origin: joelittlejohn/jsonschema2pojo

private JMethod addInternalSetMethodJava7(JDefinedClass jclass, JsonNode propertiesNode) {
  JMethod method = jclass.method(PROTECTED, jclass.owner().BOOLEAN, DEFINED_SETTER_NAME);
  JVar nameParam = method.param(String.class, "name");
  JVar valueParam = method.param(Object.class, "value");
  JBlock body = method.body();
  JSwitch propertySwitch = body._switch(nameParam);
  if (propertiesNode != null) {
    for (Iterator<Map.Entry<String, JsonNode>> properties = propertiesNode.fields(); properties.hasNext();) {
      Map.Entry<String, JsonNode> property = properties.next();
      String propertyName = property.getKey();
      JsonNode node = property.getValue();
      String fieldName = ruleFactory.getNameHelper().getPropertyName(propertyName, node);
      JType propertyType = jclass.fields().get(fieldName).type();
      addSetPropertyCase(jclass, propertySwitch, propertyName, propertyType, valueParam, node);
    }
  }
  JBlock defaultBlock = propertySwitch._default().body();
  JClass extendsType = jclass._extends();
  if (extendsType != null && extendsType instanceof JDefinedClass) {
    JDefinedClass parentClass = (JDefinedClass) extendsType;
    JMethod parentMethod = parentClass.getMethod(DEFINED_SETTER_NAME,
        new JType[] { parentClass.owner()._ref(String.class), parentClass.owner()._ref(Object.class) });
    defaultBlock._return(_super().invoke(parentMethod).arg(nameParam).arg(valueParam));
  } else {
    defaultBlock._return(FALSE);
  }
  return method;
}
origin: joelittlejohn/jsonschema2pojo

private JMethod addInternalGetMethodJava7(JDefinedClass jclass, JsonNode propertiesNode) {
  JMethod method = jclass.method(PROTECTED, jclass.owner()._ref(Object.class), DEFINED_GETTER_NAME);
  JVar nameParam = method.param(String.class, "name");
  JVar notFoundParam = method.param(jclass.owner()._ref(Object.class), "notFoundValue");
  JBlock body = method.body();
  JSwitch propertySwitch = body._switch(nameParam);
  if (propertiesNode != null) {
    for (Iterator<Map.Entry<String, JsonNode>> properties = propertiesNode.fields(); properties.hasNext();) {
      Map.Entry<String, JsonNode> property = properties.next();
      String propertyName = property.getKey();
      JsonNode node = property.getValue();
      String fieldName = ruleFactory.getNameHelper().getPropertyName(propertyName, node);
      JType propertyType = jclass.fields().get(fieldName).type();
      addGetPropertyCase(jclass, propertySwitch, propertyName, propertyType, node);
    }
  }
  JClass extendsType = jclass._extends();
  if (extendsType != null && extendsType instanceof JDefinedClass) {
    JDefinedClass parentClass = (JDefinedClass) extendsType;
    JMethod parentMethod = parentClass.getMethod(DEFINED_GETTER_NAME,
        new JType[] { parentClass.owner()._ref(String.class), parentClass.owner()._ref(Object.class) });
    propertySwitch._default().body()
    ._return(_super().invoke(parentMethod).arg(nameParam).arg(notFoundParam));
  } else {
    propertySwitch._default().body()
    ._return(notFoundParam);
  }
  return method;
}
origin: joelittlejohn/jsonschema2pojo

public void addWriteToParcel(JDefinedClass jclass) {
  JMethod method = jclass.method(JMod.PUBLIC, void.class, "writeToParcel");
  JVar dest = method.param(jclass.owner().directClass("android.os.Parcel"), "dest");
  method.param(int.class, "flags");
  // Call super.writeToParcel
  if (extendsParcelable(jclass)) {
    method.body().directStatement("super.writeToParcel(dest, flags);");
  }
  for (JFieldVar f : jclass.fields().values()) {
    if( (f.mods().getValue() & JMod.STATIC) == JMod.STATIC ) {
      continue;
    }
    if (f.type().erasure().name().equals("List")) {
      method.body().invoke(dest, "writeList").arg(f);
    } else {
      method.body().invoke(dest, "writeValue").arg(f);
    }
  }
}

origin: joelittlejohn/jsonschema2pojo

JsonNode node = property.getValue();
String fieldName = ruleFactory.getNameHelper().getPropertyName(propertyName, node);
JType propertyType = jclass.fields().get(fieldName).type();
JExpression condition = lit(propertyName).invoke("equals").arg(nameParam);
propertyConditional = propertyConditional == null ? propertyConditional = body._if(condition)
origin: joelittlejohn/jsonschema2pojo

JsonNode node = property.getValue();
String fieldName = ruleFactory.getNameHelper().getPropertyName(propertyName, node);
JType propertyType = jclass.fields().get(fieldName).type();
origin: joelittlejohn/jsonschema2pojo

public void addConstructorFromParcel(JDefinedClass jclass) {
  JMethod ctorFromParcel = jclass.constructor(JMod.PROTECTED);
  JVar in = ctorFromParcel.param(jclass.owner().directClass("android.os.Parcel"), "in");
  if (extendsParcelable(jclass)) {
    ctorFromParcel.body().directStatement("super(in);");
  }
  for (JFieldVar f : jclass.fields().values()) {
    if( (f.mods().getValue() & JMod.STATIC) == JMod.STATIC ) {
      continue;
    }
    if (f.type().erasure().name().equals("List")) {
      ctorFromParcel.body()
          .invoke(in, "readList")
          .arg(JExpr._this().ref(f))
          .arg(JExpr.direct(getListType(f.type()) + ".class.getClassLoader()"));
     } else {
      ctorFromParcel.body().assign(
          JExpr._this().ref(f),
          JExpr.cast(
              f.type(),
              in.invoke("readValue").arg(JExpr.direct(f.type().erasure().name() + ".class.getClassLoader()"))
          )
      );
    }
  }
}
origin: joelittlejohn/jsonschema2pojo

private void addHashCode(JDefinedClass jclass, JsonNode node) {
  Map<String, JFieldVar> fields = removeFieldsExcludedFromEqualsAndHashCode(jclass.fields(), node);
origin: joelittlejohn/jsonschema2pojo

private void addEquals(JDefinedClass jclass, JsonNode node) {
  Map<String, JFieldVar> fields = removeFieldsExcludedFromEqualsAndHashCode(jclass.fields(), node);
origin: fabric8io/kubernetes-client

private void annotateMetatadataValidator(JDefinedClass clazz) {
  if (clazz.name().equals("PodTemplateSpec")) {
    return;
  }
  for (Map.Entry<String, JFieldVar> f : clazz.fields().entrySet()) {
    if (f.getKey().equals("metadata") && f.getValue().type().name().equals("ObjectMeta")) {
      try {
        JAnnotationUse annotation = f.getValue().annotate(new JCodeModel()._class("io.fabric8.kubernetes.api.model.validators.CheckObjectMeta"));
        if (isMinimal(clazz)) {
          annotation.param("minimal", true);
        } else {
          annotation
            .param("regexp", "^" + getObjectNamePattern(clazz) + "$")
            .param("max", getObjectNameMaxLength(clazz));
        }
      } catch (JClassAlreadyExistsException e) {
        e.printStackTrace();
      }
      return;
    }
  }
}
origin: joelittlejohn/jsonschema2pojo

private void addToString(JDefinedClass jclass) {
  Map<String, JFieldVar> fields = jclass.fields();
  JMethod toString = jclass.method(JMod.PUBLIC, String.class, "toString");
  Set<String> excludes = new HashSet<>(Arrays.asList(ruleFactory.getGenerationConfig().getToStringExcludes()));
origin: fabric8io/kubernetes-client

if (clazz.fields().containsKey("kind") && clazz.fields().containsKey("metadata")) {
 String resourceName;
origin: org.jsonschema2pojo/jsonschema2pojo-core

private JFieldVar searchClassAndSuperClassesForField(String property, JDefinedClass jclass) {
  Map<String, JFieldVar> fields = jclass.fields();
  JFieldVar field = fields.get(property);
  if (field == null) {
    return searchSuperClassesForField(property, jclass);
  }
  return field;
}
origin: Evolveum/midpoint

private JFieldVar getReferencedField(JFieldVar field, ClassOutline classOutline) {
  QName qname = getFieldReferenceUseAnnotationQName(field, classOutline);
  CPropertyInfo propertyInfo = classOutline.target.getProperty(qname.getLocalPart());
  if (propertyInfo == null) {
    throw new IllegalArgumentException("No property "+qname.getLocalPart()+" in "+classOutline.target);
  }
  return classOutline.implClass.fields().get(propertyInfo.getName(false));
}
origin: org.andromda.thirdparty.jaxb2_commons/tools

public static JFieldVar field(FieldOutline fieldOutline) {
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  return theClass.fields().get(
      fieldOutline.getPropertyInfo().getName(false));
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc

/**
 * Adds "@Generated" to the classes, methods, and fields.
 */
private void augument(ClassOutline co) {
  annotate(co.implClass);
  for (JMethod m : co.implClass.methods())
    annotate(m);
  for (JFieldVar f : co.implClass.fields().values())
    annotate(f);
}
com.sun.codemodelJDefinedClassfields

Javadoc

Fields keyed by their names.

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.
  • 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
  • _class
    Add a new public nested class to this class.
  • javadoc,
  • _class,
  • getMethod,
  • _package,
  • dotclass,
  • enumConstant,
  • staticInvoke,
  • staticRef,
  • init

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setContentView (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • JOptionPane (javax.swing)
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now