gatherTypes(t.getErasedType(), types); for (String s : prop.getValues()) { JClassType type = typeOracle.findType(s); if (type != null) gatherTypes(type.getErasedType(), types); gatherTypes(typeOracle.findType("java.util.List").getErasedType(), types); gatherTypes(typeOracle.findType("java.util.ArrayList").getErasedType(), types); gatherTypes(typeOracle.findType("java.util.HashMap").getErasedType(), types); gatherTypes(typeOracle.findType("java.util.Map").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.String").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Boolean").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Byte").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Long").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Character").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Short").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Integer").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Float").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.CharSequence").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Double").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Object").getErasedType(), types);
gatherTypes(t.getErasedType(), types); for (String s : prop.getValues()) { JClassType type = typeOracle.findType(s); if (type != null) gatherTypes(type.getErasedType(), types); gatherTypes(typeOracle.findType("java.util.List").getErasedType(), types); gatherTypes(typeOracle.findType("java.util.ArrayList").getErasedType(), types); gatherTypes(typeOracle.findType("java.util.HashMap").getErasedType(), types); gatherTypes(typeOracle.findType("java.util.Map").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.String").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Boolean").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Byte").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Long").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Character").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Short").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Integer").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Float").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.CharSequence").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Double").getErasedType(), types); gatherTypes(typeOracle.findType("java.lang.Object").getErasedType(), types);
if (interfaces != null) { for (JClassType i : interfaces) { gatherTypes(i.getErasedType(), types); if (inner != null) { for (JClassType i : inner) { gatherTypes(i.getErasedType(), types);
if (interfaces != null) { for (JClassType i : interfaces) { gatherTypes(i.getErasedType(), types); if (inner != null) { for (JClassType i : inner) { gatherTypes(i.getErasedType(), types);
String superClass = null; if (c != null && (isVisible(c.getSuperclass()))) superClass = c.getSuperclass().getErasedType().getQualifiedSourceName() + ".class"; String assignables = null; String interfaces = null; pb(varName + ".enumConstants = new Object[" + enumConstants.length + "];"); for (int i = 0; i < enumConstants.length; i++) { pb(varName + ".enumConstants[" + i + "] = " + c.getErasedType().getQualifiedSourceName() + "." + enumConstants[i].getName() + ";");
String superClass = null; if (c != null && (isVisible(c.getSuperclass()))) superClass = c.getSuperclass().getErasedType().getQualifiedSourceName() + ".class"; String assignables = null; String interfaces = null; pb(varName + ".enumConstants = new Object[" + enumConstants.length + "];"); for (int i = 0; i < enumConstants.length; i++) { pb(varName + ".enumConstants[" + i + "] = " + c.getErasedType().getQualifiedSourceName() + "." + enumConstants[i].getName() + ";");
private JClassType eraseType(JClassType classType) { return classType == null ? null : classType.getErasedType(); }
/** * Returns <code>true</code> if the type directly implements the specified * interface. The test is done on erased types; any paramaterizations supplied * in the arguments are ignored. * * @param type type to check * @param intf interface to look for * @return <code>true</code> if the type directly implements the specified * interface */ public static boolean directlyImplementsInterface(JClassType type, JClassType intf) { type = type.getErasedType(); intf = intf.getErasedType(); return directlyImplementsInterfaceRecursive(new HashSet<JClassType>(), type, intf); }
/** * Returns <code>true</code> if the type directly implements the specified * interface. The test is done on erased types; any paramaterizations supplied * in the arguments are ignored. * * @param type type to check * @param intf interface to look for * @return <code>true</code> if the type directly implements the specified * interface */ public static boolean directlyImplementsInterface(JClassType type, JClassType intf) { type = type.getErasedType(); intf = intf.getErasedType(); return directlyImplementsInterfaceRecursive(new HashSet<JClassType>(), type, intf); }
protected String toClass(JClassType param) { return param.getErasedType().getQualifiedSourceName()+".class"; }
/** * Returns all types on the path from the root type to the serializable * leaves. * * @param root the root type * @param leaves the set of serializable leaf types * @return all types on the path from the root type to the serializable leaves */ public static List<JClassType> getAllTypesBetweenRootTypeAndLeaves(JClassType root, Collection<JClassType> leaves) { Map<JClassType, List<JClassType>> adjList = getInvertedTypeHierarchy(root.getErasedType()); Set<JClassType> types = new HashSet<JClassType>(); for (JClassType type : leaves) { depthFirstSearch(types, adjList, type.getErasedType()); } return Arrays.asList(types.toArray(new JClassType[0])); }
/** * Returns all types on the path from the root type to the serializable * leaves. * * @param root the root type * @param leaves the set of serializable leaf types * @return all types on the path from the root type to the serializable leaves */ public static List<JClassType> getAllTypesBetweenRootTypeAndLeaves(JClassType root, Collection<JClassType> leaves) { Map<JClassType, List<JClassType>> adjList = getInvertedTypeHierarchy(root.getErasedType()); Set<JClassType> types = new HashSet<JClassType>(); for (JClassType type : leaves) { depthFirstSearch(types, adjList, type.getErasedType()); } return Arrays.asList(types.toArray(new JClassType[0])); }
private void createResourceUiRenderer(XMLElement elem, String resourceName, JClassType resourceType, JClassType matchingResourceType) throws UnableToCompleteException { FieldWriter fieldWriter; if (resourceType != null && !resourceType.getErasedType().isAssignableFrom(matchingResourceType.getErasedType())) { writer.die(elem, "Type must match the type of parameter %s in %s#render method.", resourceName, writer.getBaseClass().getQualifiedSourceName()); } fieldWriter = fieldManager.registerField( FieldWriterType.IMPORTED, matchingResourceType.getErasedType(), resourceName); // Sets initialization as a NOOP. These fields are set from // parameters passed to UiRenderer#render(), instead. fieldWriter.setInitializer(resourceName); }
private void createResourceUiRenderer(XMLElement elem, String resourceName, JClassType resourceType, JClassType matchingResourceType) throws UnableToCompleteException { FieldWriter fieldWriter; if (resourceType != null && !resourceType.getErasedType().isAssignableFrom(matchingResourceType.getErasedType())) { writer.die(elem, "Type must match the type of parameter %s in %s#render method.", resourceName, writer.getBaseClass().getQualifiedSourceName()); } fieldWriter = fieldManager.registerField( FieldWriterType.IMPORTED, matchingResourceType.getErasedType(), resourceName); // Sets initialization as a NOOP. These fields are set from // parameters passed to UiRenderer#render(), instead. fieldWriter.setInitializer(resourceName); }
/** * Creates a BeanHelper and writes an interface containing its instance. Also, recursively creates * any BeanHelpers on its constrained properties. */ BeanHelper createHelper(final JClassType pjtype, final TreeLogger plogger, final GeneratorContext pcontext) throws UnableToCompleteException { final JClassType erasedType = pjtype.getErasedType(); try { final Class<?> clazz = Class.forName(erasedType.getQualifiedBinaryName()); return doCreateHelper(clazz, erasedType, plogger, pcontext); } catch (final ClassNotFoundException e) { plogger.log(TreeLogger.ERROR, "Unable to create BeanHelper for " + erasedType, e); throw new UnableToCompleteException(); // NOPMD } }
/** * Creates a BeanHelper and writes an interface containing its instance. Also, * recursively creates any BeanHelpers on its constrained properties. */ BeanHelper createHelper(JClassType jType, TreeLogger logger, GeneratorContext context) throws UnableToCompleteException { JClassType erasedType = jType.getErasedType(); try { Class<?> clazz = Class.forName(erasedType.getQualifiedBinaryName()); return doCreateHelper(clazz, erasedType, logger, context); } catch (ClassNotFoundException e) { logger.log(TreeLogger.ERROR, "Unable to create BeanHelper for " + erasedType, e); throw new UnableToCompleteException(); } }
/** * Creates a BeanHelper and writes an interface containing its instance. Also, * recursively creates any BeanHelpers on its constrained properties. */ BeanHelper createHelper(JClassType jType, TreeLogger logger, GeneratorContext context) throws UnableToCompleteException { JClassType erasedType = jType.getErasedType(); try { Class<?> clazz = Class.forName(erasedType.getQualifiedBinaryName()); return doCreateHelper(clazz, erasedType, logger, context); } catch (ClassNotFoundException e) { logger.log(TreeLogger.ERROR, "Unable to create BeanHelper for " + erasedType, e); throw new UnableToCompleteException(); } }
private JClassType getMethodRoot(final JMethod method) { JClassType winner = method.getEnclosingType(); if (winner.isInterface() != null) { for (final JClassType type : winner.getImplementedInterfaces()) { if (type.findMethod(method.getName(), EMPTY_PARAMS) != null) { if (type.isAssignableFrom(winner)) { winner = type; } } } } return winner.getErasedType(); }
private void createResourceUiField(String resourceName, OwnerField ownerField) throws UnableToCompleteException { FieldWriter fieldWriter; String initializer; if (writer.getDesignTime().isDesignTime()) { String typeName = ownerField.getType().getRawType().getQualifiedSourceName(); initializer = writer.getDesignTime().getProvidedField(typeName, ownerField.getName()); } else { initializer = "owner." + ownerField.getName(); } fieldWriter = fieldManager.registerField( FieldWriterType.IMPORTED, ownerField.getType().getRawType().getErasedType(), resourceName); fieldWriter.setInitializer(initializer); }
private void createResourceUiField(String resourceName, OwnerField ownerField) throws UnableToCompleteException { FieldWriter fieldWriter; String initializer; if (writer.getDesignTime().isDesignTime()) { String typeName = ownerField.getType().getRawType().getQualifiedSourceName(); initializer = writer.getDesignTime().getProvidedField(typeName, ownerField.getName()); } else { initializer = "owner." + ownerField.getName(); } fieldWriter = fieldManager.registerField( FieldWriterType.IMPORTED, ownerField.getType().getRawType().getErasedType(), resourceName); fieldWriter.setInitializer(initializer); }