当前位置: 首页>>代码示例>>Java>>正文


Java MoreTypes.asDeclared方法代码示例

本文整理汇总了Java中com.google.auto.common.MoreTypes.asDeclared方法的典型用法代码示例。如果您正苦于以下问题:Java MoreTypes.asDeclared方法的具体用法?Java MoreTypes.asDeclared怎么用?Java MoreTypes.asDeclared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.auto.common.MoreTypes的用法示例。


在下文中一共展示了MoreTypes.asDeclared方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReducerSuperInterface

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
public static DeclaredType getReducerSuperInterface(DeclaredType reducerType) {
    List<? extends TypeMirror> supertypes = MoreTypes.asTypeElement(reducerType).getInterfaces();

    for (TypeMirror supertype : supertypes) {
        boolean isReducer = MoreTypes.isTypeOf(Reducer.class, supertype);
        if (isReducer) {
            return MoreTypes.asDeclared(supertype);
        }
    }

    TypeMirror superclass = MoreTypes.asTypeElement(reducerType).getSuperclass();
    if (!MoreTypes.isTypeOf(Object.class, superclass)) {
        return getReducerSuperInterface(MoreTypes.asDeclared(superclass));
    }

    return null;
}
 
开发者ID:Yarikx,项目名称:reductor,代码行数:18,代码来源:Utils.java

示例2: typeAnnotationTargets

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static ImmutableSet<TypeElement> typeAnnotationTargets(final Descriptor descriptor, final TypeElement element) {
	final AnnotationMirror descriptorMirror = descriptorMirror(descriptor, element);
	final AnnotationValue classes = AnnotationMirrors.getAnnotationValue(descriptorMirror, "copyTypeAnnotationsTo");
	final ImmutableSet.Builder<TypeElement> builder = ImmutableSet.builder();

	for (final AnnotationValue value: (List<? extends AnnotationValue>)classes) {
		final DeclaredType declared = MoreTypes.asDeclared((TypeMirror)value);
		builder.add(MoreElements.asType(declared.asElement()));
	}

	return builder.build();
}
 
开发者ID:FermioCloud,项目名称:java-code-templates,代码行数:14,代码来源:Util.java

