Java Code Examples for com.sun.tools.xjc.outline.ClassOutline#getSuperClass()
The following examples show how to use
com.sun.tools.xjc.outline.ClassOutline#getSuperClass() .
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: EmbeddedAssociationMappingWrapper.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
private Collection<FieldOutline> getIdFieldsOutline( final ClassOutline classOutline) { final Collection<FieldOutline> idFieldOutlines = new ArrayList<FieldOutline>(); ClassOutline current = classOutline; while (current != null) { for (FieldOutline idFieldOutline : current.getDeclaredFields()) { final CPropertyInfo propertyInfo = idFieldOutline .getPropertyInfo(); if ((CustomizationUtils.containsCustomization(propertyInfo, Customizations.ID_ELEMENT_NAME) || CustomizationUtils .containsCustomization(propertyInfo, Customizations.EMBEDDED_ID_ELEMENT_NAME)) && !CustomizationUtils.containsCustomization( propertyInfo, Customizations.IGNORED_ELEMENT_NAME)) { idFieldOutlines.add(idFieldOutline); } } current = current.getSuperClass(); } return idFieldOutlines; }
Example 2
Source File: DefaultAssociationMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
private Collection<FieldOutline> getIdFieldsOutline( final ClassOutline classOutline) { final Collection<FieldOutline> idFieldOutlines = new ArrayList<FieldOutline>(); ClassOutline current = classOutline; while (current != null) { for (FieldOutline idFieldOutline : current.getDeclaredFields()) { final CPropertyInfo propertyInfo = idFieldOutline .getPropertyInfo(); if ((CustomizationUtils.containsCustomization(propertyInfo, Customizations.ID_ELEMENT_NAME) || CustomizationUtils .containsCustomization(propertyInfo, Customizations.EMBEDDED_ID_ELEMENT_NAME)) && !CustomizationUtils.containsCustomization( propertyInfo, Customizations.IGNORED_ELEMENT_NAME)) { idFieldOutlines.add(idFieldOutline); } } current = current.getSuperClass(); } return idFieldOutlines; }
Example 3
Source File: DefaultIgnoring.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public boolean isClassOutlineIgnored(Mapping context, ClassOutline classOutline) { if (isPackageOutlineIgnored(context, classOutline.parent(), classOutline._package())) { logger.debug("Class outline is ignored since package is ignored."); markAsAcknowledged(classOutline); return true; } else if (CustomizationUtils.containsCustomization(classOutline, Customizations.IGNORED_ELEMENT_NAME)) { logger.debug("Class outline is ignored per customization."); markAsAcknowledged(classOutline); return true; } else if (classOutline.getSuperClass() != null && isClassOutlineIgnored(context, classOutline.getSuperClass())) { logger.debug("Class outline is ignored since superclass outline is ignored."); markAsAcknowledged(classOutline); return true; } else { return false; } }
Example 4
Source File: CodeModelUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
public static JMethod getMethod(final ClassOutline classOutline, final String name) { final JDefinedClass ref = classOutline.ref; final JMethod method = getMethod(ref, name); if (method != null) { return method; } else { final ClassOutline superClassOutline = classOutline.getSuperClass(); if (superClassOutline == null) { return null; } else { return getMethod(superClassOutline, name); } } }
Example 5
Source File: ClassUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
private static void addAncestors(ClassOutline classOutline, List<ClassOutline> classOutlines) { if (classOutline.getSuperClass() != null) { final ClassOutline superClassOutline = classOutline.getSuperClass(); addAncestors(superClassOutline, classOutlines); } }
Example 6
Source File: ClassUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
public static FieldOutline[] getFields(ClassOutline classOutline) { final List<FieldOutline> fields = new ArrayList<FieldOutline>(); fields.addAll(Arrays.asList(classOutline.getDeclaredFields())); if (classOutline.getSuperClass() != null) { fields.addAll(Arrays .asList(getFields(classOutline.getSuperClass()))); } return fields.toArray(new FieldOutline[fields.size()]); }
Example 7
Source File: CustomizationUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
public static FieldOutline findInheritedFieldWithCustomization(ClassOutline classOutline, final QName name) { for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) { if (containsCustomization(fieldOutline, name)) { return fieldOutline; } } final ClassOutline superClassOutline = classOutline.getSuperClass(); if (superClassOutline != null) { return findInheritedFieldWithCustomization(superClassOutline, name); } else { return null; } }
Example 8
Source File: EntityMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public boolean isRootClass(Mapping context, ClassOutline classOutline) { if (classOutline.getSuperClass() != null) { return !CustomizationUtils.containsCustomization(classOutline, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME) && !isSelfOrAncestorRootClass(context, classOutline.getSuperClass()); } else { return !CustomizationUtils.containsCustomization(classOutline, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME); } }
Example 9
Source File: EntityMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public boolean isSelfOrAncestorRootClass(Mapping context, ClassOutline classOutline) { if (context.getIgnoring().isClassOutlineIgnored(context, classOutline)) { return false; } else if (isRootClass(context, classOutline)) { return true; } else if (classOutline.getSuperClass() != null) { return isSelfOrAncestorRootClass(context, classOutline.getSuperClass()); } else { return !CustomizationUtils.containsCustomization(classOutline, Customizations.MAPPED_SUPERCLASS_ELEMENT_NAME); } }
Example 10
Source File: BoundPropertiesPlugin.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
private void createSupportProperty(final Outline outline, final ClassOutline classOutline, final Class<?> supportClass, final Class<?> listenerClass, final String aspectName) { final JCodeModel m = outline.getCodeModel(); final JDefinedClass definedClass = classOutline.implClass; final String aspectNameCap = aspectName.substring(0, 1).toUpperCase() + aspectName.substring(1); if (classOutline.getSuperClass() == null) { // only generate fields in topmost classes final JFieldVar supportField = definedClass.field(JMod.PROTECTED | JMod.FINAL | JMod.TRANSIENT, supportClass, aspectName + BoundPropertiesPlugin.SUPPORT_FIELD_SUFFIX, JExpr._new(m.ref(supportClass)).arg(JExpr._this())); final JMethod addMethod = definedClass.method(JMod.PUBLIC, m.VOID, "add" + aspectNameCap + "Listener"); final JVar addParam = addMethod.param(JMod.FINAL, listenerClass, aspectName + "Listener"); addMethod.body().invoke(JExpr._this().ref(supportField), "add" + aspectNameCap + "Listener").arg(addParam); final JMethod removeMethod = definedClass.method(JMod.PUBLIC, m.VOID, "remove" + aspectNameCap + "Listener"); final JVar removeParam = removeMethod.param(JMod.FINAL, listenerClass, aspectName + "Listener"); removeMethod.body().invoke(JExpr._this().ref(supportField), "remove" + aspectNameCap + "Listener").arg(removeParam); } final JMethod withMethod = definedClass.method(JMod.PUBLIC, definedClass, "with" + aspectNameCap + "Listener"); final JVar withParam = withMethod.param(JMod.FINAL, listenerClass, aspectName + "Listener"); withMethod.body().invoke("add" + aspectNameCap + "Listener").arg(withParam); withMethod.body()._return(JExpr._this()); if (classOutline.getSuperClass() != null) { withMethod.annotate(Override.class); } }
Example 11
Source File: MetaPlugin.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
private JMethod generateVisitMethod(final ClassOutline classOutline) { final JDefinedClass definedClass = classOutline.implClass; final JMethod visitMethod = definedClass.method(JMod.PUBLIC, definedClass, this.visitMethodName); final JCodeModel codeModel = definedClass.owner(); final JClass visitorType = codeModel.ref(PropertyVisitor.class); final JVar visitorParam = visitMethod.param(JMod.FINAL, visitorType, "_visitor_"); if (classOutline.getSuperClass() != null) { visitMethod.body().add(JExpr._super().invoke(this.visitMethodName).arg(visitorParam)); } else { visitMethod.body().add(visitorParam.invoke("visit").arg(JExpr._this())); } return visitMethod; }
Example 12
Source File: ClassDiscoverer.java From jaxb-visitor with Apache License 2.0 | 5 votes |
static List<FieldOutline> findAllDeclaredAndInheritedFields(ClassOutline classOutline) { List<FieldOutline> fields = new LinkedList<>(); ClassOutline currentClassOutline = classOutline; while(currentClassOutline != null) { fields.addAll(Arrays.asList(currentClassOutline.getDeclaredFields())); currentClassOutline = currentClassOutline.getSuperClass(); } return fields; }
Example 13
Source File: PluginImpl.java From immutable-xjc with MIT License | 5 votes |
private boolean hasSuperClassWithSameName(ClassOutline clazz) { ClassOutline superclass = clazz.getSuperClass(); while (superclass != null) { if (superclass.implClass.name().equals(clazz.implClass.name())) { return true; } superclass = superclass.getSuperClass(); } return false; }
Example 14
Source File: EntityMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 4 votes |
public ClassOutline getSuperClass(Mapping context, ClassOutline classOutline) { return classOutline.getSuperClass(); }
Example 15
Source File: SelectorGenerator.java From jaxb2-rich-contract-plugin with MIT License | 4 votes |
private MetaInfoOutline generateMetaClass(final ClassOutline classOutline) { try { final JDefinedClass definedClass = classOutline.implClass; final JDefinedClass selectorClass = definedClass._class(JMod.PUBLIC | JMod.STATIC, this.selectorClassName); final JTypeVar rootTypeParam = selectorClass.generify("TRoot"); final JTypeVar parentTypeParam = selectorClass.generify("TParent"); rootTypeParam.bound(this.pluginContext.codeModel.ref(this.selectorBaseClass).narrow(rootTypeParam, this.pluginContext.codeModel.wildcard())); //parentTypeParam.bound(this.apiConstructs.codeModel.ref(Selector.class).narrow(parentTypeParam, this.apiConstructs.codeModel.wildcard())); final JMethod constructor = selectorClass.constructor(JMod.PUBLIC); final JVar rootParam = constructor.param(JMod.FINAL, rootTypeParam, "root"); final JVar parentParam = constructor.param(JMod.FINAL, parentTypeParam, "parent"); final JVar propertyNameParam = constructor.param(JMod.FINAL, this.pluginContext.stringClass, "propertyName"); if(this.selectorParamName != null) { final JVar includeParam = constructor.param(JMod.FINAL, getSelectorParamType(this.pluginContext.codeModel.wildcard(), definedClass.wildcard()), this.selectorParamName); constructor.body().invoke("super").arg(rootParam).arg(parentParam).arg(propertyNameParam).arg(includeParam); } else { constructor.body().invoke("super").arg(rootParam).arg(parentParam).arg(propertyNameParam); } final JClass productMapType = this.pluginContext.codeModel.ref(Map.class).narrow(String.class).narrow(this.propertyPathClass); final JMethod buildChildrenMethod = selectorClass.method(JMod.PUBLIC, productMapType, "buildChildren"); buildChildrenMethod.annotate(Override.class); final JVar productMapVar = buildChildrenMethod.body().decl(JMod.FINAL, productMapType, "products", JExpr._new(this.pluginContext.codeModel.ref(HashMap.class).narrow(String.class).narrow(this.propertyPathClass))); if(classOutline.getSuperClass() == null ) { selectorClass._extends(this.pluginContext.codeModel.ref(this.selectorBaseClass).narrow(rootTypeParam).narrow(parentTypeParam)); } final JDefinedClass rootSelectorClass = definedClass._class(JMod.PUBLIC | JMod.STATIC, this.rootSelectorClassName); rootSelectorClass._extends(selectorClass.narrow(rootSelectorClass).narrow(Void.class)); final JMethod rootSelectorConstructor = rootSelectorClass.constructor(JMod.NONE); if(this.selectorParamName != null) { final JVar rootSelectorClassIncludeParam = rootSelectorConstructor.param(JMod.FINAL, getSelectorParamType(this.pluginContext.voidClass, definedClass), this.selectorParamName); rootSelectorConstructor.body().invoke("super").arg(JExpr._null()).arg(JExpr._null()).arg(JExpr._null()).arg(rootSelectorClassIncludeParam); } else { rootSelectorConstructor.body().invoke("super").arg(JExpr._null()).arg(JExpr._null()).arg(JExpr._null()); } final JMethod rootMethod = rootSelectorClass.method(JMod.STATIC | JMod.PUBLIC, rootSelectorClass, "_root"); if(this.selectorParamName != null) { final JVar rootIncludeParam = rootMethod.param(JMod.FINAL, getSelectorParamType(this.pluginContext.voidClass, definedClass), this.selectorParamName); rootMethod.body()._return(JExpr._new(rootSelectorClass).arg(rootIncludeParam)); } else { rootMethod.body()._return(JExpr._new(rootSelectorClass)); } return new MetaInfoOutline(this, classOutline, selectorClass, rootTypeParam, parentTypeParam, buildChildrenMethod, productMapVar); } catch (final JClassAlreadyExistsException e) { SelectorGenerator.LOGGER.warning("Attempt to generate already existing class"); return null; } }