當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleTypeVisitor6類代碼示例

本文整理匯總了Java中javax.lang.model.util.SimpleTypeVisitor6的典型用法代碼示例。如果您正苦於以下問題:Java SimpleTypeVisitor6類的具體用法?Java SimpleTypeVisitor6怎麽用?Java SimpleTypeVisitor6使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleTypeVisitor6類屬於javax.lang.model.util包,在下文中一共展示了SimpleTypeVisitor6類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTypeArgument

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的package包/類
@Nullable
private TypeMirror getTypeArgument(TypeMirror annotatedType, final TypeElement baseType) {
  for (TypeMirror type : getAllTypes(annotatedType)) {
    TypeMirror typeArgument = type.accept(new SimpleTypeVisitor6<TypeMirror, Void>() {
      @Override public TypeMirror visitDeclared(DeclaredType t, Void aVoid) {
        if (isAssignable(t, baseType)) {
          List<? extends TypeMirror> typeArguments = t.getTypeArguments();
          if (!typeArguments.isEmpty()) {
            return typeUtils.erasure(typeArguments.get(0));
          }
        }
        return null;
      }
    }, null);

    if (typeArgument != null) {
      return typeArgument;
    }
  }
  error("Failed to find a type argument for %s in %s", baseType, annotatedType);
  return null;
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:23,代碼來源:CmdLineProcessor.java

示例2: asDeclaredType

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的package包/類
private static DeclaredType asDeclaredType(TypeMirror type) {
    return type.accept(new SimpleTypeVisitor6<DeclaredType, Object>() {
        @Override
        public DeclaredType visitDeclared(DeclaredType t, Object o) {
            return t;
        }
    }, null);
}
 
開發者ID:evant,項目名稱:gsonvalue,代碼行數:9,代碼來源:GsonValueProcessor.java

示例3: isValidMap

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的package包/類
/**
 * Maps can only have String keys and Parcelable values.
 */
private static boolean isValidMap(Types types, TypeMirror type) {
  return type.accept(new SimpleTypeVisitor6<Boolean, Types>() {
    @Override public Boolean visitDeclared(DeclaredType t, Types o) {
      List<? extends TypeMirror> args = t.getTypeArguments();
      if (args.size() == 2) {
        TypeMirror key = args.get(0);
        TypeMirror value = args.get(1);
        if (STRING.equals(TypeName.get(key)) && isValidType(o, value)) {
          return true;
        }
      }
      return false;
    }
  }, types);
}
 
開發者ID:rharter,項目名稱:auto-value-parcel,代碼行數:19,代碼來源:Parcelables.java

示例4: getGenericType

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的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);
}
 
開發者ID:josesamuel,項目名稱:remoter,代碼行數:39,代碼來源:BindingManager.java

示例5: extractGetIfList

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的package包/類
String extractGetIfList(TypeMirror typeMirror) {
    String name = typeMirror.toString();
    if (name.startsWith("java.util.List")) {
        //check type
        DeclaredType declaredType = typeMirror.accept(new SimpleTypeVisitor6<DeclaredType, String>() {
            @Override
            public DeclaredType visitDeclared(DeclaredType t, String s) {
                return t;
            }
        }, name);
        if (declaredType == null) {
            return null;
        }
        List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
        if (typeArguments.isEmpty()) {
            return null;
        }
        TypeMirror typeParameter = typeArguments.get(0);
        switch (MirrorUtils.flattenArrayListType(environment, typeParameter)) {
            case "java.lang.Integer":
                return "args.getIntegerArrayList($S)";
            case "java.lang.String":
                return "args.getStringArrayList($S)";
            case "java.lang.CharSequence":
                return "args.getCharSequenceArrayList($S)";
            case "android.os.Parcelable":
                return "args.getParcelableArrayList($S)";
        }
    }
    return null;
}
 
開發者ID:sys1yagi,項目名稱:fragment-creator,代碼行數:32,代碼來源:FragmentCreatorReadGenerator.java

示例6: extractPutIfList

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的package包/類
String extractPutIfList(TypeMirror typeMirror) {
    String name = typeMirror.toString();
    if (name.startsWith("java.util.List")) {
        //check type
        DeclaredType declaredType = typeMirror.accept(new SimpleTypeVisitor6<DeclaredType, String>() {
            @Override
            public DeclaredType visitDeclared(DeclaredType t, String s) {
                return t;
            }
        }, name);
        if (declaredType == null) {
            return null;
        }
        List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
        if (typeArguments.isEmpty()) {
            return null;
        }
        TypeMirror typeParameter = typeArguments.get(0);
        switch (MirrorUtils.flattenArrayListType(environment, typeParameter)) {
            case "java.lang.Integer":
                return "args.putIntegerArrayList($S,";
            case "java.lang.String":
                return "args.putStringArrayList($S,";
            case "java.lang.CharSequence":
                return "args.putCharSequenceArrayList($S,";
            case "android.os.Parcelable":
                return "args.putParcelableArrayList($S,";
        }
    }
    return null;
}
 
開發者ID:sys1yagi,項目名稱:fragment-creator,代碼行數:32,代碼來源:FragmentCreatorBuilderGenerator.java

示例7: TypeMirrorToDAInterfaceWithGeneric

import javax.lang.model.util.SimpleTypeVisitor6; //導入依賴的package包/類
public TypeMirrorToDAInterfaceWithGeneric(final JavaxExtractor javaxExtractor, final GenericTypeContext genericTypeContext) {
  this.daInterfaceExtractor = new SimpleTypeVisitor6<DAInterface, Void>() {

    @Override
    public DAInterface visitDeclared(DeclaredType declaredType, Void aVoid) {
      return new DAInterfaceImpl(javaxExtractor.extractType(declaredType, genericTypeContext));
    }
  };
}
 
開發者ID:lesaint,項目名稱:damapping,代碼行數:10,代碼來源:JavaxParsingServiceImpl.java


注:本文中的javax.lang.model.util.SimpleTypeVisitor6類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。