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

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

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

origin: joelittlejohn/jsonschema2pojo

  public static void addSerializableSupport(JDefinedClass jclass) {
    jclass._implements(Serializable.class);

    try {

      final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);

      processDefinedClassForSerializableSupport(jclass, dataOutputStream);

      dataOutputStream.flush();

      final MessageDigest digest = MessageDigest.getInstance("SHA");
      final byte[] digestBytes = digest.digest(byteArrayOutputStream.toByteArray());
      long serialVersionUID = 0L;

      for (int i = Math.min(digestBytes.length, 8) - 1; i >= 0; i--) {
        serialVersionUID = serialVersionUID << 8 | digestBytes[i] & 0xff;
      }

      JFieldVar  serialUIDField = jclass.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, long.class, "serialVersionUID");
      serialUIDField.init(JExpr.lit(serialVersionUID));

    } catch (IOException exception) {
      throw new GenerationException("IOException while generating serialversionUID field while adding serializable support to class: " + jclass.fullName(), exception);
    } catch (NoSuchAlgorithmException exception) {
      throw new GenerationException("SHA algorithm not found when trying to generate serialversionUID field while adding serializable support to class: " + jclass.fullName(), exception);
    }
  }
}
origin: joelittlejohn/jsonschema2pojo

JFieldRef getOrAddNotFoundVar(JDefinedClass jclass) {
  jclass.field(PROTECTED | STATIC | FINAL, Object.class, NOT_FOUND_VALUE_FIELD,
      _new(jclass.owner()._ref(Object.class)));
  return jclass.staticRef(NOT_FOUND_VALUE_FIELD);
}
origin: joelittlejohn/jsonschema2pojo

private JFieldVar addValueField(JDefinedClass _enum, JType type) {
  JFieldVar valueField = _enum.field(JMod.PRIVATE | JMod.FINAL, type, VALUE_FIELD_NAME);
  JMethod constructor = _enum.constructor(JMod.PRIVATE);
  JVar valueParam = constructor.param(type, VALUE_FIELD_NAME);
  JBlock body = constructor.body();
  body.assign(JExpr._this().ref(valueField), valueParam);
  return valueField;
}
origin: joelittlejohn/jsonschema2pojo

public void addCreator(JDefinedClass jclass) {
  JClass creatorType = jclass.owner().directClass("android.os.Parcelable.Creator").narrow(jclass);
  JDefinedClass creatorClass = jclass.owner().anonymousClass(creatorType);
  
  addCreateFromParcel(jclass, creatorClass);
  addNewArray(jclass, creatorClass);
  
  JFieldVar creatorField = jclass.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, creatorType, "CREATOR");
  creatorField.init(JExpr._new(creatorClass));
}
origin: joelittlejohn/jsonschema2pojo

private JFieldVar addAdditionalPropertiesField(JDefinedClass jclass, JType propertyType) {
  JClass propertiesMapType = jclass.owner().ref(Map.class);
  propertiesMapType = propertiesMapType.narrow(jclass.owner().ref(String.class), propertyType.boxify());
  JClass propertiesMapImplType = jclass.owner().ref(HashMap.class);
  propertiesMapImplType = propertiesMapImplType.narrow(jclass.owner().ref(String.class), propertyType.boxify());
  JFieldVar field = jclass.field(JMod.PRIVATE, propertiesMapType, "additionalProperties");
  ruleFactory.getAnnotator().additionalPropertiesField(field, jclass, "additionalProperties");
  field.init(JExpr._new(propertiesMapImplType));
  return field;
}
origin: joelittlejohn/jsonschema2pojo

private JFieldVar addQuickLookupMap(JDefinedClass _enum, JType backingType) {
  JClass lookupType = _enum.owner().ref(Map.class).narrow(backingType.boxify(), _enum);
  JFieldVar lookupMap = _enum.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, lookupType, "CONSTANTS");
  JClass lookupImplType = _enum.owner().ref(HashMap.class).narrow(backingType.boxify(), _enum);
  lookupMap.init(JExpr._new(lookupImplType));
  JForEach forEach = _enum.init().forEach(_enum, "c", JExpr.invoke("values"));
  JInvocation put = forEach.body().invoke(lookupMap, "put");
  put.arg(forEach.var().ref("value"));
  put.arg(forEach.var());
  return lookupMap;
}
origin: joelittlejohn/jsonschema2pojo

JFieldVar field = jclass.field(accessModifier, propertyType, propertyName);
origin: e-biz/androidkickstartr

private JFieldVar createViewField(JClass type, String name) {
  int mod = appDetails.isAndroidAnnotations() || appDetails.isRoboguice() ? JMod.NONE : JMod.PRIVATE;
  JFieldVar field = jClass.field(mod, type, name);
  return field;
}
origin: e-biz/androidkickstartr

