Java Code Examples for com.sun.tools.xjc.outline.FieldOutline#parent()
The following examples show how to use
com.sun.tools.xjc.outline.FieldOutline#parent() .
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: FieldAccessorUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
public static JMethod getter(FieldOutline fieldOutline) { final JDefinedClass theClass = fieldOutline.parent().implClass; final String publicName = fieldOutline.getPropertyInfo().getName(true); final JMethod getgetter = theClass.getMethod("get" + publicName, NONE); if (getgetter != null) { return getgetter; } else { final JMethod isgetter = theClass .getMethod("is" + publicName, NONE); if (isgetter != null) { return isgetter; } else { return null; } } }
Example 2
Source File: FieldUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
public static Set<JType> getPossibleTypes(FieldOutline fieldOutline, Aspect aspect) { Validate.notNull(fieldOutline); final ClassOutline classOutline = fieldOutline.parent(); final Outline outline = classOutline.parent(); final CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo(); final Set<JType> types = new HashSet<JType>(); if (propertyInfo.getAdapter() != null) { types.add(propertyInfo.getAdapter().customType.toType(fieldOutline .parent().parent(), aspect)); } else if (propertyInfo.baseType != null) { types.add(propertyInfo.baseType); } else { Collection<? extends CTypeInfo> typeInfos = propertyInfo.ref(); for (CTypeInfo typeInfo : typeInfos) { types.addAll(getPossibleTypes(outline, aspect, typeInfo)); } } return types; }
Example 3
Source File: ClassDiscoverer.java From jaxb-visitor with Apache License 2.0 | 6 votes |
/** * Borrowed this code from jaxb-commons project * * @param fieldOutline reference to a field * @return Getter for the given field or null */ static JMethod getter(FieldOutline fieldOutline) { final JDefinedClass theClass = fieldOutline.parent().implClass; final String publicName = fieldOutline.getPropertyInfo().getName(true); final JMethod getgetter = theClass.getMethod("get" + publicName, NONE); if (getgetter != null) { return getgetter; } else { final JMethod isgetter = theClass .getMethod("is" + publicName, NONE); if (isgetter != null) { return isgetter; } else { return null; } } }
Example 4
Source File: FieldAccessorUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
/** * Returns the <code>setProperty(...)</code> method for the given field * outline or <code>null</code> if no such method exists. * * @param fieldOutline * field outline. * @return The <code>setProperty(...)</code> method for the given field * outline or <code>null</code> if no such method exists. */ public static JMethod setter(FieldOutline fieldOutline) { final JMethod getter = getter(fieldOutline); final JType type = getter != null ? getter.type() : fieldOutline .getRawType(); 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 }); }
Example 5
Source File: PluginContext.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
public static JMethod findGetter(final FieldOutline field) { final ClassOutline classOutline = field.parent(); String propertyName = field.getPropertyInfo().getName(true); if ("Any".equals(propertyName)) { propertyName = "Content"; } String getterName = "get" + propertyName; JMethod m = classOutline.implClass.getMethod(getterName, new JType[0]); if (m == null) { getterName = "is" + propertyName; m = classOutline.implClass.getMethod(getterName, new JType[0]); } return m; }
Example 6
Source File: PluginContext.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
public static JMethod findSetter(final FieldOutline field) { final ClassOutline classOutline = field.parent(); String propertyName = field.getPropertyInfo().getName(true); if ("Any".equals(propertyName)) { propertyName = "Content"; } final String setterName = "set" + propertyName; for (final JMethod method : classOutline.implClass.methods()) { if (method.name().equals(setterName) && method.listParams().length == 1) { return method; } } return null; }
Example 7
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); }
Example 8
Source File: ClassDiscoverer.java From jaxb-visitor with Apache License 2.0 | 4 votes |
static JFieldVar field(FieldOutline fieldOutline) { final JDefinedClass theClass = fieldOutline.parent().implClass; final String privateName = fieldOutline.getPropertyInfo().getName(false); return theClass.fields().get(privateName); }
Example 9
Source File: FieldAccessorUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 3 votes |
/** * Returns the <code>isSetProperty()</code> method for the given field * outline or <code>null</code> if no such method exists. * * @param fieldOutline * field outline. * @return The <code>isSetProperty()</code> method for the given field * outline or <code>null</code> if no such method exists. */ 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); }
Example 10
Source File: DefaultAssociationMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 3 votes |
public Collection<FieldOutline> getSourceIdFieldsOutline(Mapping context, FieldOutline fieldOutline) { final ClassOutline classOutline = fieldOutline.parent(); return getIdFieldsOutline(classOutline); }
Example 11
Source File: FieldAccessorUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns the field for the given field outline or <code>null</code> if no * such field exists. * * @param fieldOutline * field outline. * @return The field for the given field outline or <code>null</code> if no * such field exists. */ public static JFieldVar field(FieldOutline fieldOutline) { final JDefinedClass theClass = fieldOutline.parent().implClass; return theClass.fields().get( fieldOutline.getPropertyInfo().getName(false)); }