Java Code Examples for com.sun.tools.xjc.outline.FieldOutline#create()
The following examples show how to use
com.sun.tools.xjc.outline.FieldOutline#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettersPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void generateSetter(FieldOutline fieldOutline, JDefinedClass theClass, JMethod setter, JVar value) { final FieldAccessor accessor = fieldOutline.create(JExpr ._this()); accessor.unsetValues(setter.body()); accessor.fromRawValue(setter.body()._if(value.ne(JExpr._null()))._then(), "draft", value); }
Example 2
Source File: PropertyFieldAccessorFactory.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 4 votes |
public PropertyFieldAccessor(final FieldOutline fieldOutline, JExpression targetObject) { super(); this.fieldOutline = fieldOutline; this.targetObject = targetObject; this.fieldAccessor = fieldOutline.create(targetObject); final String publicName = fieldOutline.getPropertyInfo().getName( true); final String privateName = fieldOutline.getPropertyInfo().getName( false); this.theClass = fieldOutline.parent().implClass; final String setterName = "set" + publicName; final JMethod getGetter = theClass.getMethod("get" + publicName, ABSENT); final JMethod isGetter = theClass.getMethod("is" + publicName, ABSENT); final JFieldVar field = theClass.fields().get(privateName); this.field = field != null && ((field.mods().getValue() & JMod.PROTECTED) != 0) && ((field.mods().getValue() & JMod.STATIC) == 0) && ((field.mods().getValue() & JMod.FINAL) == 0) ? field : null; this.getter = getGetter != null ? getGetter : (isGetter != null ? isGetter : null); this.type = this.getter != null ? this.getter.type() : fieldOutline .getRawType(); this.fieldType = this.field != null ? this.field.type() : this.type; final JFieldVar constantField = theClass.fields().get(publicName); this.constantField = constantField != null && ((constantField.mods().getValue() & JMod.PUBLIC) != 0) && ((constantField.mods().getValue() & JMod.STATIC) != 0) && ((constantField.mods().getValue() & JMod.FINAL) != 0) ? constantField : null; // fieldOutline.getRawType(); final JType rawType = fieldOutline.getRawType(); final JMethod boxifiedSetter = theClass.getMethod(setterName, new JType[] { rawType.boxify() }); final JMethod unboxifiedSetter = theClass.getMethod(setterName, new JType[] { rawType.unboxify() }); this.setter = boxifiedSetter != null ? boxifiedSetter : unboxifiedSetter; this.isSetter = theClass.getMethod("isSet" + publicName, ABSENT); this.unSetter = theClass.getMethod("unset" + publicName, ABSENT); }