private void initializeExplicitConstructor( TurinTypeContructorDefinitionNode constructor, SymbolResolver resolver) { List<? extends FormalParameter> allParams = constructor.getParameters(); List<FormalParameter> paramsWithoutDefaultValues = allParams .stream() .filter((p) -> !p.hasDefaultValue()) .collect(Collectors.<FormalParameter>toList()); List<String> paramSignatures = paramsWithoutDefaultValues .stream() .map((p) -> p.getType().jvmType().getSignature()) .collect(Collectors.toList()); boolean hasDefaultParameters = allParams.stream().filter((p) -> p.hasDefaultValue()).findFirst().isPresent(); if (hasDefaultParameters) { paramSignatures.add("Ljava/util/Map;"); } JvmConstructorDefinition constructorDefinition = new JvmConstructorDefinition( jvmType().getInternalName(), "(" + String.join("", paramSignatures) + ")V"); constructors.add( new InternalConstructorDefinition( new ReferenceTypeUsage(this), allParams, constructorDefinition)); }
public List<Property> getDirectProperties(SymbolResolver resolver) { List<Property> properties = new ArrayList<>(); for (Node member : members) { if (member instanceof PropertyDefinition) { properties.add(Property.fromDefinition((PropertyDefinition) member)); } else if (member instanceof PropertyReference) { properties.add(Property.fromReference((PropertyReference) member, resolver)); } } return properties; }
public void add(PropertyDefinition propertyDefinition) { if (propertyDefinition.getType().getParent() != propertyDefinition && propertyDefinition.getType().getParent().getParent() == null) { throw new IllegalArgumentException(); } members.add(propertyDefinition); propertyDefinition.parent = this; }
public List<TurinTypeMethodDefinitionNode> getDirectMethods() { List<TurinTypeMethodDefinitionNode> methods = new ArrayList<>(); for (Node member : members) { if (member instanceof TurinTypeMethodDefinitionNode) { methods.add((TurinTypeMethodDefinitionNode) member); } } return methods; }
@Override public List<ReferenceTypeUsage> getAllAncestors() { if (getBaseType().isPresent()) { List<ReferenceTypeUsage> res = new ArrayList<>(); res.add(getBaseType().get().asReferenceTypeUsage()); res.addAll(getBaseType().get().asReferenceTypeUsage().getAllAncestors()); return res; } return ImmutableList.of(ReferenceTypeUsage.OBJECT(symbolResolver())); }
@Override public Iterable<Node> getChildren() { List<Node> children = new LinkedList<>(); children.addAll(members); children.addAll(annotations); if (baseType.isPresent()) { children.add(baseType.get()); } children.addAll(interfaces); return children; }
public void addAnnotation(AnnotationUsage annotation) { annotation.setParent(this); annotations.add(annotation); }
public void addInterface(TypeUsageNode interfaze) { interfaze.setParent(this); interfaces.add(interfaze); }
public void add(TurinTypeContructorDefinitionNode contructorDefinition) { members.add(contructorDefinition); contructorDefinition.parent = this; }
public void add(TurinTypeMethodDefinitionNode methodDefinition) { members.add(methodDefinition); methodDefinition.parent = this; }
public void add(PropertyReference propertyReference) { members.add(propertyReference); propertyReference.parent = this; }