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

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

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

  • 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 JMethod getInternalSetMethod(JDefinedClass jclass) {
  return jclass.getMethod(DEFINED_SETTER_NAME,
      new JType[] { jclass.owner().ref(String.class), jclass.owner().ref(Object.class) });
}
origin: joelittlejohn/jsonschema2pojo

private JMethod getInternalGetMethod(JDefinedClass jclass) {
  return jclass.getMethod(DEFINED_GETTER_NAME,
      new JType[] { jclass.owner().ref(String.class), jclass.owner().ref(Object.class) });
}
origin: joelittlejohn/jsonschema2pojo

private void addGetPropertyCase(JDefinedClass jclass, JSwitch propertySwitch, String propertyName, JType propertyType, JsonNode node) {
  JMethod propertyGetter = jclass.getMethod(getGetterName(propertyName, propertyType, node), new JType[] {});
  propertySwitch._case(lit(propertyName)).body()
  ._return(invoke(propertyGetter));
}
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

      propertyConditional = propertyConditional._elseif(condition);
    JMethod propertyGetter = jclass.getMethod(getGetterName(propertyName, propertyType, node), new JType[] {});
    propertyConditional._then()._return(invoke(propertyGetter));
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) });
  lastBlock._return(_super().invoke(parentMethod).arg(nameParam).arg(notFoundParam));
origin: joelittlejohn/jsonschema2pojo

JMethod parentMethod = parentClass.getMethod(DEFINED_SETTER_NAME,
    new JType[] { parentClass.owner()._ref(String.class), parentClass.owner()._ref(Object.class) });
lastBlock._return(_super().invoke(parentMethod).arg(nameParam).arg(valueParam));
origin: joelittlejohn/jsonschema2pojo

private void addSetProperty(JDefinedClass jclass, JBlock callSite, String propertyName, JType propertyType, JVar valueVar, JsonNode node) {
  JMethod propertySetter = jclass.getMethod(getSetterName(propertyName, node), new JType[] { propertyType });
  JConditional isInstance = callSite._if(valueVar._instanceof(propertyType.boxify().erasure()));
  isInstance._then()
  .invoke(propertySetter).arg(cast(propertyType.boxify(), valueVar));
  isInstance._else()
  ._throw(illegalArgumentInvocation(jclass, propertyName, propertyType, valueVar));
}
origin: joelittlejohn/jsonschema2pojo

  private void addOverrideBuilder(JDefinedClass thisJDefinedClass, JMethod parentBuilder, JVar parentParam) {

    if (thisJDefinedClass.getMethod(parentBuilder.name(), new JType[] {parentParam.type()}) == null) {

      JMethod builder = thisJDefinedClass.method(parentBuilder.mods().getValue(), thisJDefinedClass, parentBuilder.name());
      builder.annotate(Override.class);

      JVar param = builder.param(parentParam.type(), parentParam.name());
      JBlock body = builder.body();
      body.invoke(JExpr._super(), parentBuilder).arg(param);
      body._return(JExpr._this());

    }
  }
}
origin: joelittlejohn/jsonschema2pojo

private JMethod addPublicSetMethod(JDefinedClass jclass, JMethod internalSetMethod) {
  JMethod method = jclass.method(PUBLIC, jclass.owner().VOID, SETTER_NAME);
  JVar nameParam = method.param(String.class, "name");
  JVar valueParam = method.param(Object.class, "value");
  JBlock body = method.body();
  JBlock notFound = body._if(JOp.not(invoke(internalSetMethod).arg(nameParam).arg(valueParam)))._then();
  // if we have additional properties, then put value.
  JMethod getAdditionalProperties = jclass.getMethod("getAdditionalProperties", new JType[] {});
  if (getAdditionalProperties != null) {
    JType additionalPropertiesType = ((JClass) (getAdditionalProperties.type())).getTypeParameters().get(1);
    notFound.add(invoke(getAdditionalProperties).invoke("put").arg(nameParam)
        .arg(cast(additionalPropertiesType, valueParam)));
  }
  // else throw exception.
  else {
    notFound._throw(illegalArgumentInvocation(jclass, nameParam));
  }
  return method;
}
origin: joelittlejohn/jsonschema2pojo

private JMethod addPublicWithMethod(JDefinedClass jclass, JMethod internalSetMethod) {
  JMethod method = jclass.method(PUBLIC, jclass, BUILDER_NAME);
  JVar nameParam = method.param(String.class, "name");
  JVar valueParam = method.param(Object.class, "value");
  JBlock body = method.body();
  JBlock notFound = body._if(JOp.not(invoke(internalSetMethod).arg(nameParam).arg(valueParam)))._then();
  // if we have additional properties, then put value.
  JMethod getAdditionalProperties = jclass.getMethod("getAdditionalProperties", new JType[] {});
  if (getAdditionalProperties != null) {
    JType additionalPropertiesType = ((JClass) (getAdditionalProperties.type())).getTypeParameters().get(1);
    notFound.add(invoke(getAdditionalProperties).invoke("put").arg(nameParam)
        .arg(cast(additionalPropertiesType, valueParam)));
  }
  // else throw exception.
  else {
    notFound._throw(illegalArgumentInvocation(jclass, nameParam));
  }
  body._return(_this());
  return method;
}
origin: joelittlejohn/jsonschema2pojo

