private boolean extendsParcelable(final JDefinedClass jclass) { final java.util.Iterator<JClass> interfaces = jclass._extends() != null ? jclass._extends()._implements() : null; if (interfaces != null) { while (interfaces.hasNext()) { final JClass iface = interfaces.next(); if (iface.erasure().name().equals("Parcelable")) { return true; } } } return false; }
private void addSetProperty(JDefinedClass jclass, JBlock callSite, String propertyName, JType propertyType, JVar valueVar, JsonNode node) { JMethod propertySetter = jclass.getMethod(getSetterName(propertyName, node), new JType[] { propertyType }); JConditional isInstance = callSite._if(valueVar._instanceof(propertyType.boxify().erasure())); isInstance._then() .invoke(propertySetter).arg(cast(propertyType.boxify(), valueVar)); isInstance._else() ._throw(illegalArgumentInvocation(jclass, propertyName, propertyType, valueVar)); }
/** * Returns true if this class is a parameterized class. */ public final boolean isParameterized() { return erasure()!=this; }
/** * Returns true if this class is a parameterized class. */ public final boolean isParameterized() { return erasure()!=this; }
/** * Returns true if this class is a parameterized class. */ public final boolean isParameterized() { return erasure()!=this; }
/** * Returns true if this class is a parameterized class. */ public final boolean isParameterized() { return erasure()!=this; }
/** * Returns true if this class is a parameterized class. */ public final boolean isParameterized() { return erasure()!=this; }
private boolean isList(JType type) { boolean isList = false; if (type instanceof JClass) { isList = CLASS_MAP.get(List.class).equals(((JClass) type).erasure()); } return isList; }
private boolean extendsParcelable(final JDefinedClass jclass) { final java.util.Iterator<JClass> interfaces = jclass._extends() != null ? jclass._extends()._implements() : null; if (interfaces != null) { while (interfaces.hasNext()) { final JClass iface = interfaces.next(); if (iface.erasure().name().equals("Parcelable")) { return true; } } } return false; }
/** * 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; // 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); }
/** * 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; // 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); }
@Override public List<JMethod> apply(JClass clazz, JClass superClazz){ String parameterName = NameConverter.standard.toVariableName((clazz.erasure()).name()); if(!JJavaName.isJavaIdentifier(parameterName)){ parameterName = ("_" + parameterName); } JMethod visitorVisit = visitorInterface.method(JMod.PUBLIC, visitorActionEnum, "visit"); visitorVisit.param(clazz, parameterName); JMethod abstractVisitorVisit = abstractVisitorClazz.method(JMod.PUBLIC, visitorActionEnum, "visit"); abstractVisitorVisit.annotate(Override.class); abstractVisitorVisit.param(clazz, parameterName); abstractVisitorVisit.body()._return(JExpr.invoke("visit").arg(JExpr.cast(superClazz.erasure(), JExpr.ref(parameterName)))); return Arrays.asList(visitorVisit, abstractVisitorVisit); } };
/** * Wraps a type value into a {@link JAXBElement}. */ protected final JInvocation createJAXBElement(JExpression $var) { JCodeModel cm = codeModel(); return JExpr._new(cm.ref(JAXBElement.class)) .arg(JExpr._new(cm.ref(QName.class)) .arg(ei.getElementName().getNamespaceURI()) .arg(ei.getElementName().getLocalPart())) .arg(getRawType().boxify().erasure().dotclass()) .arg($var); } }
/** * Wraps a type value into a {@link JAXBElement}. */ protected final JInvocation createJAXBElement(JExpression $var) { JCodeModel cm = codeModel(); return JExpr._new(cm.ref(JAXBElement.class)) .arg(JExpr._new(cm.ref(QName.class)) .arg(ei.getElementName().getNamespaceURI()) .arg(ei.getElementName().getLocalPart())) .arg(getRawType().boxify().erasure().dotclass()) .arg($var); } }
/** * Wraps a type value into a {@link JAXBElement}. */ protected final JInvocation createJAXBElement(JExpression $var) { JCodeModel cm = codeModel(); return JExpr._new(cm.ref(JAXBElement.class)) .arg(JExpr._new(cm.ref(QName.class)) .arg(ei.getElementName().getNamespaceURI()) .arg(ei.getElementName().getLocalPart())) .arg(getRawType().boxify().erasure().dotclass()) .arg($var); } }
/** * Wraps a type value into a {@link JAXBElement}. */ protected final JInvocation createJAXBElement(JExpression $var) { JCodeModel cm = codeModel(); return JExpr._new(cm.ref(JAXBElement.class)) .arg(JExpr._new(cm.ref(QName.class)) .arg(ei.getElementName().getNamespaceURI()) .arg(ei.getElementName().getLocalPart())) .arg(getRawType().boxify().erasure().dotclass()) .arg($var); } }
/** * Wraps a type value into a {@link JAXBElement}. */ protected final JInvocation createJAXBElement(JExpression $var) { JCodeModel cm = codeModel(); return JExpr._new(cm.ref(JAXBElement.class)) .arg(JExpr._new(cm.ref(QName.class)) .arg(ei.getElementName().getNamespaceURI()) .arg(ei.getElementName().getLocalPart())) .arg(getRawType().boxify().erasure().dotclass()) .arg($var); } }
private void addSetProperty(JDefinedClass jclass, JBlock callSite, String propertyName, JType propertyType, JVar valueVar, JsonNode node) { JMethod propertySetter = jclass.getMethod(getSetterName(propertyName, node), new JType[] { propertyType }); JConditional isInstance = callSite._if(valueVar._instanceof(propertyType.boxify().erasure())); isInstance._then() .invoke(propertySetter).arg(cast(propertyType.boxify(), valueVar)); isInstance._else() ._throw(illegalArgumentInvocation(jclass, propertyName, propertyType, valueVar)); }