示例3: getDeclaredType

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
public static DeclaredType getDeclaredType(DeclaredType baseDt, TypeElement intf, TypeElement bind, ProcessingEnvironment env) {
    TypeMirror[] params = new TypeMirror[intf.getTypeParameters().size()];

    for (int i = 0; i < params.length; i++) {
        TypeParameterElement parameterElement = intf.getTypeParameters().get(i);

        params[i] = env.getTypeUtils().asMemberOf(baseDt, parameterElement);
    }

    try {
        return env.getTypeUtils().getDeclaredType(bind, params);
    } catch (IllegalArgumentException e) {
        return MoreTypes.asDeclared(bind.asType());
    }
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:16,代码来源:Util.java

示例4: processInterfaceElements

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
private static void processInterfaceElements(List<ExecutableElement> elementsFromInterface,
                                             List<ExecutableElement> elementsFromBind,
                                             TypeElement baseIntf,
                                             TypeElement concreteIntf,
                                             TypeElement bind,
                                             Map<IExecutableElementContainer, List<ITypeElementPairContainer>> map,
                                             boolean intfInjected,
                                             ProcessingEnvironment env) {
    DeclaredType baseDt = MoreTypes.asDeclared(baseIntf.asType());
    for (ExecutableElement method : elementsFromInterface) {
        ExecutableElementContainer container = new ExecutableElementContainer(method, baseDt, env);
        IRelationShipResult result = findRelation(method, elementsFromBind, bind, false, env);

        if (result.isDuplicateFound()) {
            TypeElementPairContainer typeElementPairContainer = new TypeElementPairContainer(concreteIntf, bind, baseDt);
            typeElementPairContainer.setAbstract(result.getRelationShip() == ExecutableRelationShip.Same
                    || result.getRelationShip() == ExecutableRelationShip.OverridingAbstract);
            typeElementPairContainer.setFinal(isFinal(bind));
            typeElementPairContainer.setUseInjection(intfInjected);
            typeElementPairContainer.setRelationShip(result.getRelationShip());

            addValueToMapList(container, (ITypeElementPairContainer) typeElementPairContainer, map);
        } else {
            addValueToMapList(container, null, map);
        }

        // interface's methods should not be redefined
        container.setRedefinitionRequired(false);
    }
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:31,代码来源:TypeElementUtils.java

示例5: processBindElements

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
private static void processBindElements(List<ExecutableElement> elementsFromInterface,
                                        List<ExecutableElement> elementsFromBind,
                                        TypeElement baseIntf,
                                        TypeElement concreteIntf,
                                        TypeElement bind,
                                        Map<IExecutableElementContainer, List<ITypeElementPairContainer>> map,
                                        boolean intfInjected,
                                        ProcessingEnvironment env) {
    DeclaredType baseDt = MoreTypes.asDeclared(baseIntf.asType());
    DeclaredType concreteDt = Util.getDeclaredType(baseDt, concreteIntf, bind, env);

    for (ExecutableElement method : elementsFromBind) {
        ExecutableElementContainer container = new ExecutableElementContainer(method, concreteDt, env);
        IRelationShipResult result = findRelation(method, elementsFromInterface, baseIntf, true, env);

        if (!result.isDuplicateFound()) {
            TypeElementPairContainer typeElementPairContainer = new TypeElementPairContainer(concreteIntf, bind, concreteDt);
            typeElementPairContainer.setAbstract(isAbstract(method)
                    || result.getRelationShip() == ExecutableRelationShip.Same);
            typeElementPairContainer.setFinal(isFinal(bind));
            typeElementPairContainer.setUseInjection(intfInjected);
            typeElementPairContainer.setRelationShip(result.getRelationShip());

            addValueToMapList(container, (ITypeElementPairContainer) typeElementPairContainer, map);
        }

        // Redefine only if no duplicates found
        container.setRedefinitionRequired(!result.isDuplicateFound());
    }
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:31,代码来源:TypeElementUtils.java

示例6: toBuilderMethods

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
/**
 * Finds any methods in the set that return the builder type. If the builder has type parameters
 * {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
 * the same parameter names. We enforce elsewhere that the names and bounds of the builder
 * parameters must be the same as those of the @RetroFacebook class. Here's a correct example:
 * <pre>
 * {@code @RetroFacebook abstract class Foo<A extends Number, B> {
 *   abstract int someProperty();
 *
 *   abstract Builder<A, B> toBuilder();
 *
 *   interface Builder<A extends Number, B> {...}
 * }}
 * </pre>
 * <p/>
 * <p>We currently impose that there cannot be more than one such method.</p>
 */
ImmutableSet<ExecutableElement> toBuilderMethods(
    Types typeUtils, Set<ExecutableElement> abstractMethods) {

  ImmutableList<String> builderTypeParamNames =
      FluentIterable.from(builderTypeElement.getTypeParameters())
          .transform(SimpleNameFunction.INSTANCE)
          .toList();

  ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
  for (ExecutableElement method : abstractMethods) {
    if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
      methods.add(method);
      DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
      ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
      for (TypeMirror typeArgument : returnType.getTypeArguments()) {
        if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
          typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
        }
      }
      if (!builderTypeParamNames.equals(typeArguments.build())) {
        errorReporter.reportError(
            "Builder converter method should return "
                + builderTypeElement
                + TypeSimplifier.actualTypeParametersString(builderTypeElement),
            method);
      }
    }
  }
  ImmutableSet<ExecutableElement> builderMethods = methods.build();
  if (builderMethods.size() > 1) {
    errorReporter.reportError(
        "There can be at most one builder converter method", builderMethods.iterator().next());
  }
  return builderMethods;
}
 
开发者ID:yongjhih,项目名称:RetroFacebook,代码行数:53,代码来源:BuilderSpec.java

示例7: constructor

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
private MethodSpec constructor(Context context) {
  Types types = context.processingEnvironment().getTypeUtils();
  DeclaredType declaredValueType = MoreTypes.asDeclared(context.autoValueClass().asType());

  ImmutableList.Builder<ParameterSpec> parameterBuilder = ImmutableList.builder();
  for (Map.Entry<String, ExecutableElement> entry : context.properties().entrySet()) {
    ExecutableType resolvedExecutableType =
        MoreTypes.asExecutable(types.asMemberOf(declaredValueType, entry.getValue()));
    TypeName typeName = TypeName.get(resolvedExecutableType.getReturnType());
    ParameterSpec.Builder spec = ParameterSpec.builder(typeName, entry.getKey());
    AnnotationMirror nullableAnnotation =
        Utils.getAnnotationWithSimpleName(entry.getValue(), NULLABLE_ANNOTATION_NAME);
    if (nullableAnnotation != null) {
      spec.addAnnotation(AnnotationSpec.get(nullableAnnotation));
    }
    parameterBuilder.add(spec.build());
  }

  ImmutableList<ParameterSpec> parameters = parameterBuilder.build();
  CodeBlock parameterList = CodeBlocks.join(FluentIterable.from(parameters)
      .transform(new Function<ParameterSpec, CodeBlock>() {
        @Override public CodeBlock apply(ParameterSpec parameterSpec) {
          return CodeBlock.of("$N", parameterSpec.name);
        }
      }), ", ");

  return MethodSpec.constructorBuilder()
      .addParameters(parameters)
      .addStatement("super($L)", parameterList)
      .build();
}
 
开发者ID:grandstaish,项目名称:paperparcel,代码行数:32,代码来源:PaperParcelAutoValueExtension.java

示例8: toBuilderMethods

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
/**
 * Finds any methods in the set that return the builder type. If the builder has type parameters
 * {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
 * the same parameter names. We enforce elsewhere that the names and bounds of the builder
 * parameters must be the same as those of the @AutoCursor class. Here's a correct example:
 * <pre>
 * {@code @AutoCursor abstract class Foo<A extends Number, B> {
 *   abstract int someProperty();
 *
 *   abstract Builder<A, B> toBuilder();
 *
 *   interface Builder<A extends Number, B> {...}
 * }}
 * </pre>
 * <p/>
 * <p>We currently impose that there cannot be more than one such method.</p>
 */
ImmutableSet<ExecutableElement> toBuilderMethods(
    Types typeUtils, Set<ExecutableElement> abstractMethods) {

  ImmutableList<String> builderTypeParamNames =
      FluentIterable.from(builderTypeElement.getTypeParameters())
          .transform(SimpleNameFunction.INSTANCE)
          .toList();

  ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
  for (ExecutableElement method : abstractMethods) {
    if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
      methods.add(method);
      DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
      ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
      for (TypeMirror typeArgument : returnType.getTypeArguments()) {
        if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
          typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
        }
      }
      if (!builderTypeParamNames.equals(typeArguments.build())) {
        errorReporter.reportError(
            "Builder converter method should return "
                + builderTypeElement
                + TypeSimplifier.actualTypeParametersString(builderTypeElement),
            method);
      }
    }
  }
  ImmutableSet<ExecutableElement> builderMethods = methods.build();
  if (builderMethods.size() > 1) {
    errorReporter.reportError(
        "There can be at most one builder converter method", builderMethods.iterator().next());
  }
  return builderMethods;
}
 
