Java Code Examples for javax.lang.model.element.Parameterizable#getTypeParameters()
The following examples show how to use
javax.lang.model.element.Parameterizable#getTypeParameters() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintingProcessor.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private void printFormalTypeParameters(Parameterizable e, boolean pad) { List<? extends TypeParameterElement> typeParams = e.getTypeParameters(); if (typeParams.size() > 0) { writer.print("<"); boolean first = true; for(TypeParameterElement tpe: typeParams) { if (!first) writer.print(", "); printAnnotationsInline(tpe); writer.print(tpe.toString()); first = false; } writer.print(">"); if (pad) writer.print(" "); } }
Example 2
Source File: PrintingProcessor.java From javaide with GNU General Public License v3.0 | 6 votes |
private void printFormalTypeParameters(Parameterizable e, boolean pad) { List<? extends TypeParameterElement> typeParams = e.getTypeParameters(); if (typeParams.size() > 0) { writer.print("<"); boolean first = true; for(TypeParameterElement tpe: typeParams) { if (!first) writer.print(", "); printAnnotationsInline(tpe); writer.print(tpe.toString()); first = false; } writer.print(">"); if (pad) writer.print(" "); } }
Example 3
Source File: MoreElements.java From doma with Apache License 2.0 | 5 votes |
public TypeParametersDef getTypeParametersDef(Parameterizable element) { assertNotNull(element); List<? extends TypeParameterElement> typeParameters = element.getTypeParameters(); List<String> typeParameterNames = getTypeParameterNames(typeParameters); Iterator<String> values = typeParameterNames.iterator(); Iterator<? extends TypeParameterElement> keys = typeParameters.iterator(); LinkedHashMap<TypeParameterElement, String> map = new LinkedHashMap<>(); while (keys.hasNext() && values.hasNext()) { map.put(keys.next(), values.next()); } return new TypeParametersDef(map); }
Example 4
Source File: CompilerTreeApiTest.java From buck with Apache License 2.0 | 5 votes |
protected TypeParameterElement findTypeParameter(String name, Parameterizable element) { for (TypeParameterElement parameter : element.getTypeParameters()) { if (parameter.getSimpleName().contentEquals(name)) { return parameter; } } throw new IllegalArgumentException( String.format("No such parameter on %s: %s", element.getSimpleName(), name)); }
Example 5
Source File: TypeExtractor.java From immutables with Apache License 2.0 | 5 votes |
private Type.Parameters initParameters(Parameterizable context) { Type.Parameters parameters = factory.parameters(); for (TypeParameterElement p : context.getTypeParameters()) { String name = p.getSimpleName().toString(); // <T extends Cls<T>>: when parsing bounds for T, T should be already defined for recursion Type.Parameters parameterForRecursion = parameters.recursive(name); List<Type.Defined> bounds = getBounds(parameterForRecursion, p); parameters = parameters.introduce(name, bounds); } return parameters; }
Example 6
Source File: Encodings.java From immutables with Apache License 2.0 | 5 votes |
private List<String> getTypeParameterNames(Parameterizable element) { List<String> names = new ArrayList<>(); for (TypeParameterElement p : element.getTypeParameters()) { names.add(p.getSimpleName().toString()); } return names; }