JFieldRef fieldRef = JExpr.refthis(fieldVar.name());
JFieldRef thisFieldRef = JExpr.refthis(fieldVar.name()); JFieldRef otherFieldRef = JExpr.ref(rhsVar, fieldVar.name()); JExpression fieldEquals;
body.add(sb.invoke("append").arg(JExpr.refthis(fieldVar.name()))); } else if (fieldVar.type().isArray()) { JExpr.refthis(fieldVar.name()).eq(JExpr._null()), JExpr.lit("<null>"), jclass.owner().ref(Arrays.class).staticInvoke("toString") .arg(JExpr.refthis(fieldVar.name())) .invoke("replace").arg(JExpr.lit('[')).arg(JExpr.lit('{')) .invoke("replace").arg(JExpr.lit(']')).arg(JExpr.lit('}')) body.add(sb.invoke("append") .arg(JOp.cond( JExpr.refthis(fieldVar.name()).eq(JExpr._null()), JExpr.lit("<null>"), JExpr.refthis(fieldVar.name()))));
public JAXBElementNameField(final ClassOutlineImpl context, final CPropertyInfo prop, final CReferencePropertyInfo core, final CPropertyInfo valueProperty, final CNonElement type) { super(context, prop, core); this.valueProperty = valueProperty; this.valueField = JExpr.refthis(valueProperty.getName(false)); this.elementType = type; }
public JAXBElementValueField(ClassOutlineImpl context, CPropertyInfo prop, CReferencePropertyInfo core, CPropertyInfo nameProperty, CNonElement type) { super(context, prop, core); this.nameProperty = nameProperty; this.nameField = JExpr.refthis(nameProperty.getName(false)); this.type = type; }
public JAXBElementValueField(ClassOutlineImpl context, CPropertyInfo prop, CReferencePropertyInfo core, CPropertyInfo nameProperty, CNonElement type) { super(context, prop, core); this.nameProperty = nameProperty; this.nameField = JExpr.refthis(nameProperty.getName(false)); this.type = type; }
public JAXBElementNameField(final ClassOutlineImpl context, final CPropertyInfo prop, final CReferencePropertyInfo core, final CPropertyInfo valueProperty, final CNonElement type) { super(context, prop, core); this.valueProperty = valueProperty; this.valueField = JExpr.refthis(valueProperty.getName(false)); this.elementType = type; }
public AbstractWrappingField(ClassOutlineImpl context, CPropertyInfo prop, CPropertyInfo core) { super(context, prop); this.core = core; if (!Customizations.isGenerated(prop)) { this.coreField = JExpr.refthis(core.getName(false)); } else { this.coreField = null; } assert !exposedType.isPrimitive() && !implType.isPrimitive(); }
public AbstractWrappingField(ClassOutlineImpl context, CPropertyInfo prop, CPropertyInfo core) { super(context, prop); this.core = core; if (!Customizations.isGenerated(prop)) { this.coreField = JExpr.refthis(core.getName(false)); } else { this.coreField = null; } assert !exposedType.isPrimitive() && !implType.isPrimitive(); }
@SafeVarargs public static JVar addObjectParameter( final JMethod method, final JFieldVar field, final IProcedure<JVar, RuntimeException>... procedure) { if (method == null || field == null) { return null; } final JVar param = method.param(JMod.FINAL, field.type(), field.name()); for (final IProcedure<JVar, RuntimeException> closure : procedure) { closure.execute(param); } method.body().assign(JExpr.refthis(field.name()), param); return param; }
private JMethod addAddMethod(JDefinedClass builderClass, FieldOutline field) { List<JClass> typeParams = ((JClass) getJavaType(field)).getTypeParameters(); if (!typeParams.iterator().hasNext()) { return null; } JMethod method = builderClass.method(JMod.PUBLIC, builderClass, "add" + field.getPropertyInfo().getName(true)); JBlock block = method.body(); String fieldName = field.getPropertyInfo().getName(false); JVar param = method.param(JMod.FINAL, typeParams.iterator().next(), fieldName); JInvocation invocation = JExpr.refthis(fieldName).invoke("add").arg(param); block.add(invocation); block._return(JExpr.direct("this")); return method; }
private void generateDefaultPropertyAssignment(JMethod method, FieldOutline fieldOutline) { JBlock block = method.body(); String propertyName = fieldOutline.getPropertyInfo().getName(false); block.assign(JExpr.refthis(propertyName), defaultValue(getJavaType(fieldOutline), fieldOutline)); }
private void createHashCode(final JDefinedClass bean, final Iterable<JFieldVar> fields) { final JMethod method = bean.method(JMod.PUBLIC, this.codeModel.INT, "hashCode"); method.annotate(java.lang.Override.class); final JBlock block = method.body().block(); final JClass objectUtilities = _classByNames(net.anwiba.commons.lang.object.ObjectUtilities.class.getName()); JInvocation hashCode = objectUtilities.staticInvoke("hashCode"); for (final JFieldVar field : fields) { hashCode = hashCode.arg(JExpr.refthis(field.name())); } block._return(hashCode); }
private void nameGetter( final JDefinedClass instance, final String methodName, final Iterable<Annotation> annotations, final JFieldVar field) throws CreationException { final JMethod method = instance.method(JMod.PUBLIC, _type(JAVA_LANG_ITERABLE, JAVA_LANG_STRING), methodName); annotate(method, annotations); method.body()._return(JExpr.refthis(field.name()).invoke("keySet")); //$NON-NLS-1$ }
protected JFieldVar addConstructor(final JDefinedClass implClass) { final JClass serviceClass = getModel().ref("org.bonitasoft.engine.business.data.BusinessDataRepository"); final JFieldVar service = addField(implClass, "businessDataRepository", serviceClass); final JMethod constructor = implClass.constructor(JMod.PUBLIC); constructor.param(serviceClass, "businessDataRepository"); final JBlock body = constructor.body(); body.assign(JExpr.refthis("businessDataRepository"), JExpr.ref("businessDataRepository")); return service; }
protected JFieldVar addConstructor(final JDefinedClass implClass) { final JClass serviceClass = getModel().ref("org.bonitasoft.engine.business.data.BusinessDataRepository"); final JFieldVar service = addField(implClass, "businessDataRepository", serviceClass); final JMethod constructor = implClass.constructor(JMod.PUBLIC); constructor.param(serviceClass, "businessDataRepository"); final JBlock body = constructor.body(); body.assign(JExpr.refthis("businessDataRepository"), JExpr.ref("businessDataRepository")); return service; }
@Override public void execute(final JVar param) throws RuntimeException { ensureThatArgument(param, notNull()); method .body() ._if(param.eq(JExpr._null())) ._then() .block() .add(JExpr.refthis(param.name()).invoke("clear")) ._return(returnValue); } };
private void valueGetter( final JDefinedClass instance, final String methodName, final Iterable<Annotation> annotations, final Type type, final JFieldVar field) throws CreationException { final JMethod method = instance.method(JMod.PUBLIC, _class(type, true), methodName); final JVar param = method.param(JMod.FINAL, _type(JAVA_LANG_STRING), "name"); //$NON-NLS-1$ annotate(method, annotations); createAddIfNullReturnNullClosure(method).execute(param); method.body()._return(JExpr.refthis(field.name()).invoke("get").arg(param)); //$NON-NLS-1$ }
@Override public void execute(final JVar param) throws RuntimeException { ensureThatArgument(param, notNull()); method .body() ._if(param.eq(JExpr._null())) ._then() .block() .add(JExpr.refthis(param.name()).invoke("clear")) ._return(returnValue); } };
@Override public void execute(final JVar param) throws RuntimeException { ensureThatArgument(param, notNull()); final ValueConverter valueConverter = new ValueConverter(codeModel); final JInvocation invocation = JExpr._new(param.type()); method .body() ._if(param.eq(JExpr._null())) ._then() .block() .assign(JExpr.refthis(param.name()), valueConverter.convert(invocation)) ._return(returnValue); } };