开发者ID:yongjhih,项目名称:AutoCursor,代码行数:53,代码来源:BuilderSpec.java

示例9: toBuilderMethods

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
/**
 * Finds any methods in the set that return the builder type. If the builder has type parameters
 * {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
 * the same parameter names. We enforce elsewhere that the names and bounds of the builder
 * parameters must be the same as those of the @Retrofit class. Here's a correct example:
 * <pre>
 * {@code @Retrofit abstract class Foo<A extends Number, B> {
 *   abstract int someProperty();
 *
 *   abstract Builder<A, B> toBuilder();
 *
 *   interface Builder<A extends Number, B> {...}
 * }}
 * </pre>
 * <p/>
 * <p>We currently impose that there cannot be more than one such method.</p>
 */
ImmutableSet<ExecutableElement> toBuilderMethods(
    Types typeUtils, Set<ExecutableElement> abstractMethods) {

  ImmutableList<String> builderTypeParamNames =
      FluentIterable.from(builderTypeElement.getTypeParameters())
          .transform(SimpleNameFunction.INSTANCE)
          .toList();

  ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
  for (ExecutableElement method : abstractMethods) {
    if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
      methods.add(method);
      DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
      ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
      for (TypeMirror typeArgument : returnType.getTypeArguments()) {
        if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
          typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
        }
      }
      if (!builderTypeParamNames.equals(typeArguments.build())) {
        errorReporter.reportError(
            "Builder converter method should return "
                + builderTypeElement
                + TypeSimplifier.actualTypeParametersString(builderTypeElement),
            method);
      }
    }
  }
  ImmutableSet<ExecutableElement> builderMethods = methods.build();
  if (builderMethods.size() > 1) {
    errorReporter.reportError(
        "There can be at most one builder converter method", builderMethods.iterator().next());
  }
  return builderMethods;
}
 
开发者ID:yongjhih,项目名称:retrofit2.bak,代码行数:53,代码来源:BuilderSpec.java

