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) : propertyConditional._elseif(condition); 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)); } else { lastBlock._return(FALSE);
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; }
JType propertyType = jclass.fields().get(fieldName).type(); JExpression condition = lit(propertyName).invoke("equals").arg(nameParam); if (propertyConditional == null) { propertyConditional = body._if(condition); 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)); } else { lastBlock._return(notFoundParam);
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; }
body.assign(result, result.mul(JExpr.lit(31)).plus(JExpr._super().invoke("hashCode")));
result = result.cand(JExpr._super().invoke("equals").arg(rhsVar));
JExpression as(JExpression rhs, TypeMirror targetType) { return JExpr.cast(toJtype.visit(targetType, null), rhs.invoke("get")); } JClass sourceType() {
void pack(JBlock block, JExpression item, JExpression itemDom) { // [RESULT] // x.put(dom.getKey(),<rhs>); block.invoke($map,"put").arg(itemDom.invoke("getKey")).arg(item); }
/** * Do the opposite of the wrap method. * * REVISIT: it's not clear how this method works for VOID. */ public JExpression unwrap( JExpression exp ) { // it just so happens that the unwrap method is always // things like "intValue" or "booleanValue". return exp.invoke(typeName+"Value"); }
MethodGenerator(String methodNamePrefix, JMethod reinjectionMethod, Property p, String xmlName) { this.xmlName = p.inferName(xmlName); this.p = p; if(generateNoopConfigInjector) { body = null; $dom = null; $target = null; } else { JMethod m = injector.method(JMod.PUBLIC,void.class, methodNamePrefix+p.seedName()); $dom = m.param(Dom.class,"dom"); $target = m.param(targetType,"target"); body = m.body(); injectMethod.body().invoke(m).arg($dom).arg($target); reinjectionMethod.body()._if(JExpr.lit(this.xmlName).invoke("equals").arg(JExpr.ref("name"))) ._then().invoke(m).arg($dom).arg($target); } erasure = erasure(p.type()); packer = createPacker(p.type(),erasure); itemType = packer==null ? erasure : erasure(packer.itemType()); }
public static JStatement set(JExpression _this, FieldOutline fieldOutline, JExpression value) { final JMethod setter = setter(fieldOutline); return _this.invoke(setter).arg(value); }
public static void get( JBlock block, JVar var, JExpression target, final ClassContext classContext, final FieldItem fieldItem) { final JMethod method = get(classContext, fieldItem); block.assign(var, target.invoke(method)); }
public void fromRawValue(JBlock block, String uniqueName, JExpression $var) { // [RESULT] // bean.getLIST().addAll($<var>); JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get)); block.invoke($list,"addAll").arg($var); } }
public void fromRawValue(JBlock block, String uniqueName, JExpression $var) { // [RESULT] // bean.getLIST().addAll($<var>); JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get)); block.invoke($list,"addAll").arg($var); } }
public void fromRawValue(JBlock block, String uniqueName, JExpression $var) { // [RESULT] // bean.getLIST().addAll($<var>); JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get)); block.invoke($list,"addAll").arg($var); } }
@Override protected JExpression unwrap(JExpression source) { return JOp.cond(source.eq(JExpr._null()), JExpr._null(), source .invoke("value")); }
public TypedExpression initializeProxy(InjectionBuilderContext context, TypedExpression proxyVariable, TypedExpression variableBuilder) { context.getBlock().add( proxyVariable.getExpression().invoke(DelayedLoad.LOAD_METHOD).arg(variableBuilder.getExpression())); return variableBuilder; } }
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation)); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null())); ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg( "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath.")); staticBlock.assign(exField, exVar); }
private void writeClassLoaderBaseResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null()); JTryBlock tryBlock = staticBlock._try(); tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(".")).arg(wsdlLocation)); JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class)); JVar murlVar = catchBlock.param("murl"); catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(murlVar)); staticBlock.assign(urlField, urlVar); staticBlock.assign(exField, exVar); }