createTypeInvokables(c, varName, "Constructor", c.getConstructors()); } else { logger.log(Type.INFO, c.getName() + " can't be instantiated. Constructors not generated");
createTypeInvokables(c, varName, "Constructor", c.getConstructors()); } else { logger.log(Type.INFO, c.getName() + " can't be instantiated. Constructors not generated");
private JConstructor findCreator(JClassType sourceClazz) { for (JConstructor constructor : sourceClazz.getConstructors()) { if (getAnnotation(constructor, JsonCreator.class) != null) { return constructor; } } return null; }
private JConstructor findCreator(JClassType sourceClazz) { for (JConstructor constructor : sourceClazz.getConstructors()) { if (getAnnotation(constructor, JsonCreator.class) != null) { return constructor; } } return null; }
public static String getConstructorFactoryName(JClassType type, JParameter[] list) { StringBuilder b = new StringBuilder(type.getName()); b.append(CONSTRUCTOR_SPACER).append(ReflectionUtilType.toUniqueFactory(list, type.getConstructors())); return b.toString(); }
public static String getConstructorFactoryName(final JClassType type, final JParameter[] list) { final StringBuilder b = new StringBuilder(type.getName()); b.append(MemberGenerator.CONSTRUCTOR_SPACER).append( ReflectionUtilType.toUniqueFactory(list, type.getConstructors())); return b.toString(); }
@Override public MetaConstructor[] getConstructors() { final JClassType type = getEnclosedMetaObject().isClassOrInterface(); if (type == null) { return null; } return fromMethodArray(oracle, Arrays .stream(type.getConstructors()) .filter(ctor -> ctor.isPublic())); }
@Override public MetaConstructor[] getDeclaredConstructors() { final JClassType type = getEnclosedMetaObject().isClassOrInterface(); if (type == null) { return null; } return fromMethodArray(oracle, Arrays.stream(type.getConstructors())); }
@Override public MetaConstructor[] getDeclaredConstructors() { final JClassType type = getEnclosedMetaObject().isClassOrInterface(); if (type == null) { return null; } return fromMethodArray(oracle, Arrays.stream(type.getConstructors())); }
@Override public MetaConstructor[] getConstructors() { final JClassType type = getEnclosedMetaObject().isClassOrInterface(); if (type == null) { return null; } return fromMethodArray(oracle, Arrays .stream(type.getConstructors()) .filter(ctor -> ctor.isPublic())); }
private static void extractConstructors(TreeLogger logger, KeepConstructor keepCtor, JClassType injectionType, ReflectionManifest manifest) { boolean keepCtors = keepCtor != null; boolean keepAnnos = manifest.anno != null; Set<String> seen = new HashSet<String>(); Set<? extends JClassType> allTypes = injectionType.getFlattenedSupertypeHierarchy(); for(JClassType nextClass : allTypes) { for (JConstructor ctor : nextClass.getConstructors()) { if (keepCtors || ctor.getAnnotation(KeepConstructor.class) != null){ // do not include overridden constructors if (seen.add(ctor.getJsniSignature())) { final Annotation[] annos; if (keepAnnos || ctor.getAnnotation(KeepAnnotation.class) != null) { annos = ctor.getAnnotations(); } else { // only keep annotations annotated with KeepAnnotation. final List<Annotation> keepers = new ArrayList<Annotation>(); for (Annotation anno : ctor.getAnnotations()) { if (anno.annotationType().getAnnotation(KeepAnnotation.class) != null) keepers.add(anno); } annos = keepers.toArray(new Annotation[keepers.size()]); } manifest.constructors.put(ctor, annos); } } } nextClass = nextClass.getSuperclass(); } }
/** * Finds the constructor annotated with @UiConcontructor if there is one, and * puts it in the {@link #uiConstructor} field. * * @param fieldType the type of the field */ private void findUiConstructor(JClassType fieldType) throws UnableToCompleteException { for (JConstructor ctor : fieldType.getConstructors()) { if (ctor.getAnnotation(UiConstructor.class) != null) { if (uiConstructor != null) { logger.die(fieldType.getName() + " has more than one constructor annotated with @UiConstructor"); } uiConstructor = ctor; } } }
public static JConstructor findConstructor(TreeLogger logger, JClassType type, List<String> params, boolean declared) { loop: for (JConstructor ctor : type.getConstructors()) { JType[] types = ctor.getParameterTypes(); if (types.length == params.size()) { for (int i = 0, m = types.length; i < m; i++ ) { String typeName = types[i].getErasedType().getQualifiedBinaryName(); while (typeName.startsWith("[")) { typeName = typeName.substring(1)+"[]"; } if (!params.get(i).equals(typeName)) { logger.log(Type.DEBUG, "constructor with different signature; " +"("+params+") mismatches at index "+i+" with value "+typeName); continue loop; } } return ctor; } } return declared || type.getSuperclass() == null ? null: findConstructor(logger, type.getSuperclass(), params, declared); }
/** * Finds the constructor annotated with @UiConcontructor if there is one, and * puts it in the {@link #uiConstructor} field. * * @param fieldType the type of the field */ private void findUiConstructor(JClassType fieldType) throws UnableToCompleteException { for (JConstructor ctor : fieldType.getConstructors()) { if (ctor.getAnnotation(UiConstructor.class) != null) { if (uiConstructor != null) { logger.die(fieldType.getName() + " has more than one constructor annotated with @UiConstructor"); } uiConstructor = ctor; } } }
public static JConstructor findConstructor(final TreeLogger logger, final JClassType type, final List<String> params, final boolean declared) { loop: for (final JConstructor ctor : type.getConstructors()) { final JType[] types = ctor.getParameterTypes(); if (types.length == params.size()) { for (int i = 0, m = types.length; i < m; i++ ) { String typeName = types[i].getErasedType().getQualifiedBinaryName(); while (typeName.startsWith("[")) { typeName = typeName.substring(1)+"[]"; } if (!params.get(i).equals(typeName)) { logger.log(Type.DEBUG, "constructor with different signature; " +"("+params+") mismatches at index "+i+" with value "+typeName); continue loop; } } return ctor; } } return declared || type.getSuperclass() == null ? null: findConstructor(logger, type.getSuperclass(), params, declared); }
/** * Check for a constructor which is compatible with the supplied argument * types. * * @param type * @param argTypes * @return true if a constructor compatible with the supplied arguments exists */ public static boolean hasCompatibleConstructor(JClassType type, JType... argTypes) { // Note that this does not return the constructor, since that is a more // complicated decision about finding the best matching arguments where // more than one are compatible. for (JConstructor ctor : type.getConstructors()) { if (typesAreCompatible(ctor.getParameterTypes(), argTypes, ctor.isVarArgs())) { return true; } } return false; }
/** * Check for a constructor which is compatible with the supplied argument * types. * * @param type * @param argTypes * @return true if a constructor compatible with the supplied arguments exists */ public static boolean hasCompatibleConstructor(JClassType type, JType... argTypes) { // Note that this does not return the constructor, since that is a more // complicated decision about finding the best matching arguments where // more than one are compatible. for (JConstructor ctor : type.getConstructors()) { if (typesAreCompatible(ctor.getParameterTypes(), argTypes, ctor.isVarArgs())) { return true; } } return false; }
@Override protected void doGenerate(SourceWriter sourceWriter) throws UnableToCompleteException { JClassType adapterProviderClassType = typeOracle.findType(getAdapterProviderBaseClass().getCanonicalName()); JClassType[] adapterProviders = adapterProviderClassType.getSubtypes(); sourceWriter.println("public void registerAllAdapters() {"); sourceWriter.indent(); for (JClassType adapterProviderImplementationClassType : adapterProviders) { if (!adapterProviderImplementationClassType.isAbstract()) { boolean found = false; for (JConstructor constructor :adapterProviderImplementationClassType.getConstructors()) { if (constructor.getParameters().length == 0) { found = true; } } if (found) { sourceWriter.println(BeanAdapterFactory.class.getSimpleName() + ".addProvider(new " + adapterProviderImplementationClassType.getQualifiedSourceName() + "());"); } } } sourceWriter.indent(); sourceWriter.println("}"); }
private void generateInternalTokenizer(TreeLogger logger, SourceWriter srcWriter) { boolean hasTokeConstructor = false; for (JConstructor constructor : this.placeType.getConstructors()) { if (constructor.getParameters().length == 1 && constructor.getParameters()[0].getType().getSimpleSourceName().equals(String.class.getSimpleName())) {
private void generateInternalTokenizer(TreeLogger logger, SourceWriter srcWriter) { boolean hasTokeConstructor = false; for (JConstructor constructor : this.placeType.getConstructors()) { if (constructor.getParameters().length == 1 && constructor.getParameters()[0].getType().getSimpleSourceName().equals(String.class.getSimpleName())) {