示例10: toBuilderMethods

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
/**
 * Finds any methods in the set that return the builder type. If the builder has type parameters
 * {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
 * the same parameter names. We enforce elsewhere that the names and bounds of the builder
 * parameters must be the same as those of the @RetroWeibo class. Here's a correct example:
 * <pre>
 * {@code @RetroWeibo abstract class Foo<A extends Number, B> {
 *   abstract int someProperty();
 *
 *   abstract Builder<A, B> toBuilder();
 *
 *   interface Builder<A extends Number, B> {...}
 * }}
 * </pre>
 * <p/>
 * <p>We currently impose that there cannot be more than one such method.</p>
 */
ImmutableSet<ExecutableElement> toBuilderMethods(
    Types typeUtils, Set<ExecutableElement> abstractMethods) {

  ImmutableList<String> builderTypeParamNames =
      FluentIterable.from(builderTypeElement.getTypeParameters())
          .transform(SimpleNameFunction.INSTANCE)
          .toList();

  ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
  for (ExecutableElement method : abstractMethods) {
    if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
      methods.add(method);
      DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
      ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
      for (TypeMirror typeArgument : returnType.getTypeArguments()) {
        if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
          typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
        }
      }
      if (!builderTypeParamNames.equals(typeArguments.build())) {
        errorReporter.reportError(
            "Builder converter method should return "
                + builderTypeElement
                + TypeSimplifier.actualTypeParametersString(builderTypeElement),
            method);
      }
    }
  }
  ImmutableSet<ExecutableElement> builderMethods = methods.build();
  if (builderMethods.size() > 1) {
    errorReporter.reportError(
        "There can be at most one builder converter method", builderMethods.iterator().next());
  }
  return builderMethods;
}
 
开发者ID:8tory,项目名称:SimpleWeibo,代码行数:53,代码来源:BuilderSpec.java

示例11: StoreMethodModel

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
public StoreMethodModel(ExecutableElement element, StoreModel storeModel) {
    this.element = element;
    this.storeModel = storeModel;

    List<TypeName> states = FluentIterable.from(storeModel.getStoreImplModels())
            .transform(new Function<StoreImplModel, TypeName>() {
                @Override
                public TypeName apply(StoreImplModel input) {
                    return input.getState();
                }
            }).toList();

    returnType = MoreTypes.asDeclared(element.getReturnType());

    if (states.contains(ClassName.get(returnType))) {
        kind = Kind.GETTER;
        isBindable = element.getAnnotation(Bindable.class) != null;
    } else if (getName().equals(DispatcherModel.DISPATCH_METHOD_NAME)) {
        kind = Kind.DISPATCH;
    } else if (MoreTypes.isTypeOf(OBSERVE_METHOD_CLASS, returnType.asElement().asType())
            && states.contains(ClassName.get(returnType.getTypeArguments().get(0)))) {
        if (element.getParameters() != null
                && !element.getParameters().isEmpty()
                && MoreTypes.isTypeOf(BACKPRESSURE_STRATEGY_PARAM_CLASS, element.getParameters().get(0).asType())) {
            bpsParamName = element.getParameters().get(0).getSimpleName().toString();
            kind = Kind.OBSERVE_WITH_BPS;
        } else {
            kind = Kind.OBSERVE;
        }
    } else {
        kind = Kind.UNKNOWN;
    }
}
 
开发者ID:izumin5210,项目名称:Droidux,代码行数:34,代码来源:StoreMethodModel.java

示例12: toBuilderMethods

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
/**
 * Finds any methods in the set that return the builder type. If the builder has type parameters
 * {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
 * the same parameter names. We enforce elsewhere that the names and bounds of the builder
 * parameters must be the same as those of the @AutoJson class. Here's a correct example:
 * <pre>
 * {@code @AutoJson abstract class Foo<A extends Number, B> {
 *   abstract int someProperty();
 *
 *   abstract Builder<A, B> toBuilder();
 *
 *   interface Builder<A extends Number, B> {...}
 * }}
 * </pre>
 * <p/>
 * <p>We currently impose that there cannot be more than one such method.</p>
 */
ImmutableSet<ExecutableElement> toBuilderMethods(
    Types typeUtils, Set<ExecutableElement> abstractMethods) {

  ImmutableList<String> builderTypeParamNames =
      FluentIterable.from(builderTypeElement.getTypeParameters())
          .transform(SimpleNameFunction.INSTANCE)
          .toList();

  ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
  for (ExecutableElement method : abstractMethods) {
    if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
      methods.add(method);
      DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
      ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
      for (TypeMirror typeArgument : returnType.getTypeArguments()) {
        if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
          typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
        }
      }
      if (!builderTypeParamNames.equals(typeArguments.build())) {
        errorReporter.reportError(
            "Builder converter method should return "
                + builderTypeElement
                + TypeSimplifier.actualTypeParametersString(builderTypeElement),
            method);
      }
    }
  }
  ImmutableSet<ExecutableElement> builderMethods = methods.build();
  if (builderMethods.size() > 1) {
    errorReporter.reportError(
        "There can be at most one builder converter method", builderMethods.iterator().next());
  }
  return builderMethods;
}
 
