com.sun.tools.xjc.outline.ClassOutline Java Examples

The following examples show how to use com.sun.tools.xjc.outline.ClassOutline. 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: CreateTraverserInterface.java    From jaxb-visitor with Apache License 2.0 6 votes vote down vote up
@Override
protected void run(Set<ClassOutline> classes, Set<JClass> directClasses) {
    JDefinedClass scratch = getOutline().getClassFactory().createInterface(getPackage(), "_scratch", null);
    try {
        JDefinedClass _interface = getOutline().getClassFactory().createInterface(getPackage(), "Traverser", null);
        setOutput(_interface);
        final JTypeVar retType = scratch.generify("?");
        final JTypeVar exceptionType = _interface.generify("E", Throwable.class);
        final JClass narrowedVisitor = visitor.narrow(retType).narrow(exceptionType);

        for (JClass jc : allConcreteClasses(classes, directClasses)) {
            implTraverse(exceptionType, narrowedVisitor, jc);
        }
    } finally {
        jpackage.remove(scratch);
    }
}
 
Example #2
Source File: JaxbValidationsPlugins.java    From krasa-jaxb-tools with Apache License 2.0 6 votes vote down vote up
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
	try {
		for (ClassOutline co : model.getClasses()) {
			List<CPropertyInfo> properties = co.target.getProperties();
			for (CPropertyInfo property : properties) {
				if (property instanceof CElementPropertyInfo) {
					processElement((CElementPropertyInfo) property, co, model);
				} else if (property instanceof CAttributePropertyInfo) {
					processAttribute((CAttributePropertyInfo) property, co, model);
				} else if (property instanceof CValuePropertyInfo) {
					processAttribute((CValuePropertyInfo) property, co, model);
				}
			}
		}
		return true;
	} catch (Exception e) {
		log(e);
		return false;
	}
}
 
Example #3
Source File: BoundPropertiesPlugin.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private JMethod generateLazyProxyInitGetter(final ClassOutline classOutline, final FieldOutline fieldOutline) {
	final JCodeModel m = classOutline.parent().getCodeModel();
	final JDefinedClass definedClass = classOutline.implClass;
	final String fieldName = fieldOutline.getPropertyInfo().getName(false);
	final String getterName = "get" + fieldOutline.getPropertyInfo().getName(true);
	final JFieldVar collectionField = definedClass.fields().get(fieldName);
	final JClass elementType = ((JClass) collectionField.type()).getTypeParameters().get(0);
	final JClass proxyFieldType = m.ref(BoundList.class).narrow(elementType);
	final JFieldRef collectionFieldRef = JExpr._this().ref(collectionField);
	final JFieldRef proxyField = JExpr._this().ref(collectionField.name() + BoundPropertiesPlugin.PROXY_SUFFIX);
	final JMethod oldGetter = definedClass.getMethod(getterName, new JType[0]);
	definedClass.methods().remove(oldGetter);
	final JMethod newGetter = definedClass.method(JMod.PUBLIC, proxyFieldType, getterName);
	newGetter.body()._if(collectionFieldRef.eq(JExpr._null()))._then().assign(collectionFieldRef, JExpr._new(m.ref(ArrayList.class).narrow(elementType)));
	final JBlock ifProxyNull = newGetter.body()._if(proxyField.eq(JExpr._null()))._then();
	ifProxyNull.assign(proxyField, JExpr._new(m.ref(BoundListProxy.class).narrow(elementType)).arg(collectionFieldRef));
	newGetter.body()._return(proxyField);
	return newGetter;
}
 
Example #4
Source File: NoJavadocPlugin.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public boolean run(Outline outline, Options options, ErrorHandler errorHandler){
	JCodeModel codeModel = outline.getCodeModel();

	Collection<? extends ClassOutline> classOutlines = outline.getClasses();
	for(ClassOutline classOutline : classOutlines){
		JDefinedClass beanClazz = classOutline.implClass;

		nullifyJavadoc(beanClazz);
	}

	Collection<? extends EnumOutline> enumOutlines = outline.getEnums();
	for(EnumOutline enumOutline : enumOutlines){
		JDefinedClass clazz = enumOutline.clazz;

		nullifyJavadoc(clazz);
	}

	return true;
}
 
