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

The following examples show how to use com.sun.tools.xjc.outline.EnumOutline. 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: CMEnumConstantOutlineGenerator.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public MEnumConstantOutline generate(MEnumOutline parent,
		MModelInfo<NType, NClass> modelInfo,
		MEnumConstantInfo<NType, NClass> enumConstantInfo) {

	final CEnumLeafInfo eli = enumConstant.getEnclosingClass();

	final EnumOutline enumOutline = outline.getEnum(eli);

	for (EnumConstantOutline enumConstantOutline : enumOutline.constants) {
		if (enumConstantOutline.target == enumConstant) {
			return new CMEnumConstantOutline(parent, enumConstantInfo,
					enumConstantOutline.constRef);
		}
	}
	return null;
}
 
Example #2
Source File: CMEnumOutlineGenerator.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public MEnumOutline generate(MPackageOutline parent,
		MModelInfo<NType, NClass> modelInfo,
		MEnumLeafInfo<NType, NClass> enumLeafInfo) {
	final EnumOutline eo = outline.getEnum(this.enumLeafInfo);

	final CMEnumOutline enumOutline = new CMEnumOutline(parent.getParent(),
			parent, enumLeafInfo, eo.clazz);

	for (MEnumConstantInfo<NType, NClass> enumConstantInfo : enumLeafInfo
			.getConstants()) {

		if (enumConstantInfo.getOrigin() instanceof EnumConstantOutlineGeneratorFactory) {
			final MEnumConstantOutlineGenerator generator = ((EnumConstantOutlineGeneratorFactory) enumConstantInfo
					.getOrigin()).createGenerator(outline);
			final MEnumConstantOutline enumConstantOutline = generator
					.generate(enumOutline, modelInfo, enumConstantInfo);
			if (enumConstantOutline != null) {
				enumOutline.addEnumConstantOutline(enumConstantOutline);
			}
		}
	}
	return enumOutline;
}
 
Example #3
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 #4
Source File: EnumModelBuilder.java    From mxjc with MIT License 5 votes vote down vote up
public static void buildEnumModel(Outline outline, CGModel cgModel, ErrorReceiver errorReceiver) {
for (EnumOutline eo : outline.getEnums()) {
	EnumInfo enumInfo = new EnumInfo();
	enumInfo.setPackageName(eo._package()._package().name());
	enumInfo.setName(eo.clazz.name());
	if (!StringUtil.isEmpty(enumInfo.getPackageName())) {
		enumInfo.setFullName(enumInfo.getPackageName() + "." + enumInfo.getName());
	} else {
		enumInfo.setFullName(enumInfo.getName());
	}
	
	// enum constant
	for (EnumConstantOutline eco : eo.constants) {
		EnumConstantInfo enumConstant = new EnumConstantInfo();
		// name of this enum constant
		enumConstant.setName(eco.target.getName());
		// value of this enum constant
		enumConstant.setValue(eco.target.getLexicalValue());
		// java doc on this enum constant
		enumConstant.setDocComment(eco.target.javadoc);

		// add this enum constant in the enum model
		enumInfo.getEnumConstants().add(enumConstant);
	}

	// xsd annotation as doc comment
	String docComment = ModelBuilder.getDocumentation(eo.target
			.getSchemaComponent());
	enumInfo.setDocComment(docComment);

	// add this enum in the codegen model
	cgModel.getEnums().add(enumInfo);
}
  }
 
Example #5
Source File: EnumValuePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void processEnumOutline(EnumOutline enumOutline) {
	CEnumLeafInfo enumLeafInfo = enumOutline.target;
	JClass enumType = enumLeafInfo.base.toType(enumOutline.parent(),
			Aspect.EXPOSED).boxify();

	final JDefinedClass theClass = enumOutline.clazz;

	ClassUtils._implements(theClass, theClass.owner().ref(EnumValue.class)
			.narrow(enumType));

	final JMethod enumValue$enumValue = theClass.method(JMod.PUBLIC,
			enumType, "enumValue");
	enumValue$enumValue.annotate(Override.class);
	enumValue$enumValue.body()._return(JExpr._this().invoke("value"));
}
 
Example #6
Source File: EnumValuePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
	for (final EnumOutline enumOutline : outline.getEnums()) {
		if (!getIgnoring().isIgnored(enumOutline)) {
			processEnumOutline(enumOutline);
		}
	}
	return true;
}
 
Example #7
Source File: CustomizedIgnoring.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean isIgnored(EnumOutline enumOutline) {
	for (QName name : getIgnoredCustomizationElementNames()) {
		if (CustomizationUtils.containsCustomization(enumOutline, name)) {
			return true;
		}
	}
	return false;
}
 