private void createAndInitLocationsField() {
  // private String[] locations;
  locationsField = jClass.field(JMod.PRIVATE, ref.string().array(), "locations");
  // locations = getResources().getStringArray(R.array.locations);
  JFieldRef rArrayLocations = ref.r().staticRef("array").ref("locations");
  JInvocation getResources = JExpr.invoke("getResources");
  JInvocation getStringArray = getResources.invoke("getStringArray").arg(rArrayLocations);
  afterViewsBody.assign(locationsField, getStringArray);
}
origin: e-biz/androidkickstartr

private void addRestClient(JFieldVar textViewField) {
  // add annotated restClient field
  JFieldVar restClient = jClass.field(JMod.NONE, ref.ref(appDetails.getRestClientPackage()), "restClient");
  restClient.annotate(ref.restService());
  // add doSomethingElseOnUiThread method
  JMethod doSomethingElseOnUiThread = jClass.method(JMod.NONE, jCodeModel.VOID, "doSomethingElseOnUiThread");
  doSomethingElseOnUiThread.annotate(ref.uithread());
  JBlock body = doSomethingElseOnUiThread.body();
  if (textViewField != null) {
    body.invoke(textViewField, "setText").arg("Hi!");
  } else {
    body.directStatement("// do something on UIThread");
  }
  // add doSomethingInBackground method
  JMethod doSomethingInBackground = jClass.method(JMod.NONE, jCodeModel.VOID, "doSomethingInBackground");
  doSomethingInBackground.annotate(ref.background());
  JBlock doSomethingInBackgroundBody = doSomethingInBackground.body();
  doSomethingInBackgroundBody.invoke(restClient, "main");
  doSomethingInBackgroundBody.invoke(doSomethingElseOnUiThread);
}
origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

public SingleMarshallingField(ClassOutlineImpl context, CPropertyInfo prop,
    CPropertyInfo core, String contextPath, boolean _final) {
  super(context, prop, core);
  this.contextPath = context.implClass.field(JMod.PUBLIC | JMod.STATIC
      | (_final ? JMod.FINAL : JMod.NONE), String.class, prop
      .getName(true)
      + "ContextPath", JExpr.lit(contextPath));
}
origin: org.apache.drill.exec/drill-java-exec

public JVar declareClassField(String prefix, JType t, JExpression init) {
 if (innerClassGenerator != null && hasMaxIndexValue()) {
  return innerClassGenerator.declareClassField(prefix, t, init);
 }
 return clazz.field(JMod.NONE, t, prefix + index++, init);
}
origin: sun-jaxb/jaxb-xjc

public JFieldVar field(
  int mods,
  Class type,
  String name,
  JExpression init) {
  return field(mods, owner()._ref(type), name, init);
}
origin: org.jvnet.jaxb2_commons/jaxb2-basics-tools

protected JFieldVar generateField() {
  // generate the constant
  JExpression value = createValue();
  JFieldVar field = referenceClass.field(JMod.PUBLIC | JMod.STATIC
      | JMod.FINAL, type, propertyInfo.getPublicName(), value);
  annotate(field);
  return field;
}
origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

protected final void createField() {
  field = outline.implClass.field( JMod.PROTECTED,
    getFieldType(), prop.getName(false) );
  annotate(field);
}
origin: org.glassfish.metro/webservices-tools

protected final void createField() {
  field = outline.implClass.field( JMod.PROTECTED,
    getFieldType(), prop.getName(false) );
  annotate(field);
}
origin: e-biz/androidkickstartr

if (hasLocationsField) {
  locationsField = jClass.field(JMod.PRIVATE, ref.string().array(), "locations");
origin: org.glassfish.metro/webservices-tools

protected final void generate() {
  // for the collectionType customization to take effect, the field needs to be strongly typed,
  // not just List<Foo>.
  field = outline.implClass.field( JMod.PROTECTED, listT, prop.getName(false) );
  if(eagerInstanciation)
    field.init(newCoreList());
  annotate(field);
  // generate the rest of accessors
  generateAccessors();
}
origin: e-biz/androidkickstartr

JFieldVar labelTextField = jClass.field(appDetails.isAndroidAnnotations() || appDetails.isRoboguice() ? JMod.NONE : JMod.PRIVATE, ref.textView(), "labelText");
origin: jpmml/jpmml-evaluator

private void createReportingVectorClass(JCodeModel codeModel, String name, JPrimitiveType type) throws JClassAlreadyExistsException {
  JDefinedClass clazz = codeModel._class(JMod.ABSTRACT | JMod.PUBLIC, "org.jpmml.evaluator.Reporting" + name, ClassType.CLASS);
  clazz._extends(codeModel.ref("org.jpmml.evaluator." + name));
  JFieldVar expressionField = clazz.field(JMod.PRIVATE, String.class, "expression", JExpr.lit(""));
  createNewReportMethod(clazz);
  createOperationMethods(clazz, name, type);
  createValueMethods(clazz, type);
  createReportMethod(clazz);
  createAccessorMethods(clazz, expressionField);
}
com.sun.codemodelJDefinedClassfield

Javadoc

Adds a field to the list of field members of this JDefinedClass.

Popular methods of JDefinedClass

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

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • setContentView (Activity)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JButton (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • From CI to AI: The AI layer in your organization
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