Java Code Examples for com.sun.codemodel.JClass#fullName()

The following examples show how to use com.sun.codemodel.JClass#fullName() . 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: JClassUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T> boolean isInstanceOf(JClass _class,
		Class<? extends T> _interface) {
	Validate.notNull(_class);
	Validate.notNull(_interface);

	final String className = _class.fullName();

	try {
		if (_interface.isAssignableFrom(Class.forName(className))) {
			return true;
		}
	} catch (ClassNotFoundException cnfex) {
		// Unknown
	}

	final JClass superClass = _class._extends();
	if (superClass != null) {
		if (isInstanceOf(superClass, _interface)) {
			return true;
		}
	}

	for (final Iterator<? extends JClass> implementsIterator = _class
			._implements(); implementsIterator.hasNext();) {
		final JClass superInterface = implementsIterator.next();

		if (isInstanceOf(superInterface, _interface)) {
			return true;
		}
	}

	return false;
}
 
Example 2
Source File: InheritancePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private JClass generateExtends(ClassOutline classOutline,
		Map<String, JClass> knownClasses,
		Map<JClass, CClassInfo> knownClassInfos) {
	final JDefinedClass theClass = classOutline.implClass;
	final CPluginCustomization extendsClassCustomization = CustomizationUtils
			.findCustomization(classOutline,
					Customizations.EXTENDS_ELEMENT_NAME);
	JClass targetClass = generateExtends(theClass,
			extendsClassCustomization, knownClasses);

	final CClassInfo classInfo = classOutline.target;
	if (targetClass != null && classInfo.getBaseClass() == null
			&& classInfo.getRefBaseClass() == null) {
		final CClassInfo targetClassInfo = knownClassInfos.get(targetClass);
		if (targetClassInfo == null && classInfo.getRefBaseClass() == null) {
			final Model model = classInfo.model;
			// BIEnum as BIClass is protected too much
			final BIEnum decl = new BIEnum();
			decl.ref = targetClass.fullName();
			final CClassRef baseClass = new CClassRef(model,
					classInfo.getSchemaComponent(), decl,
					new CCustomizations());
			classInfo.setBaseClass(baseClass);
		} else if (targetClassInfo != null
				&& classInfo.getBaseClass() == null) {
			classInfo.setBaseClass(targetClassInfo);
		}
	}
	return targetClass;
}
 
Example 3
Source File: CodeModelUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static String getClassName(final JClass theClass) {
	return (theClass.outer() == null ? theClass.fullName()
			: getClassName(theClass.outer()) + "$" + theClass.name());
}
 
Example 4
Source File: CodeModelUtils.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static String getPackagedClassName(final JClass theClass) {
	return (theClass.outer() == null ? theClass.fullName()
			: getPackagedClassName(theClass.outer()) + "$"
					+ theClass.name());
}