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); }
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); }
/** * 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; }
JConstructor mixinConstructor = mixinClass.get().findConstructor( constructor.getParameterTypes() ); if ( null != mixinConstructor ) { constructors.add( mixinConstructor );