本文整理了Java中javax.lang.model.util.Types.getWildcardType()
方法的一些代码示例,展示了Types.getWildcardType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.getWildcardType()
方法的具体详情如下:
包路径:javax.lang.model.util.Types
类名称:Types
方法名:getWildcardType
[英]Returns a new wildcard type argument. Either of the wildcard's bounds may be specified, or neither, but not both.
[中]返回一个新的通配符类型参数。可以指定通配符的任意一个边界,也可以两者都指定,但不能同时指定两者。
代码示例来源:origin: sockeqwe/fragmentargs
private TypeMirror getWildcardType(String type, String elementType) {
TypeElement arrayList = processingEnv.getElementUtils().getTypeElement(type);
TypeMirror elType = processingEnv.getElementUtils().getTypeElement(elementType).asType();
return processingEnv.getTypeUtils()
.getDeclaredType(arrayList, processingEnv.getTypeUtils().getWildcardType(elType, null));
}
代码示例来源:origin: androidannotations/androidannotations
private void createDaoParametrizedTypes() {
daoTypeElement = helper.typeElementFromQualifiedName(OrmLiteClasses.DAO);
runtimeExceptionDaoTypeElement = helper.typeElementFromQualifiedName(OrmLiteClasses.RUNTIME_EXCEPTION_DAO);
Types typeUtils = helper.getTypeUtils();
TypeMirror wildcardType = typeUtils.getWildcardType(null, null);
daoParametrizedType = helper.getTypeUtils().getDeclaredType(daoTypeElement, wildcardType, wildcardType);
runtimeExceptionDaoParametrizedType = helper.getTypeUtils().getDeclaredType(runtimeExceptionDaoTypeElement, wildcardType, wildcardType);
}
}
代码示例来源:origin: inferred/FreeBuilder
private static TypeMirror wildcardSuperMap(
TypeMirror keyType,
TypeMirror valueType,
Elements elements,
Types types) {
TypeElement mapType = elements.getTypeElement(Map.class.getName());
return types.getWildcardType(null, types.getDeclaredType(mapType, keyType, valueType));
}
}
代码示例来源:origin: inferred/FreeBuilder
private static TypeMirror wildcardSuperSortedSet(
TypeMirror elementType,
Elements elements,
Types types) {
TypeElement setType = elements.getTypeElement(SortedSet.class.getName());
return types.getWildcardType(null, types.getDeclaredType(setType, elementType));
}
}
代码示例来源:origin: inferred/FreeBuilder
private static TypeMirror wildcardSuperSet(
TypeMirror elementType,
Elements elements,
Types types) {
TypeElement setType = elements.getTypeElement(Set.class.getName());
return types.getWildcardType(null, types.getDeclaredType(setType, elementType));
}
}
代码示例来源:origin: inferred/FreeBuilder
/**
* Returns {@code ? super List<elementType>}.
*/
private static TypeMirror wildcardSuperList(
TypeMirror elementType,
Elements elements,
Types types) {
TypeElement listType = elements.getTypeElement(List.class.getName());
return types.getWildcardType(null, types.getDeclaredType(listType, elementType));
}
}
代码示例来源:origin: inferred/FreeBuilder
upperBound = null;
return typeUtils.getWildcardType(
typeMirror(typeUtils, elementUtils, upperBound),
typeMirror(typeUtils, elementUtils, lowerBound));
代码示例来源:origin: org.uberfire/uberfire-workbench-processors
@Override
public WildcardType getWildcardType(TypeMirror arg0,
TypeMirror arg1) {
return realImpl.getWildcardType(arg0,
arg1);
}
代码示例来源:origin: inferred/FreeBuilder
@Test
public void testErasesToAnyOf_wildcardType() {
WildcardType wildcard = model.typeUtils().getWildcardType(null, null);
assertTrue(ModelUtils.erasesToAnyOf(
(DeclaredType) model.typeMirror("java.util.List", wildcard), List.class));
}
代码示例来源:origin: inferred/FreeBuilder
@Test
public void testHandlesWildcards() {
// Get a functional type representing Consumer<? super List<Integer>>
TypeElement list = model.elementUtils().getTypeElement(List.class.getName());
TypeMirror integer = model.elementUtils().getTypeElement(Integer.class.getName()).asType();
DeclaredType intList = model.typeUtils().getDeclaredType(list, integer);
WildcardType superIntList = model.typeUtils().getWildcardType(null, intList);
FunctionalType consumerSuperIntList = FunctionalType.consumer(superIntList);
FunctionalType result = FunctionalType.functionalTypeAcceptedByMethod(
(DeclaredType) model.typeElement(Foo.class).asType(),
"mutate",
consumerSuperIntList,
model.elementUtils(),
model.typeUtils());
assertEquals(
QualifiedName.of(IntListConsumer.class).withParameters(),
result.getFunctionalInterface());
}
代码示例来源:origin: inferred/FreeBuilder
@Test
public void testUpperBound_unknownType() {
// ? -> Object
TypeMirror result = ModelUtils.upperBound(
model.elementUtils(), model.typeUtils().getWildcardType(null, null));
assertSameType(model.typeMirror("Object"), result);
}
代码示例来源:origin: inferred/FreeBuilder
@Test
public void testUpperBound_superBound() {
// ? super T -> Object
TypeMirror result = ModelUtils.upperBound(
model.elementUtils(), model.typeUtils().getWildcardType(null, model.typeMirror("Number")));
assertSameType(model.typeMirror("Object"), result);
}
代码示例来源:origin: inferred/FreeBuilder
@Test
public void testUpperBound_extendsBound() {
// ? extends T -> T
TypeMirror result = ModelUtils.upperBound(
model.elementUtils(), model.typeUtils().getWildcardType(model.typeMirror("Number"), null));
assertSameType(model.typeMirror("Number"), result);
}
代码示例来源:origin: org.inferred/freebuilder
private static TypeMirror wildcardSuperMap(
TypeMirror keyType,
TypeMirror valueType,
Elements elements,
Types types) {
TypeElement mapType = elements.getTypeElement(Map.class.getName());
return types.getWildcardType(null, types.getDeclaredType(mapType, keyType, valueType));
}
}
代码示例来源:origin: org.inferred/freebuilder
private static TypeMirror wildcardSuperSortedSet(
TypeMirror elementType,
Elements elements,
Types types) {
TypeElement setType = elements.getTypeElement(SortedSet.class.getName());
return types.getWildcardType(null, types.getDeclaredType(setType, elementType));
}
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb-processor
public static void init(ProcessingEnvironment env) {
types = env.getTypeUtils();
elements = env.getElementUtils();
factoryInterface = types.getDeclaredType(
elements.getTypeElement("com.artemis.EntityFactory"),
types.getWildcardType(null, null));
ObjectElement = (TypeElement) types.getDeclaredType(
elements.getTypeElement("java.lang.Object")).asElement();
}
代码示例来源:origin: ArcBees/GWTP
public TypeMirror createWithWildcard(String qualifiedName) {
TypeElement element = elements.getTypeElement(qualifiedName);
int typeParametersCount = element.getTypeParameters().size();
TypeMirror[] typeArguments = new TypeMirror[typeParametersCount];
for (int i = 0; i < typeParametersCount; ++i) {
typeArguments[i] = types.getWildcardType(null, null);
}
return types.getDeclaredType(element, typeArguments);
}
代码示例来源:origin: fr.xebia.extras/selma-processor
public static boolean isCollection(DeclaredType declaredType, MapperGeneratorContext context) {
TypeElement typeElement1 = context.elements.getTypeElement("java.util.Collection");
DeclaredType declaredType2 = context.type.getDeclaredType(typeElement1, context.type.getWildcardType(null, null));
return declaredType != null && context.type.isAssignable(declaredType, declaredType2);
}
代码示例来源:origin: stoicflame/enunciate
public WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound) {
while (extendsBound instanceof DecoratedTypeMirror) {
extendsBound = ((DecoratedTypeMirror) extendsBound).getDelegate();
}
while (superBound instanceof DecoratedTypeMirror) {
superBound = ((DecoratedTypeMirror) superBound).getDelegate();
}
return delegate.getWildcardType(extendsBound, superBound);
}
代码示例来源:origin: org.brightify.torch/torch-compiler
@Override
public boolean accepts(TypeMirror type) {
DeclaredType lazyList =
types.getDeclaredType(typeHelper.elementOf(List.class), types.getWildcardType(null, null));
if (!types.isAssignable(typeHelper.getWrappedType(type), lazyList)) {
return false;
}
TypeMirror listType = typeHelper.singleGenericParameter(type);
return marshallerRegistry.getMarshaller(listType) != null && !entityContext.containsEntity(listType.toString());
}
内容来源于网络,如有侵权,请联系作者删除!