/** * Indicates if this <code>JavaClass</code> is either the same as, or is a superclass of, * the <code>javaClass</code> argument. * * @param javaClass the <code>Class</code> to test. * * @return <code>true</code> if this <code>JavaClass</code> is assignable from * <code>javaClass</code>, otherwise <code>false</code>. * * @see java.lang.Class#isAssignableFrom(Class) */ public boolean isAssignableFrom(JavaClass javaClass) { if (javaClass == null) { return false; } XJCJavaClassImpl javaClassImpl = (XJCJavaClassImpl) javaClass; JClass someClass = javaClassImpl.xjcClass; return xjcClass.isAssignableFrom(someClass); }
/** * Remove method {@code ObjectFactory} that creates an object of a given {@code clazz}. * * @return {@code 1} if such method was successfully located and removed */ private int deleteFactoryMethod(JDefinedClass factoryClass, Candidate candidate) { int deletedMethods = 0; for (Iterator<JMethod> iter = factoryClass.methods().iterator(); iter.hasNext();) { JMethod method = iter.next(); // Remove the methods: // * public T createT() { return new T(); } // * public JAXBElement<T> createT(T value) { return new JAXBElement<T>(QNAME, T.class, null, value); } // * @XmlElementDecl(..., scope = X.class) // public JAXBElement<T> createT...(T value) { return new JAXBElement<...>(QNAME, T.class, X.class, value); } if ((method.type() instanceof JDefinedClass && ((JDefinedClass) method.type()).isAssignableFrom(candidate.getClazz())) || isListedAsParametrisation(candidate.getClazz(), method.type()) || candidate.getScopedElementInfos().containsKey(method.name())) { writeSummary("\tRemoving factory method [" + method.type().fullName() + "#" + method.name() + "()] from " + factoryClass.fullName()); iter.remove(); deletedMethods++; } } return deletedMethods; }
/** * Remove method {@code ObjectFactory} that creates an object of a given {@code clazz}. * * @return {@code 1} if such method was successfully located and removed */ private int deleteFactoryMethod(JDefinedClass factoryClass, Candidate candidate) { int deletedMethods = 0; for (Iterator<JMethod> iter = factoryClass.methods().iterator(); iter.hasNext();) { JMethod method = iter.next(); // Remove the methods: // * public T createT() { return new T(); } // * public JAXBElement<T> createT(T value) { return new JAXBElement<T>(QNAME, T.class, null, value); } // * @XmlElementDecl(..., scope = X.class) // public JAXBElement<T> createT...(T value) { return new JAXBElement<...>(QNAME, T.class, X.class, value); } if ((method.type() instanceof JDefinedClass && ((JDefinedClass) method.type()).isAssignableFrom(candidate.getClazz())) || isListedAsParametrisation(candidate.getClazz(), method.type()) || candidate.getScopedElementInfos().containsKey(method.name())) { writeSummary("\tRemoving factory method [" + method.type().fullName() + "#" + method.name() + "()] from " + factoryClass.fullName()); iter.remove(); deletedMethods++; } } return deletedMethods; }