Example #5
Source File: FieldUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #6
Source File: LombokPlugin.java    From jaxb-lombok-plugin with MIT License 6 votes vote down vote up
@Override
public boolean run(Outline outline, Options options, ErrorHandler errorHandler) {
    // for each generated classes
    for (ClassOutline generatedClassOutline : outline.getClasses()) {
        JDefinedClass generatedClass = generatedClassOutline.implClass;
        if (!isAbstractClass(generatedClass) &&
                !generatedClass.fields().isEmpty()) {
            boolean commandExecuted = false;
            for (Command command : commands.values()) {
                if (command.isEnabled()) {
                    command.editGeneratedClass(generatedClass);
                    commandExecuted = true;
                }
            }

            if (!commandExecuted) {
                defaultCommand.editGeneratedClass(generatedClass);
            }
        }
    }
    return true;
}
 
Example #7
Source File: EqualsPlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected JMethod generateObject$equals(final ClassOutline classOutline,
		final JDefinedClass theClass) {
	final JCodeModel codeModel = theClass.owner();
	final JMethod objectEquals = theClass.method(JMod.PUBLIC,
			codeModel.BOOLEAN, "equals");
	objectEquals.annotate(Override.class);
	{
		final JVar object = objectEquals.param(Object.class, "object");
		final JBlock body = objectEquals.body();
		final JVar equalsStrategy = body.decl(JMod.FINAL,
				codeModel.ref(EqualsStrategy2.class), "strategy",
				createEqualsStrategy(codeModel));
		body._return(JExpr.invoke("equals").arg(JExpr._null())
				.arg(JExpr._null()).arg(object).arg(equalsStrategy));
	}
	return objectEquals;
}
 
Example #8
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private void generateMetaClass(final PluginContext pluginContext, final ClassOutline classOutline, final ErrorHandler errorHandler) throws SAXException {
	try {
		final JDefinedClass metaClass = classOutline.implClass._class(JMod.PUBLIC | JMod.STATIC, this.metaClassName);
		final JMethod visitMethod = generateVisitMethod(classOutline);
		for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) {
			if (this.extended) {
				generateExtendedMetaField(pluginContext, metaClass, visitMethod, fieldOutline);
			} else {
				generateNameOnlyMetaField(pluginContext, metaClass, fieldOutline);
			}
		}
		visitMethod.body()._return(JExpr._this());
	} catch (final JClassAlreadyExistsException e) {
		errorHandler.error(new SAXParseException(getMessage("error.metaClassExists", classOutline.implClass.name(), this.metaClassName), classOutline.target.getLocator()));
	}
}
 
Example #9
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private void generateImplementsEntries(final Map<QName, DefinedInterfaceOutline> groupInterfaces, final ClassOutline classOutline, final Iterable<? extends XSDeclaration> groupUses) throws SAXException {
	for (final XSDeclaration groupUse : groupUses) {
		final DefinedInterfaceOutline definedGroupType = groupInterfaces.get(PluginContext.getQName(groupUse));
		if (definedGroupType == null) {
			final ReferencedInterfaceOutline referencedInterfaceOutline = getReferencedInterfaceOutline(PluginContext.getQName(groupUse));
			if(referencedInterfaceOutline == null) {
				final String interfaceName = this.pluginContext.outline.getModel().getNameConverter().toClassName(groupUse.getName());
				this.pluginContext.errorHandler.error(new SAXParseException(MessageFormat.format(GroupInterfaceGenerator.RESOURCE_BUNDLE.getString("error.interface-not-found"), groupUse.getName(), interfaceName), groupUse.getLocator()));
			} else {
				classOutline.implClass._implements(coalesce(referencedInterfaceOutline.getSupportInterface(), referencedInterfaceOutline.getImplClass()));
				putGroupInterfaceForClass(classOutline.implClass.fullName(), referencedInterfaceOutline);
			}

		} else {
			classOutline.implClass._implements(coalesce(definedGroupType.getSupportInterface(),definedGroupType.getImplClass()));
			putGroupInterfaceForClass(classOutline.implClass.fullName(), definedGroupType);
		}
	}
}
 
Example #10
Source File: ClassModelBuilder.java    From mxjc with MIT License 6 votes vote down vote up
private static AttributeAnnotation getAttributeAnnotation(ClassOutline parent, CPropertyInfo prop) {
    CAttributePropertyInfo ap = (CAttributePropertyInfo) prop;
    QName attName = ap.getXmlName();
    
    AttributeAnnotation attributeAnnotation = new AttributeAnnotation();
    
    final String generatedName = attName.getLocalPart();
    
    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // generate name property?
    if(!generatedName.equals(ap.getName(false)) || (parent.parent().getModel().getNameConverter() != NameConverter.standard)) {
    	attributeAnnotation.setName(generatedName);
    }
    
    return attributeAnnotation;
}
 
