protected JMethod createGetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod getter = writer.declareMethod(propertyListType, getGetterName()); final JBlock body = getter.body(); fix(body); body._return(propertyField); return getter; }
protected JMethod createGetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod getter = writer.declareMethod(propertyListType, getGetterName()); final JBlock body = getter.body(); fix(body); body._return(propertyField); return getter; }
protected JMethod createSetter() { final JMethod setter; final MethodWriter writer = outline.createMethodWriter(); setter = writer.declareMethod(codeModel.VOID, getSetterName()); final JVar value = writer.addParameter(propertyListType, "value"); final JBlock body = setter.body(); body.assign(wrappedPropertyField, JExpr._null()); body.assign(wrappingPropertyField, JExpr._null()); body.assign(propertyField, value); fix(body); return setter; }
protected JMethod createSetter() { final JMethod setter; final MethodWriter writer = outline.createMethodWriter(); setter = writer.declareMethod(codeModel.VOID, getSetterName()); final JVar value = writer.addParameter(propertyListType, "value"); final JBlock body = setter.body(); body.assign(wrappedPropertyField, JExpr._null()); body.assign(wrappingPropertyField, JExpr._null()); body.assign(propertyField, value); fix(body); return setter; }
@Override public void generateAccessors() { super.generateAccessors(); final MethodWriter writer = outline.createMethodWriter(); $set = writer.declareMethod(codeModel.VOID, "set" + prop.getName(true)); JVar var = writer.addParameter(listT, prop.getName(false)); writer.javadoc().append(prop.javadoc); JBlock block = $set.body(); block.assign(JExpr._this().ref(field), var); } }
@Override public void generateAccessors() { super.generateAccessors(); final MethodWriter writer = outline.createMethodWriter(); $set = writer.declareMethod(codeModel.VOID, "set" + prop.getName(true)); JVar var = writer.addParameter(listT, prop.getName(false)); writer.javadoc().append(prop.javadoc); JBlock block = $set.body(); block.assign(JExpr._this().ref(field), var); } }
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) { // add isSetXXX and unsetXXX. MethodWriter writer = outline.createMethodWriter(); JCodeModel codeModel = outline.parent().getCodeModel(); FieldAccessor acc = core.create(JExpr._this()); if( generateIsSetMethod ) { // [RESULT] boolean isSetXXX() JExpression hasSetValue = acc.hasSetValue(); if( hasSetValue==null ) { // this field renderer doesn't support the isSet/unset methods generation. // issue an error throw new UnsupportedOperationException(); } writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true)) .body()._return( hasSetValue ); } if( generateUnSetMethod ) { // [RESULT] void unsetXXX() acc.unsetValues( writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() ); } }
protected JMethod createSetter() { final JMethod setter; final MethodWriter writer = outline.createMethodWriter(); setter = writer.declareMethod(codeModel.VOID, getSetterName()); final JVar target = writer.addParameter(exposedType, "target"); final JExpression wrapCondition = wrapCondifiton(target); if (wrapCondition == null) { setCore(setter.body(), wrap(target)); } else { final JConditional _if = setter.body()._if(wrapCondition); setCore(_if._then(), wrap(target)); } return setter; }
protected JMethod createSetter() { final JMethod setter; final MethodWriter writer = outline.createMethodWriter(); setter = writer.declareMethod(codeModel.VOID, getSetterName()); final JVar target = writer.addParameter(exposedType, "target"); final JExpression wrapCondition = wrapCondifiton(target); if (wrapCondition == null) { setCore(setter.body(), wrap(target)); } else { final JConditional _if = setter.body()._if(wrapCondition); setCore(_if._then(), wrap(target)); } return setter; }
protected JMethod createSetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod setter = writer.declareMethod(codeModel.VOID, getSetterName()); final JVar var = writer.addParameter(exposedType, prop.getName(false)); final JBlock block = setter.body(); block.assign(field, var); block.assign(nameField, codeModel.ref(JAXBElementUtils.class) .staticInvoke("getName").arg(var)); block.assign(valueField, codeModel.ref(JAXBElementUtils.class) .staticInvoke("getValue").arg(var)); return setter; }
protected JMethod createSetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod setter = writer.declareMethod(codeModel.VOID, getSetterName()); final JVar var = writer.addParameter(exposedType, prop.getName(false)); final JBlock block = setter.body(); block.assign(field, var); block.assign(nameField, codeModel.ref(JAXBElementUtils.class) .staticInvoke("getName").arg(var)); block.assign(valueField, codeModel.ref(JAXBElementUtils.class) .staticInvoke("getValue").arg(var)); return setter; }
protected JMethod createGetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod getter = writer.declareMethod(exposedType, getGetterName()); final JBlock block = getter.body(); block._if(codeModel.ref(JAXBElementUtils.class).staticInvoke("shouldBeWrapped").arg(field).arg(nameField).arg(valueField)). _then().assign(field, codeModel.ref(JAXBElementUtils.class).staticInvoke("wrap").arg(field).arg(nameField).arg(valueField)); block._return(field); return setter; }
protected JMethod createGetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod getter = writer.declareMethod(exposedType, getGetterName()); JExpression source = getCore(); final JExpression unwrapCondition = unwrapCondifiton(source); if (unwrapCondition == null) { getter.body()._return(unwrap(source)); } else { final JConditional _if = getter.body()._if(unwrapCondition); _if._then()._return(unwrap(source)); _if._else()._return(JExpr._null()); } return getter; }
protected JMethod createGetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod getter = writer.declareMethod(exposedType, getGetterName()); JExpression source = getCore(); final JExpression unwrapCondition = unwrapCondifiton(source); if (unwrapCondition == null) { getter.body()._return(unwrap(source)); } else { final JConditional _if = getter.body()._if(unwrapCondition); _if._then()._return(unwrap(source)); _if._else()._return(JExpr._null()); } return getter; }
protected JMethod createGetter() { final MethodWriter writer = outline.createMethodWriter(); final JMethod getter = writer.declareMethod(exposedType, getGetterName()); final JBlock block = getter.body(); block._if(codeModel.ref(JAXBElementUtils.class).staticInvoke("shouldBeWrapped").arg(field).arg(nameField).arg(valueField)). _then().assign(field, codeModel.ref(JAXBElementUtils.class).staticInvoke("wrap").arg(field).arg(nameField).arg(valueField)); block._return(field); return setter; }
/** * Generates an attribute wildcard property on a class. */ private void generateAttributeWildcard( ClassOutlineImpl cc ) { String FIELD_NAME = "otherAttributes"; String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME); JClass mapType = codeModel.ref(Map.class).narrow(QName.class,String.class); JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class,String.class); // [RESULT] // Map<QName,String> m = new HashMap<QName,String>(); JFieldVar $ref = cc.implClass.field(JMod.PRIVATE, mapType, FIELD_NAME, JExpr._new(mapImpl) ); $ref.annotate2(XmlAnyAttributeWriter.class); MethodWriter writer = cc.createMethodWriter(); JMethod $get = writer.declareMethod( mapType, "get"+METHOD_SEED ); $get.javadoc().append( "Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n" + "<p>\n" + "the map is keyed by the name of the attribute and \n" + "the value is the string value of the attribute.\n" + "\n" + "the map returned by this method is live, and you can add new attribute\n" + "by updating the map directly. Because of this design, there's no setter.\n"); $get.javadoc().addReturn().append("always non-null"); $get.body()._return($ref); }