set type parameter to a copied node.

@param node node to build
@param containerClass container class to set
@param typeArgumentIndex type argument index to set
@return new created node implementation
556078
public static NodeImpl setTypeParameter(final NodeImpl node, final Class<?> containerClass,
      final Integer typeArgumentIndex) {
    return new NodeImpl( //
        node.name, //
        node.parent, //
        node.isIterableValue, //
        node.index, //
        node.key, //
        node.kind, //
        node.parameterTypes, //
        node.parameterIndex, //
        node.value, //
        containerClass, //
        typeArgumentIndex //
    );
  }
1210091
public function setType($parameterIndex, ObjectTypeInterface $type)
    {
        $this->setParameter($parameterIndex, $this->escape($type->getQueryName()));
    }
697408
@Override
    public R visitTypeParameter(TypeParameterTree node, P p) {
        R r = scan(node.getAnnotations(), p);
        r = scanAndReduce(node.getBounds(), p, r);
        return r;
    }
428557
private static <T> void mapTypeVariablesToArguments(final Class<T> cls,
            final ParameterizedType parameterizedType, final Map<TypeVariable<?>, Type> typeVarAssigns) {
        // capture the type variables from the owner type that have assignments
        final Type ownerType = parameterizedType.getOwnerType();

        if (ownerType instanceof ParameterizedType) {
            // recursion to make sure the owner's owner type gets processed
            mapTypeVariablesToArguments(cls, (ParameterizedType) ownerType, typeVarAssigns);
        }

        // parameterizedType is a generic interface/class (or it's in the owner
        // hierarchy of said interface/class) implemented/extended by the class
        // cls. Find out which type variables of cls are type arguments of
        // parameterizedType:
        final Type[] typeArgs = parameterizedType.getActualTypeArguments();

        // of the cls's type variables that are arguments of parameterizedType,
        // find out which ones can be determined from the super type's arguments
        final TypeVariable<?>[] typeVars = getRawType(parameterizedType).getTypeParameters();

        // use List view of type parameters of cls so the contains() method can be used:
        final List<TypeVariable<Class<T>>> typeVarList = Arrays.asList(cls
                .getTypeParameters());

        for (int i = 0; i < typeArgs.length; i++) {
            final TypeVariable<?> typeVar = typeVars[i];
            final Type typeArg = typeArgs[i];

            // argument of parameterizedType is a type variable of cls
            if (typeVarList.contains(typeArg)
            // type variable of parameterizedType has an assignment in
                    // the super type.
                    && typeVarAssigns.containsKey(typeVar)) {
                // map the assignment to the cls's type variable
                typeVarAssigns.put((TypeVariable<?>) typeArg, typeVarAssigns.get(typeVar));
            }
        }
    }
211017
public ParameterizedTypeName nestedClass(String name, List<TypeName> typeArguments) {
    checkNotNull(name, "name == null");
    return new ParameterizedTypeName(this, rawType.nestedClass(name), typeArguments,
        new ArrayList<>());
  }
245859
public Node createOptionalParameters(JSType... parameterTypes) {
    FunctionParamBuilder builder = new FunctionParamBuilder(this);
    builder.addOptionalParams(parameterTypes);
    return builder.build();
  }
1363223
@Override
    public org.mozilla.javascript.Node setType(int type) {
        if (type != Token.VAR
            && type != Token.CONST
            && type != Token.LET)
            throw new IllegalArgumentException("invalid decl type: " + type);
        return super.setType(type);
    }