Example #11
Source File: EmbeddableAttributesMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public EmbeddableAttributes process(Mapping context,
		ClassOutline classOutline, Options options) {

	final EmbeddableAttributes attributes = new EmbeddableAttributes();

	final FieldOutline[] fieldOutlines = classOutline.getDeclaredFields();
	for (final FieldOutline fieldOutline : fieldOutlines) {

		final Object attributeMapping = getAttributeMapping(context,
				fieldOutline, options).process(context, fieldOutline,
				options);

		if (attributeMapping instanceof Basic) {
			attributes.getBasic().add((Basic) attributeMapping);
		} else if (attributeMapping instanceof Transient) {
			attributes.getTransient().add((Transient) attributeMapping);
		}
	}
	return attributes;
}
 
Example #12
Source File: EmbeddedAssociationMappingWrapper.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #13
Source File: CopyablePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected JMethod generateCopyTo$createNewInstance(
		final ClassOutline classOutline, final JDefinedClass theClass) {

	final JMethod existingMethod = theClass.getMethod("createNewInstance",
			new JType[0]);
	if (existingMethod == null) {

		final JMethod newMethod = theClass.method(JMod.PUBLIC, theClass
				.owner().ref(Object.class), "createNewInstance");
		newMethod.annotate(Override.class);
		{
			final JBlock body = newMethod.body();
			body._return(JExpr._new(theClass));
		}
		return newMethod;
	} else {
		return existingMethod;
	}
}
 
Example #14
Source File: MarshalMappings.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<ClassOutline> process(EjbPlugin context, Outline outline,
		Options options) throws Exception {
	logger.debug("Processing outline with context path ["
			+ OutlineUtils.getContextPath(outline) + "].");

	final Collection<? extends ClassOutline> classes = outline.getClasses();
	final Collection<ClassOutline> processedClassOutlines = new ArrayList<ClassOutline>(
			classes.size());

	for (final ClassOutline classOutline : classes) {
		if (!getIgnoring()
				.isClassOutlineIgnored(getMapping(), classOutline)) {
			final ClassOutline processedClassOutline = process(this,
					classOutline, options);
			if (processedClassOutline != null) {
				processedClassOutlines.add(processedClassOutline);
			}
		}
	}
	return processedClassOutlines;
}
 
Example #15
Source File: DefinedClassOutline.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
public DefinedClassOutline(final PluginContext pluginContext, final ClassOutline classOutline) {
	this.pluginContext = pluginContext;
	this.classOutline = classOutline;
	final List<DefinedPropertyOutline> properties = new ArrayList<>(classOutline.getDeclaredFields().length);

	for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) {
		properties.add(new DefinedPropertyOutline(fieldOutline));
	}
	this.declaredFields = Collections.unmodifiableList(properties);
	if (this.classOutline.getSuperClass() != null) {
		this.superClass = new DefinedClassOutline(this.pluginContext, this.classOutline.getSuperClass());
	} else {
		try {
			final Class<?> ungeneratedSuperClass = Class.forName(this.classOutline.implClass._extends().fullName());
			if (Object.class.equals(ungeneratedSuperClass)) {
				this.superClass = null;
			} else {
				this.superClass = new ReferencedClassOutline(this.pluginContext.codeModel, ungeneratedSuperClass);
			}
		} catch (final Exception e) {
			throw new RuntimeException("Cannot find superclass of " + this.classOutline.target.getName() + ": " + this.classOutline.target.getLocator());
		}
	}
}
 
Example #16
Source File: EntityMapping.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void createEntity$Inheritance(Mapping context,
		ClassOutline classOutline, final Entity entity) {
	final InheritanceType inheritanceStrategy = getInheritanceStrategy(
			context, classOutline, entity);

	if (isRootClass(context, classOutline)) {
		if (entity.getInheritance() == null
				|| entity.getInheritance().getStrategy() == null) {
			entity.setInheritance(new Inheritance());
			entity.getInheritance().setStrategy(inheritanceStrategy.name());
		}
	} else {
		if (entity.getInheritance() != null
				&& entity.getInheritance().getStrategy() != null) {
			entity.setInheritance(null);
		}
	}
}
 
