Java Code Examples for com.sun.codemodel.JClass#_extends
The following examples show how to use
com.sun.codemodel.JClass#_extends .
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: PojoBuilder.java From springmvc-raml-plugin with Apache License 2.0 | 6 votes |
private JFieldVar parentContainsField(JClass pojo, String name) { if (pojo != null && !pojo.fullName().equals(Object.class.getName())) { JClass parent = pojo._extends(); if (parent != null) { // Our parent has a parent, lets check if it has it JFieldVar parentField = parentContainsField(parent, name); if (parentField != null) { return parentField; } else { if (parent instanceof JDefinedClass) { return ((JDefinedClass) parent).fields().get(name); } } } } return null; }
Example 2
Source File: PojoBuilder.java From springmvc-raml-plugin with Apache License 2.0 | 6 votes |
private Map<String, JVar> getSuperParametersToAdd(JClass pojo) { Map<String, JVar> tFields = new LinkedHashMap<>(); JClass parent = pojo._extends(); if (!parent.name().equals(Object.class.getSimpleName())) { parent = CodeModelHelper.findFirstClassBySimpleName(this.pojoModel, parent.name()); if (parent instanceof JDefinedClass) { JDefinedClass jParent = (JDefinedClass) parent; JMethod constructor = null; Iterator<JMethod> constructors = jParent.constructors(); while (constructors.hasNext()) { JMethod targetConstructor = constructors.next(); if (constructor == null || constructor.params().size() < targetConstructor.params().size()) { constructor = targetConstructor; } } for (JVar var : constructor.params()) { tFields.put(var.name(), var); } } } return tFields; }
Example 3
Source File: JClassUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
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 4
Source File: TypeUtil.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
/** * Returns the set of all classes/interfaces that a given type * implements/extends, including itself. * * For example, if you pass java.io.FilterInputStream, then the returned * set will contain java.lang.Object, java.lang.InputStream, and * java.lang.FilterInputStream. */ private static void getAssignableTypes( JClass t, Set<JClass> s ) { if(!s.add(t)) return; // TODO // if (t.fullName().equals(Equals.class.getName()) || // t.fullName().equals(HashCode.class.getName()) || // t.fullName().equals(ToString.class.getName()) || // t.fullName().equals(CopyTo.class.getName()) // ) // add its raw type s.add(t.erasure()); // if this type is added for the first time, // recursively process the super class. JClass _super = t._extends(); if(_super!=null) getAssignableTypes(_super,s); // recursively process all implemented interfaces Iterator<JClass> itr = t._implements(); while(itr.hasNext()) { getAssignableTypes(itr.next(),s); } }
Example 5
Source File: PluginImpl.java From immutable-xjc with MIT License | 5 votes |
private List<JDefinedClass> getSuperClasses(JClass clazz) { // first get all superclasses List<JDefinedClass> superclasses = new ArrayList<>(); JClass superclass = clazz._extends(); while (superclass != null) { if (superclass instanceof JDefinedClass) { superclasses.add((JDefinedClass) superclass); } superclass = superclass._extends(); } return superclasses; }