591860
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass, 
            Set<String> exclusions, IdStrategy strategy)
    {
        if(typeClass.isInterface() || Modifier.isAbstract(typeClass.getModifiers()))
        {
            throw new RuntimeException("The root object can neither be an abstract " +
                        "class nor interface: \"" + typeClass.getName());
        }
        
        final Map<String,java.lang.reflect.Field> fieldMap = findInstanceFields(typeClass);
        final ArrayList<Field<T>> fields = new ArrayList<Field<T>>(fieldMap.size());
        int i = 0;
        int maxFieldMapping = 0;
        boolean annotated = false;
        for(java.lang.reflect.Field f : fieldMap.values())
        {
            if(!exclusions.contains(f.getName()))
            {
                if(f.getAnnotation(Deprecated.class) != null)
                {
                    // this field is deprecated and should be skipped.
                    // preserve its field number for backward-forward compat
                    i++;
                    continue;
                }
                
                final Tag tag = f.getAnnotation(Tag.class);
                final int fieldMapping;
                final String name;
                if(tag == null)
                {
                    // Fields gets assigned mapping tags according to their definition order
                    if(annotated)
                    {
                        throw new RuntimeException("When using annotation-based mapping, " +
                                "all fields must be annotated with @" + Tag.class.getSimpleName());
                    }
                    fieldMapping = ++i;
                    
                    name = f.getName();
                }
                else
                {
                    // Fields gets assigned mapping tags according to their annotation
                    if(!annotated && !fields.isEmpty())
                    {
                        throw new RuntimeException("When using annotation-based mapping, " +
                                "all fields must be annotated with @" + Tag.class.getSimpleName());
                    }
                    annotated = true;
                    fieldMapping = tag.value();
                    
                    if(fieldMapping < 1)
                    {
                        throw new RuntimeException("Invalid field number: " + 
                                fieldMapping + " on " + typeClass);
                    }
                    
                    name = tag.alias().isEmpty() ? f.getName() : tag.alias();
                }
                
                final Field<T> field = RuntimeFieldFactory.getFieldFactory(
                        f.getType(), strategy).create(fieldMapping, name, f, strategy);
                fields.add(field);
                
                maxFieldMapping = Math.max(maxFieldMapping, fieldMapping);
            }
        }
        if(fields.isEmpty())
        {
            throw new RuntimeException("Not able to map any fields from " + 
                    typeClass + ".  All fields are either transient/static.");
        }
        
        return new RuntimeSchema<T>(typeClass, fields, maxFieldMapping, 
                RuntimeEnv.newInstantiator(typeClass));
    }
422898
public static TypeAnnotationPosition
        typeParameter(final List<TypePathEntry> location,
                      final JCLambda onLambda,
                      final int parameter_index,
                      final int pos) {
        return new TypeAnnotationPosition(TargetType.CLASS_TYPE_PARAMETER, pos,
                                          parameter_index, onLambda,
                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
                                          location);
    }
255092
public static Type getTypeArgument(Type type, int index) {
		final Type[] typeArguments = getTypeArguments(type);
		if (null != typeArguments && typeArguments.length > index) {
			return typeArguments[index];
		}
		return null;
	}
329435
@SuppressWarnings("unchecked")
    private <T extends XPathBuilder> T setSearchLabelType(SearchType... searchLabelTypes) {
        this.searchLabelType = new ArrayList<>();
        if (searchLabelTypes != null) {
            this.searchLabelType.addAll(0, Arrays.asList(searchLabelTypes));
        }
        this.searchLabelType = cleanUpSearchType(this.searchLabelType);
        return (T) this;
    }
1046403
@Override
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
        for (Class<?> t = type.getRawType(); (t != Object.class) && (t.getSuperclass() != null); t = t.getSuperclass()) {
            for (Method m : t.getDeclaredMethods()) {
                if (m.isAnnotationPresent(PostConstruct.class)) {
                    m.setAccessible(true);
                    TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
                    return new PostConstructAdapter<T>(delegate, m);
                }
            }
        }
        return null;
    }
932410
public static NodeImpl makeIterableAndSetMapKey(final NodeImpl node, final Object key) {
    return new NodeImpl( //
        node.name, //
        node.parent, //
        true, //
        null, //
        key, //
        node.kind, //
        node.parameterTypes, //
        node.parameterIndex, //
        node.value, //
        node.containerClass, //
        node.typeArgumentIndex //
    );
  }
1176197
public static TypeAnnotationPosition
        constructorRefTypeArg(final List<TypePathEntry> location,
                              final int type_index) {
        return constructorRefTypeArg(location, null, type_index, -1);
    }
437117
@SuppressWarnings("unchecked")
	public <T> DatagraphEnvironment setInstance(Class<T> type, T value) {
		((Map<Class<T>, T>) instances).put(type, value);
		return this;
	}
913018
public static void setVarargsElement(JCTree tree, Type varargsElement) {
        switch (tree.getTag()) {
            case APPLY:
                ((JCMethodInvocation)tree).varargsElement = varargsElement;
                break;
            case NEWCLASS:
                ((JCNewClass)tree).varargsElement = varargsElement;
                break;
            case REFERENCE:
                ((JCMemberReference)tree).varargsElement = varargsElement;
                break;
            default:
                throw new AssertionError("Unexpected tree: " + tree);
        }
    }
663147
public final void setObjectTypeNode(final ObjectTypeNode objectTypeNode) {
        this.objectTypeNode = objectTypeNode;

        NodeReferenceSetter setter= new NodeReferenceSetter();
        ObjectTypeNodeParser parser = new ObjectTypeNodeParser(objectTypeNode);
        parser.accept(setter);
    }