Example #17
Source File: ClassPersistenceProcessor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<ClassOutline> process(EjbPlugin plugin, Outline outline,
		Options options) throws Exception {

	Collection<ClassOutline> includedClasses = getOutlineProcessor()
			.process(plugin, outline, options);

	final String pun = plugin.getPersistenceUnitName();
	final String persistenceUnitName = pun != null ? pun : getNaming()
			.getPersistenceUnitName(plugin.getMapping(), outline);

	final PersistenceUnit persistenceUnit = getPersistenceUnitFactory()
			.createPersistenceUnit(includedClasses);

	final Persistence persistence = createPersistence(plugin,
			persistenceUnit, persistenceUnitName);

	getPersistenceMarshaller().marshallPersistence(outline.getCodeModel(),
			persistence);

	return includedClasses;
}
 
Example #18
Source File: AddAcceptMethod.java    From jaxb-visitor with Apache License 2.0 6 votes vote down vote up
public void run(Set<ClassOutline> sorted, JDefinedClass visitor) {
        // skip over abstract classes
// add the accept method to the bean
        sorted.stream().filter(classOutline -> !classOutline.target.isAbstract()).forEach(classOutline -> {
            // add the accept method to the bean
            JDefinedClass beanImpl = classOutline.implClass;
            final JMethod acceptMethod = beanImpl.method(JMod.PUBLIC, void.class, "accept");
            final JTypeVar returnType = acceptMethod.generify("R");
            final JTypeVar exceptionType = acceptMethod.generify("E", Throwable.class);
            acceptMethod.type(returnType);
            acceptMethod._throws(exceptionType);
            final JClass narrowedVisitor = visitor.narrow(returnType, exceptionType);
            JVar vizParam = acceptMethod.param(narrowedVisitor, "aVisitor");
            JBlock block = acceptMethod.body();
            String methodName = visitMethodNamer.apply(beanImpl.name());
            block._return(vizParam.invoke(methodName).arg(JExpr._this()));
        });
    }
 
Example #19
Source File: AnnotateOutline.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<ClassOutline> process(EjbPlugin context, Outline outline,
		Options options) throws Exception {
	logger.debug("Processing outline with context path ["
			+ OutlineUtils.getContextPath(outline) + "].");

	final Collection<? extends ClassOutline> classes = outline.getClasses();
	final Collection<ClassOutline> processedClassOutlines = new ArrayList<ClassOutline>(
			classes.size());

	for (final ClassOutline classOutline : classes) {
		if (!getIgnoring()
				.isClassOutlineIgnored(getMapping(), classOutline)) {
			final ClassOutline processedClassOutline = process(this,
					classOutline, options);
			if (processedClassOutline != null) {
				processedClassOutlines.add(processedClassOutline);
			}
		}
	}
	return processedClassOutlines;
}
 
Example #20
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
@Override
public boolean run(final Outline outline, final Options opt, final ErrorHandler errorHandler) throws SAXException {
	final PluginContext pluginContext = PluginContext.get(outline, opt, errorHandler);
	if (this.extended && this.generateTools) {
		pluginContext.writeSourceFile(PropertyInfo.class);
		pluginContext.writeSourceFile(SinglePropertyInfo.class);
		pluginContext.writeSourceFile(CollectionPropertyInfo.class);
		pluginContext.writeSourceFile(IndirectCollectionPropertyInfo.class);
		pluginContext.writeSourceFile(IndirectPrimitiveCollectionPropertyInfo.class);
		pluginContext.writeSourceFile(PropertyVisitor.class);
		pluginContext.writeSourceFile(Property.class);
		pluginContext.writeSourceFile(SingleProperty.class);
		pluginContext.writeSourceFile(CollectionProperty.class);
		pluginContext.writeSourceFile(IndirectCollectionProperty.class);
		pluginContext.writeSourceFile(IndirectPrimitiveCollectionProperty.class);
		pluginContext.writeSourceFile(ItemProperty.class);
	}
	for (final ClassOutline classOutline : outline.getClasses()) {
		generateMetaClass(pluginContext, classOutline, errorHandler);
	}
	return true;
}
 
Example #21
Source File: AnnotateOutline.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void processAttributeWildcard(ClassOutline classOutline) {
	logger.debug("The class ["
			+ OutlineUtils.getClassName(classOutline)
			+ "] declares an attribute wildcard which will be made transient.");
	String FIELD_NAME = "otherAttributes";
	String METHOD_SEED = classOutline.parent().getModel()
			.getNameConverter().toClassName(FIELD_NAME);

	final JMethod getOtherAttributesMethod = classOutline.ref.getMethod(
			"get" + METHOD_SEED, new JType[0]);

	if (getOtherAttributesMethod == null) {
		logger.error("Could not find the attribute wildcard method in the class ["
				+ OutlineUtils.getClassName(classOutline) + "].");
	} else {
		getOtherAttributesMethod.annotate(Transient.class);
	}
}
 