开发者ID:yongjhih,项目名称:AutoJson,代码行数:53,代码来源:BuilderSpec.java

示例13: create

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
static AutoHttpDescriptor create(
    TypeElement validTypeElement,
    ImmutableList<ExecutableElement> validMethodElements) throws ClassNotFoundException {

  ImmutableList.Builder<MethodDescriptor> methodDescriptorBuilder = ImmutableList.builder();
  for (ExecutableElement methodElement : validMethodElements) {
    TypeMirror returnTypeMirror = methodElement.getReturnType();

    DeclaredType declaredType = MoreTypes.asDeclared(returnTypeMirror);
    Class<?> returnType =
        Class.forName(declaredType.asElement().toString());

    List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
    Class<?>[] returnTypeArguments = new Class<?>[typeArguments.size()];
    for (int i = 0; i < returnTypeArguments.length; i++) {
      returnTypeArguments[i] =
          Class.forName(MoreTypes.asDeclared(typeArguments.get(i)).toString());
    }

    Class<?> converterType = null;
    Class<?>[] converterTypeArguments = null;
    if (returnTypeArguments.length > 0) {
      converterType = returnTypeArguments[0];
    }

    if (returnTypeArguments.length > 1) {
      converterTypeArguments = Arrays.copyOfRange(returnTypeArguments, 1, returnTypeArguments.length);
    } else {
      converterTypeArguments = new Class[0];
    }


    MethodDescriptor methodDescriptor =
        new AutoValue_AutoHttpDescriptor_MethodDescriptor(
            methodElement,
            TypeName.get(returnTypeMirror),
            returnType,
            ImmutableList.copyOf(returnTypeArguments),
            converterType,
            ImmutableList.copyOf(converterTypeArguments)
        );
    methodDescriptorBuilder.add(methodDescriptor);
  }

  return new AutoValue_AutoHttpDescriptor(
      validTypeElement,
      methodDescriptorBuilder.build());
}
 
开发者ID:BiaoWu,项目名称:AutoHttp,代码行数:49,代码来源:AutoHttpDescriptor.java

示例14: isValidFieldType

import com.google.auto.common.MoreTypes; //导入方法依赖的package包/类
private boolean isValidFieldType(TypeMirror fieldType) {
    switch (fieldType.getKind()) {
        // These primitive types are valid immediately.
        case BOOLEAN:
        case DOUBLE:
        case FLOAT:
        case INT:
        case LONG:
        case SHORT:
            return true;
        // For declared, we need to do a bit of extra work.
        case DECLARED:
            try {
                // If it's a boxed primitive, other than byte or char, return true.
                TypeName typeName = TypeName.get(fieldType).unbox();
                if (typeName.equals(TypeName.BYTE) || typeName.equals(TypeName.CHAR)) return false;
                if (typeName.isPrimitive()) return true;
            } catch (UnsupportedOperationException e) {
                // Do nothing, we just did this to try and check if this was a boxed primitive.
            }

            // Strings and java.util.Dates are okay.
            DeclaredType declaredType = MoreTypes.asDeclared(fieldType);
            if (MoreTypes.isTypeOf(String.class, declaredType) || MoreTypes.isTypeOf(Date.class, declaredType))
                return true;

            // Any of our classes annotated with @RealmClass are okay.
            if (Utils.isSubtypeOfType(fieldType, TypeNames.REALM_MODEL.toString())) return true;

            // RealmLists are okay as well.
            TypeName fieldTypeName = TypeName.get(fieldType);
            if (isRealmList(fieldTypeName)) return true;

            // Everything else is bad.
            return false;
        // We ignore these types.
        case ARRAY:
        case BYTE:
        case CHAR:
        case ERROR:
        case EXECUTABLE:
        case NONE:
        case NULL:
        case OTHER:
        case PACKAGE:
        case TYPEVAR:
        case UNION:
        case VOID:
        case WILDCARD:
        default:
            return false;
    }
}
 
开发者ID:bkromhout,项目名称:Ruqus,代码行数:54,代码来源:ClassDataBuilder.java


注:本文中的com.google.auto.common.MoreTypes.asDeclared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。