本文整理汇总了Java中javax.lang.model.type.TypeMirror.accept方法的典型用法代码示例。如果您正苦于以下问题:Java TypeMirror.accept方法的具体用法?Java TypeMirror.accept怎么用?Java TypeMirror.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.type.TypeMirror
的用法示例。
在下文中一共展示了TypeMirror.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitType
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
public Boolean visitType(TypeElement arg0, Void arg1) {
for (TypeParameterElement e : arg0.getTypeParameters()) {
if (stop) {
return false;
}
for (TypeMirror b : e.getBounds()) {
if (stop) {
return false;
}
if (b.accept(this, arg1)) {
return true;
}
}
}
TypeMirror superclass = arg0.getSuperclass();
if (superclass.getKind() == TypeKind.DECLARED) {
if (!((DeclaredType) superclass).asElement().getKind().isInterface()) {
return false;
}
}
return superclass.accept(this, arg1);
}
示例2: equal
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private static boolean equal(TypeMirror a, TypeMirror b, Set<ComparedElements> visiting) {
// TypeMirror.equals is not guaranteed to return true for types that are equal, but we can
// assume that if it does return true then the types are equal. This check also avoids getting
// stuck in infinite recursion when Eclipse decrees that the upper bound of the second K in
// <K extends Comparable<K>> is a distinct but equal K.
// The javac implementation of ExecutableType, at least in some versions, does not take thrown
// exceptions into account in its equals implementation, so avoid this optimization for
// ExecutableType.
if (Objects.equal(a, b) && !(a instanceof ExecutableType)) {
return true;
}
EqualVisitorParam p = new EqualVisitorParam();
p.type = b;
p.visiting = visiting;
if (INTERSECTION_TYPE != null) {
if (isIntersectionType(a)) {
return equalIntersectionTypes(a, b, visiting);
} else if (isIntersectionType(b)) {
return false;
}
}
return (a == b) || (a != null && b != null && a.accept(EQUAL_VISITOR, p));
}
示例3: asTypeVariable
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Returns a {@link TypeVariable} if the {@link TypeMirror} represents a type variable
* or throws an {@link IllegalArgumentException}.
*/
public static TypeVariable asTypeVariable(TypeMirror maybeTypeVariable) {
return maybeTypeVariable.accept(new CastingTypeVisitor<TypeVariable>() {
@Override
public TypeVariable visitTypeVariable(TypeVariable type, String p) {
return type;
}
}, "type variable");
}
示例4: asExecutable
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Returns a {@link ExecutableType} if the {@link TypeMirror} represents an executable type such
* as a method, constructor, or initializer or throws an {@link IllegalArgumentException}.
*/
public static ExecutableType asExecutable(TypeMirror maybeExecutableType) {
return maybeExecutableType.accept(new CastingTypeVisitor<ExecutableType>() {
@Override
public ExecutableType visitExecutable(ExecutableType type, String p) {
return type;
}
}, "executable type");
}
示例5: asNoType
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Returns a {@link NoType} if the {@link TypeMirror} represents an non-type such
* as void, or package, etc. or throws an {@link IllegalArgumentException}.
*/
public static NoType asNoType(TypeMirror maybeNoType) {
return maybeNoType.accept(new CastingTypeVisitor<NoType>() {
@Override
public NoType visitNoType(NoType noType, String p) {
return noType;
}
}, "non-type");
}
示例6: getGenericType
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Return the generic type if any
*/
public TypeElement getGenericType(TypeMirror typeMirror) {
return typeMirror.accept(new SimpleTypeVisitor6<TypeElement, Void>() {
@Override
public TypeElement visitDeclared(DeclaredType declaredType, Void v) {
TypeElement genericTypeElement = null;
TypeElement typeElement = (TypeElement) declaredType.asElement();
if (parcelClass != null && typeUtils.isAssignable(typeElement.asType(), listTypeMirror)) {
List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
if (!typeArguments.isEmpty()) {
for (TypeMirror genericType : typeArguments) {
if (genericType instanceof WildcardType) {
WildcardType wildcardType = (WildcardType) genericType;
TypeMirror extendsType = wildcardType.getExtendsBound();
if (extendsType != null) {
typeElement = elementUtils.getTypeElement(extendsType.toString());
if (typeElement.getAnnotation(parcelClass) != null) {
genericTypeElement = typeElement;
break;
}
}
} else {
typeElement = elementUtils.getTypeElement(genericType.toString());
if (typeElement.getAnnotation(parcelClass) != null) {
genericTypeElement = typeElement;
break;
}
}
}
}
}
return genericTypeElement;
}
}, null);
}
示例7: appendTypeParameterWithBounds
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private void appendTypeParameterWithBounds(StringBuilder sb, TypeParameterElement typeParameter) {
sb.append(typeParameter.getSimpleName());
String sep = " extends ";
for (TypeMirror bound : typeParameter.getBounds()) {
if (!bound.toString().equals("java.lang.Object")) {
sb.append(sep);
sep = " & ";
bound.accept(toStringTypeVisitor, sb);
}
}
}
示例8: visitTypeVariable
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
@Override
public Integer visitTypeVariable(TypeVariable t, Set<Element> visiting) {
int result = hashKind(HASH_SEED, t);
result *= HASH_MULTIPLIER;
result += t.getLowerBound().accept(this, visiting);
TypeParameterElement element = (TypeParameterElement) t.asElement();
for (TypeMirror bound : element.getBounds()) {
result *= HASH_MULTIPLIER;
result += bound.accept(this, visiting);
}
return result;
}
示例9: asArray
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Returns a {@link ArrayType} if the {@link TypeMirror} represents a primitive array or
* throws an {@link IllegalArgumentException}.
*/
public static ArrayType asArray(TypeMirror maybeArrayType) {
return maybeArrayType.accept(new CastingTypeVisitor<ArrayType>() {
@Override
public ArrayType visitArray(ArrayType type, String ignore) {
return type;
}
}, "primitive array");
}
示例10: asPrimitiveType
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Returns a {@link PrimitiveType} if the {@link TypeMirror} represents a primitive type
* or throws an {@link IllegalArgumentException}.
*/
public static PrimitiveType asPrimitiveType(TypeMirror maybePrimitiveType) {
return maybePrimitiveType.accept(new CastingTypeVisitor<PrimitiveType>() {
@Override
public PrimitiveType visitPrimitive(PrimitiveType type, String p) {
return type;
}
}, "primitive type");
}
示例11: asError
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
* Returns a {@link ExecutableType} if the {@link TypeMirror} represents an executable type such
* as may result from missing code, or bad compiles or throws an {@link IllegalArgumentException}.
*/
public static ErrorType asError(TypeMirror maybeErrorType) {
return maybeErrorType.accept(new CastingTypeVisitor<ErrorType>() {
@Override
public ErrorType visitError(ErrorType type, String p) {
return type;
}
}, "error type");
}
示例12: get
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
Type get(TypeMirror type) {
return type.accept(converter, parameters);
}
示例13: visitWildcard
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
public Boolean visitWildcard(WildcardType wild, Void arg1) {
TypeMirror eb = wild.getExtendsBound();
TypeMirror sb = wild.getSuperBound();
return (eb != null && eb.accept(this, arg1)) ||
(sb != null && sb.accept(this, arg1));
}
示例14: getType
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private static String getType(ExecutableElement getterElement) throws ModelException {
TypeMirror type = getterElement.getReturnType();
if (!type.accept(checkGetterTypeVisitor, true))
throw new ModelException("illegal parameter type: " + type.toString());
return type.toString();
}
示例15: isLegalMethod
import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
protected boolean isLegalMethod(ExecutableElement method, TypeElement typeElement) {
WebMethod webMethod = method.getAnnotation(WebMethod.class);
//SEI cannot have methods with @WebMethod(exclude=true)
if (typeElement.getKind().equals(ElementKind.INTERFACE) && webMethod != null && webMethod.exclude())
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_SEI_ANNOTATION_ELEMENT_EXCLUDE("exclude=true", typeElement.getQualifiedName(), method.toString()), method);
// With https://jax-ws.dev.java.net/issues/show_bug.cgi?id=577, hasWebMethods has no effect
if (hasWebMethods && webMethod == null) // backwards compatibility (for legacyWebMethod computation)
return true;
if ((webMethod != null) && webMethod.exclude()) {
return true;
}
/*
This check is not needed as Impl class is already checked that it is not abstract.
if (typeElement instanceof TypeElement && method.getModifiers().contains(Modifier.ABSTRACT)) { // use Kind.equals instead of instanceOf
builder.processError(method.getPosition(), WebserviceapMessages.WEBSERVICEAP_WEBSERVICE_METHOD_IS_ABSTRACT(typeElement.getQualifiedName(), method.getSimpleName()));
return false;
}
*/
TypeMirror returnType = method.getReturnType();
if (!isLegalType(returnType)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RETURN_TYPE_CANNOT_IMPLEMENT_REMOTE(typeElement.getQualifiedName(),
method.getSimpleName(),
returnType), method);
}
boolean isOneWay = method.getAnnotation(Oneway.class) != null;
if (isOneWay && !isValidOneWayMethod(method, typeElement))
return false;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style().equals(SOAPBinding.Style.RPC)) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_RPC_SOAPBINDING_NOT_ALLOWED_ON_METHOD(typeElement.getQualifiedName(), method.toString()), method);
}
}
int paramIndex = 0;
for (VariableElement parameter : method.getParameters()) {
if (!isLegalParameter(parameter, method, typeElement, paramIndex++))
return false;
}
if (!isDocLitWrapped() && soapStyle.equals(SOAPStyle.DOCUMENT)) {
VariableElement outParam = getOutParameter(method);
int inParams = getModeParameterCount(method, WebParam.Mode.IN);
int outParams = getModeParameterCount(method, WebParam.Mode.OUT);
if (inParams != 1) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_AND_NO_ONE_IN(typeElement.getQualifiedName(), method.toString()), method);
}
if (returnType.accept(NO_TYPE_VISITOR, null)) {
if (outParam == null && !isOneWay) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
if (outParams != 1) {
if (!isOneWay && outParams != 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_NO_RETURN_AND_NO_OUT(typeElement.getQualifiedName(), method.toString()), method);
}
} else {
if (outParams > 0) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_DOC_BARE_RETURN_AND_OUT(typeElement.getQualifiedName(), method.toString()), outParam);
}
}
}
return true;
}