Example #22
Source File: MappingFilePersistenceProcessor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Collection<ClassOutline> process(EjbPlugin plugin, Outline outline,
		Options options) throws Exception {

	Collection<ClassOutline> includedClasses = getOutlineProcessor()
			.process(plugin, outline, options);

	final String pun = plugin.getPersistenceUnitName();
	final String persistenceUnitName = pun != null ? pun : getNaming()
			.getPersistenceUnitName(plugin.getMapping(), outline);

	final PersistenceUnit persistenceUnit = getPersistenceUnitFactory()
			.createPersistenceUnit(includedClasses);

	final Persistence persistence = createPersistence(plugin,
			persistenceUnit, persistenceUnitName);

	getPersistenceMarshaller().marshallPersistence(outline.getCodeModel(),
			persistence);

	// TODO Auto-generated method stub
	return includedClasses;
}
 
Example #23
Source File: SelectorGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
MetaInfoOutline(final SelectorGenerator selectorGenerator, final ClassOutline classOutline, final JDefinedClass selectorClass, final JTypeVar rootTypeParam, final JTypeVar parentTypeParam, final JMethod buildChildrenMethod, final JVar productMapVar) {
	this.selectorGenerator = selectorGenerator;
	this.classOutline = classOutline;
	this.selectorClass = selectorClass;
	this.rootTypeParam = rootTypeParam;
	this.parentTypeParam = parentTypeParam;
	this.buildChildrenMethod = buildChildrenMethod;
	this.buildChildrenMethod.body().add(productMapVar.invoke("putAll").arg(JExpr._super().invoke(buildChildrenMethod)));
	this.productMapVar = productMapVar;
}
 
Example #24
Source File: ClassModelBuilder.java    From mxjc with MIT License 5 votes vote down vote up
private static ElementAnnotation getElementAnnotation(ClassOutline parent, CPropertyInfo prop, CTypeRef ctype) {
	ElementAnnotation elementAnnotation = null;
	
    String propName = prop.getName(false);
    
    // generate the name property?
    String generatedName = ctype.getTagName().getLocalPart();
    if(!generatedName.equals(propName)) {
    	elementAnnotation = new ElementAnnotation();
    	elementAnnotation.setName(generatedName);
    }
	
	return elementAnnotation;
}
 
Example #25
Source File: ClassUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #26
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
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 #27
Source File: HashCodePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void processClassOutline(ClassOutline classOutline) {
	final JDefinedClass theClass = classOutline.implClass;
	ClassUtils._implements(theClass, theClass.owner().ref(HashCode2.class));

	@SuppressWarnings("unused")
	final JMethod hashCode$hashCode = generateHashCode$hashCode(
			classOutline, theClass);
	@SuppressWarnings("unused")
	final JMethod object$hashCode = generateObject$hashCode(classOutline,
			theClass);
}
 
Example #28
Source File: CopyablePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected JMethod generateObject$clone(final ClassOutline classOutline,
		final JDefinedClass theClass) {

	final JMethod clone = theClass.method(JMod.PUBLIC, theClass.owner()
			.ref(Object.class), "clone");
	clone.annotate(Override.class);
	{
		final JBlock body = clone.body();
		body._return(JExpr.invoke("copyTo").arg(
				JExpr.invoke("createNewInstance")));
	}
	return clone;
}
 
Example #29
Source File: ClassPersistenceUnitFactory.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PersistenceUnit createPersistenceUnit(
		final Collection<ClassOutline> includedClasses) {
	final PersistenceUnit persistenceUnit = new PersistenceUnit();
	for (final ClassOutline classOutline : includedClasses) {
		persistenceUnit.getClazz().add(
				OutlineUtils.getClassName(classOutline));
	}
	return persistenceUnit;

}
 
Example #30
Source File: CustomizedIgnoring.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isIgnored(ClassOutline classOutline) {
	for (QName name : getIgnoredCustomizationElementNames()) {
		if (CustomizationUtils.containsCustomization(classOutline, name)) {
			return true;
		}
	}
	return false;
}