Example #8
Source File: InheritancePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private List<JClass> generateImplements(EnumOutline enumOutline,
		Map<String, JClass> knownClasses) {
	final JDefinedClass theClass = enumOutline.clazz;
	final List<CPluginCustomization> implementsInterfaceCustomizations = CustomizationUtils
			.findCustomizations(enumOutline,
					Customizations.IMPLEMENTS_ELEMENT_NAME);
	return generateImplements(theClass, implementsInterfaceCustomizations,
			knownClasses);
}
 
Example #9
Source File: InheritancePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private JClass generateExtends(EnumOutline enumOutline,
		Map<String, JClass> knownClasses) {
	final JDefinedClass theClass = enumOutline.clazz;
	final CPluginCustomization extendsClassCustomization = CustomizationUtils
			.findCustomization(enumOutline,
					Customizations.EXTENDS_ELEMENT_NAME);
	return generateExtends(theClass, extendsClassCustomization,
			knownClasses);
}
 
Example #10
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static CPluginCustomization findCustomization(EnumOutline classOutline, QName name) {
	final CCustomizations customizations = CustomizationUtils.getCustomizations(classOutline);
	final CPluginCustomization customization = customizations.find(name.getNamespaceURI(), name.getLocalPart());
	if (customization != null) {
		customization.markAsAcknowledged();
	}
	return customization;
}
 
Example #11
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static boolean containsCustomization(EnumOutline enumOutline, QName name) {
	final CPluginCustomization customization = findCustomization(enumOutline, name);
	if (customization != null) {
		customization.markAsAcknowledged();
	}
	return customization != null;
}
 
Example #12
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static CCustomizations getCustomizations(EnumOutline enumOutline) {
	return getCustomizations(enumOutline.target);
}
 
Example #13
Source File: CustomizationUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static List<CPluginCustomization> findCustomizations(EnumOutline enumOutline, QName name) {
	return findCustomizations(enumOutline.target, name);
}
 
Example #14
Source File: PluginContext.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
EnumOutline getEnumOutline(final JType typeSpec) {
	return this.enums.get(typeSpec.fullName());
}
 
Example #15
Source File: EpisodeBuilder.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
public EpisodeBuilder addEnum(final EnumOutline enumOutline) {
	this.outlines.add(new OutlineAdaptor(enumOutline.target.getSchemaComponent(), OutlineAdaptor.OutlineType.ENUM, enumOutline.clazz));
	return this;
}
 
Example #16
Source File: AnnotatePlugin.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 4 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;

		CPluginCustomization classCustomization = CustomizationUtils.findCustomization(classOutline, AnnotatePlugin.ANNOTATE_CLASS_QNAME);
		if(classCustomization != null){
			annotate(codeModel, beanClazz, classCustomization);
		}

		Map<String, JFieldVar> fieldVars = beanClazz.fields();

		FieldOutline[] fieldOutlines = classOutline.getDeclaredFields();
		for(FieldOutline fieldOutline : fieldOutlines){
			CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo();

			List<CPluginCustomization> propertyCustomizations = CustomizationUtils.findPropertyCustomizationsInProperty(propertyInfo, AnnotatePlugin.ANNOTATE_PROPERTY_QNAME);
			for(CPluginCustomization propertyCustomization : propertyCustomizations){
				JFieldVar fieldVar = fieldVars.get(propertyInfo.getName(false));

				annotate(codeModel, fieldVar, propertyCustomization);
			}
		}
	}

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

		CPluginCustomization enumCustomization = CustomizationUtils.findCustomization(enumOutline, AnnotatePlugin.ANNOTATE_ENUM_QNAME);
		if(enumCustomization != null){
			annotate(codeModel, clazz, enumCustomization);
		}

		List<EnumConstantOutline> enumConstantOutlines = enumOutline.constants;
		for(EnumConstantOutline enumConstantOutline : enumConstantOutlines){
			CCustomizations enumConstantCustomizations = enumConstantOutline.target.getCustomizations();

			for(CPluginCustomization enumConstantCustomization : enumConstantCustomizations){
				Element element = enumConstantCustomization.element;

				if((AnnotatePlugin.ANNOTATE_ENUM_CONSTANT_QNAME.getNamespaceURI()).equals(element.getNamespaceURI()) && (AnnotatePlugin.ANNOTATE_ENUM_CONSTANT_QNAME.getLocalPart()).equals(element.getLocalName())){
					annotate(codeModel, enumConstantOutline.constRef, enumConstantCustomization);

					enumConstantCustomization.markAsAcknowledged();
				}
			}
		}
	}

	return true;
}
 
Example #17
Source File: InheritancePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 3 votes vote down vote up
private void processEnumOutline(EnumOutline enumOutline,
		Map<String, JClass> knownClasses) {

	generateExtends(enumOutline, knownClasses);
	generateImplements(enumOutline, knownClasses);

}
 
Example #18
Source File: Ignoring.java    From jaxb2-basics with BSD 2-Clause "Simplified" License votes vote down vote up
public boolean isIgnored(EnumOutline enumOutline);