@SuppressWarnings("unchecked") @Override public <T, U> U getValue(T element) { return ((U) ((Object) (castTarget(element).getConstructors()))); }
for (CtConstructor<?> c : sourceClass.getConstructors()) { if (c.isImplicit()) { continue;
executables.addAll(((CtType<?>) t).getMethods()); if (t instanceof CtClass) { executables.addAll(((CtClass<?>) t).getConstructors());
/** * Generates a constructor from a template constructor by substituting all * the template parameters by their values. * * @param targetClass * the target class where to insert the generated constructor * @param template * the template instance that holds the source template * constructor and that defines the parameter values * @param sourceConstructor * the source template constructor * @return the generated constructor */ @SuppressWarnings("unchecked") public static <T> CtConstructor<T> insertConstructor(CtClass<T> targetClass, Template<?> template, CtConstructor<?> sourceConstructor) { CtConstructor<T> newConstrutor = substitute(targetClass, template, (CtConstructor<T>) sourceConstructor); // remove the implicit constructor if clashing if (newConstrutor.getParameters().isEmpty()) { CtConstructor<?> c = targetClass.getConstructor(); if (c != null && c.isImplicit()) { targetClass.getConstructors().remove(c); } } targetClass.addConstructor(newConstrutor); // newConstrutor.setParent(targetClass); return newConstrutor; }
ctClass.getNestedTypes().forEach(t -> add(mergedClass, t, mergedClass::addNestedType)); ctClass.getFields().forEach(f -> add(mergedClass, f, mergedClass::addField)); ctClass.getConstructors() .stream() .filter(c -> !c.isImplicit())
private static <T> void mergeStagedChainInner(List<CtClass<T>> chain) { if (chain.size() == 1) return; reverse(chain); CtClass<T> toMerge = chain.get(0); for (int i = 1; i < chain.size(); i++) { CtClass<T> mergeInto = chain.get(i); replaceInstantiatedTypeParams(toMerge, mergeInto); toMerge.getAnnotations().stream() .forEach((CtAnnotation<? extends Annotation> a) -> { if (mergeInto.getAnnotation(a.getActualAnnotation().getClass()) == null) add(mergeInto, a, mergeInto::addAnnotation); }); toMerge.getSuperInterfaces().forEach(mergeInto::addSuperInterface); toMerge.getAnonymousExecutables() .forEach(b -> add(mergeInto, b, mergeInto::addAnonymousExecutable)); toMerge.getNestedTypes().forEach(nt -> add(mergeInto, nt, mergeInto::addNestedType)); toMerge.getFields().forEach(f -> add(mergeInto, f, mergeInto::addField)); for (CtMethod<?> methodToMerge : toMerge.getMethods()) { processMethod(mergeInto, toMerge, methodToMerge); } final CtClass<T> finalToMerge = toMerge; mergeInto.getConstructors().forEach(c -> processConstructor(c, finalToMerge)); mergeInto.setSuperclass(toMerge.getSuperclass()); toMerge = mergeInto; } }
if (typeDeclaration != null && typeDeclaration instanceof CtClass<?>) { final List<CtConstructor<?>> constructors = ((CtClass<?>) typeDeclaration).getConstructors() .stream() .filter(ctConstructor ->
if (declaringType instanceof CtClass) { CtClass<?> declaringClass = (CtClass) declaringType; if (declaringClass.getConstructors().isEmpty()) { Factory factory = declaringClass.getFactory(); CtConstructor ctr = factory.Constructor().create(declaringClass, EnumSet.of(PUBLIC), emptyList(), emptySet()); ctr.setBody(factory.Core().createBlock()); } else if (declaringClass.getConstructors().size() == 1) { declaringClass.getConstructors().iterator().next().setImplicit(false); declaringClass.getConstructors().forEach((CtConstructor ctr) -> { CtAssignment assignment = root.f.Code().createVariableAssignment( field.getReference(), false, root.f.Core().clone(fieldInit));
for (CtConstructor<?> c : new TreeSet<CtConstructor<?>>(ctClass.getConstructors())) { if (c.getAnnotation(Local.class) != null) { ctClass.getConstructors().remove(c);
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public <T> void visitCtConstructorCall(CtConstructorCall<T> ctConstructorCall) { super.visitCtConstructorCall(ctConstructorCall); String type = ctConstructorCall.getType().getQualifiedName(); List<CtExpression<?>> argumentlist = ctConstructorCall.getArguments(); List<String> orig = resolveTypes(argumentlist); CtClass classname = parser.getClassMap().get(type); if(classname!=null) { Set<CtConstructor<T>> constructors=classname.getConstructors(); for(CtConstructor constructor:constructors) { List<CtParameter> paramlist=constructor.getParameters(); List<String> target=resolveParams(paramlist); transformOneMethod(orig,target,ctConstructorCall); } } else { List<Class[]> params = parser.fetchMethods(type, type); for (Class[] p : params) transformOneConstructor(orig, ctConstructorCall, p); } }
for (CtConstructor<?> c : sourceClass.getConstructors()) { if (c.isImplicit()) { continue;
public <T> void visitCtClass(CtClass<T> ctClass) { enter(ctClass); scan(ctClass.getAnnotations()); scan(ctClass.getSuperclass()); scanReferences(ctClass.getSuperInterfaces()); scanReferences(ctClass.getFormalTypeParameters()); scan(ctClass.getAnonymousExecutables()); scan(ctClass.getNestedTypes()); scan(ctClass.getFields()); scan(ctClass.getConstructors()); scan(ctClass.getMethods()); exit(ctClass); }
for (CtConstructor<T> c : ctClass.getConstructors()) { if (!c.isImplicit()) { lst.add(c);
for (CtConstructor<?> c : templateClass.getConstructors()) { if (c.isImplicit()) { continue;