private JMethod addPublicGetMethod(JDefinedClass jclass, JMethod internalGetMethod, JFieldRef notFoundValue) {
  JMethod method = jclass.method(PUBLIC, jclass.owner()._ref(Object.class), GETTER_NAME);
  JTypeVar returnType = method.generify("T");
  method.type(returnType);
  Models.suppressWarnings(method, "unchecked");
  JVar nameParam = method.param(String.class, "name");
  JBlock body = method.body();
  JVar valueVar = body.decl(jclass.owner()._ref(Object.class), "value",
      invoke(internalGetMethod).arg(nameParam).arg(notFoundValue));
  JConditional found = method.body()._if(notFoundValue.ne(valueVar));
  found._then()._return(cast(returnType, valueVar));
  JBlock notFound = found._else();
  JMethod getAdditionalProperties = jclass.getMethod("getAdditionalProperties", new JType[] {});
  if (getAdditionalProperties != null) {
    notFound._return(cast(returnType, invoke(getAdditionalProperties).invoke("get").arg(nameParam)));
  } else {
    notFound._throw(illegalArgumentInvocation(jclass, nameParam));
  }
  return method;
}
origin: net.sourceforge.ccxjc/cc-xjc-plugin

private JMethod getPropertyGetter( final FieldOutline f )
{
  final JDefinedClass clazz = f.parent().implClass;
  final String name = f.getPropertyInfo().getName( true );
  JMethod getter = clazz.getMethod( "get" + name, NO_ARGS );
  if ( getter == null )
  {
    getter = clazz.getMethod( "is" + name, NO_ARGS );
  }
  return getter;
}
origin: org.jvnet.jaxb2_commons/tools

public static JMethod issetter(FieldOutline fieldOutline) {
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  final String publicName = fieldOutline.getPropertyInfo().getName(true);
  final String name = "isSet" + publicName;
  return theClass.getMethod(name, NONE);
}
origin: org.jvnet.hyperjaxb3/hyperjaxb3-tools

public static JMethod getter(FieldOutline fieldOutline) {
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  final String publicName = fieldOutline.getPropertyInfo().getName(true);
  final String name = "get" + publicName;
  return theClass.getMethod(name, NONE);
}
origin: com.seovic.coherence/pof

  /**
  * Returns the setter method for a given field.
  *
  * @param fieldOutline  field outline
  * @return setter for the specified field
  */
  protected JMethod setter(FieldOutline fieldOutline) {
    JDefinedClass theClass = fieldOutline.parent().implClass;
    String publicName = fieldOutline.getPropertyInfo().getName(true);
    return theClass.getMethod("set" + publicName, new JType[] {fieldOutline.getRawType()});
  }
}
origin: org.jvnet.jaxb2_commons/tools

public static JMethod setter(FieldOutline fieldOutline) {
  final JMethod getter = getter(fieldOutline);
  assert getter != null : "Getter is required.";
  final JType type = getter.type();
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  final String publicName = fieldOutline.getPropertyInfo().getName(true);
  final String name = "set" + publicName;
  return theClass.getMethod(name, new JType[] { type });
}
 
origin: org.andromda.thirdparty.jaxb2_commons/tools

public static JMethod setter(FieldOutline fieldOutline) {
  final JMethod getter = getter(fieldOutline);
  assert getter != null : "Getter is required.";
  final JType type = getter.type();
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  final String publicName = fieldOutline.getPropertyInfo().getName(true);
  final String name = "set" + publicName;
  return theClass.getMethod(name, new JType[] { type });
}
 
origin: jpmml/jpmml-model

static
public void createSetterProxy(JDefinedClass beanClazz, JType type, String parameterName, String name, String setterName){
  JMethod getterMethod = beanClazz.getMethod(setterName.replace("set", "get"), new JType[0]);
  JMethod method = beanClazz.method(JMod.PUBLIC, beanClazz, name);
  method.annotate(Override.class);
  JVar nameParameter = method.param(type, parameterName);
  method.body()._return(JExpr.invoke(setterName).arg(nameParameter));
  moveBefore(beanClazz, method, getterMethod);
}
origin: org.jsonschema2pojo/jsonschema2pojo-core

private void addSetProperty(JDefinedClass jclass, JBlock callSite, String propertyName, JType propertyType, JVar valueVar, JsonNode node) {
  JMethod propertySetter = jclass.getMethod(getSetterName(propertyName, node), new JType[] { propertyType });
  JConditional isInstance = callSite._if(valueVar._instanceof(propertyType.boxify().erasure()));
  isInstance._then()
  .invoke(propertySetter).arg(cast(propertyType.boxify(), valueVar));
  isInstance._else()
  ._throw(illegalArgumentInvocation(jclass, propertyName, propertyType, valueVar));
}
com.sun.codemodelJDefinedClassgetMethod

Javadoc

Looks for a method that has the specified method signature and return 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,
  • _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