javax.lang.model.util.Types.getArrayType()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中javax.lang.model.util.Types.getArrayType()方法的一些代码示例,展示了Types.getArrayType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.getArrayType()方法的具体详情如下:
包路径:javax.lang.model.util.Types
类名称:Types
方法名:getArrayType

Types.getArrayType介绍

[英]Returns an array type with the specified component type.
[中]返回具有指定组件类型的数组类型。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util-lookup

continue;
ArrayType arrStringType = processingEnv.getTypeUtils().getArrayType(stringType);
if (processingEnv.getTypeUtils().isAssignable(toCheck, arrStringType)) {
  continue;

代码示例来源:origin: hibernate/hibernate-validator

/**
 * Returns a TypeMirror for the given class.
 *
 * @param clazz The class of interest.
 *
 * @return A TypeMirror for the given class.
 */
public TypeMirror getMirrorForType(Class<?> clazz) {
  if ( clazz.isArray() ) {
    return typeUtils.getArrayType( getMirrorForNonArrayType( clazz.getComponentType() ) );
  }
  else {
    return getMirrorForNonArrayType( clazz );
  }
}

代码示例来源:origin: inferred/FreeBuilder

private static boolean hasBuilderVarargsAddMethodOverride(Config config, Type builderType) {
  TypeMirror rawBuilderType = config.getElements()
    .getTypeElement(builderType.getQualifiedName().toString())
    .asType();
  return overrides(
    config.getBuilder(),
    config.getTypes(),
    addMethod(config.getProperty()),
    config.getTypes().getArrayType(rawBuilderType));
 }
}

代码示例来源:origin: inferred/FreeBuilder

/** Returns a {@link TypeMirror} for the given class (raw T, not T&lt;?&gt;, if T is generic). */
public static TypeMirror typeMirror(
  Types typeUtils,
  Elements elementUtils,
  Class<?> cls) {
 if (cls.equals(void.class)) {
  return typeUtils.getNoType(TypeKind.VOID);
 } else if (cls.isPrimitive()) {
  return typeUtils.getPrimitiveType(TypeKind.valueOf(cls.getSimpleName().toUpperCase()));
 } else if (cls.isArray()) {
  return typeUtils.getArrayType(typeMirror(typeUtils, elementUtils, cls.getComponentType()));
 } else {
  return rawType(typeUtils, elementUtils, cls.getCanonicalName());
 }
}

代码示例来源:origin: inferred/FreeBuilder

private static boolean hasVarargsAddMethodOverride(Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: inferred/FreeBuilder

private static boolean hasVarargsAddMethodOverride(Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: inferred/FreeBuilder

private static boolean hasVarargsAddMethodOverride(Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: inferred/FreeBuilder

private static boolean hasValueInstanceVarargsAddMethodOverride(
  Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: inferred/FreeBuilder

private static boolean hasVarargsAddMethodOverride(Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: inferred/FreeBuilder

/**
 * Evaluate generics and arrays depth-first, and substitute %d strings in their place.
 *   e.g.  %1<%2,%3<%4>>  -->  %1<%2,%5>  -->  %6
 */
private static void substituteGenericsAndArrays(
  Types typeUtils,
  MutableString snippet,
  Substitutions substitutions) {
 for (MatchResult m : snippet.instancesOf(GENERIC_OR_ARRAY_PATTERN)) {
  // Group 1 is the type on the left, e.g. '%1' in '%1<%2,%5>'
  // Group 2 contains the array brackets if this is an array, e.g. '[]' in '%1[]'
  // Group 3 contains the type list if this is a generic type, e.g. '%2,%5' in '%1<%2,%5>'
  TypeMirror type = substitutions.get(m.group(1));
  if (Strings.isNullOrEmpty(m.group(2))) {
   List<TypeMirror> argTypes = Lists.transform(
     Splitter.on(",").trimResults().splitToList(m.group(3)),
     substitutions.asFunction());
   snippet.replace(m, substitutions.put(parameterisedType(typeUtils, type, argTypes)));
  } else {
   snippet.replace(m, substitutions.put(typeUtils.getArrayType(type)));
  }
 }
}

代码示例来源:origin: inferred/FreeBuilder

} else if (type instanceof GenericArrayType) {
 Type componentType = ((GenericArrayType) type).getGenericComponentType();
 return typeUtils.getArrayType(typeMirror(typeUtils, elementUtils, componentType));
} else if (type instanceof ParameterizedType) {
 ParameterizedType pType = (ParameterizedType) type;

代码示例来源:origin: br.com.objectos/code-apt

@Override
public TypeMirror get(Elements elements, Types types) {
 Class<?> componentType = type.getComponentType();
 TypeMirror component = TypeMirrorGetter.of(componentType).get(elements, types);
 return types.getArrayType(component);
}

代码示例来源:origin: br.com.objectos.code/apt

@Override
public TypeMirror get(Elements elements, Types types) {
 Class<?> componentType = type.getComponentType();
 TypeMirror component = TypeMirrorGetter.of(componentType).get(elements, types);
 return types.getArrayType(component);
}

代码示例来源:origin: stoicflame/enunciate

public ArrayType getArrayType(TypeMirror componentType) {
 while (componentType instanceof DecoratedTypeMirror) {
  componentType = ((DecoratedTypeMirror) componentType).getDelegate();
 }
 return TypeMirrorDecorator.decorate(delegate.getArrayType(componentType), this.env);
}

代码示例来源:origin: com.google.auto/auto-common

@Override
 public TypeMirror visitArray(ArrayType t, Void p) {
  return typeUtils.getArrayType(visit(t.getComponentType()));
 }
}

代码示例来源:origin: com.webcohesion.enunciate/enunciate-javac-support

public ArrayType getArrayType(TypeMirror componentType) {
 while (componentType instanceof DecoratedTypeMirror) {
  componentType = ((DecoratedTypeMirror) componentType).getDelegate();
 }
 return TypeMirrorDecorator.decorate(delegate.getArrayType(componentType), this.env);
}

代码示例来源:origin: org.inferred/freebuilder

private static boolean hasVarargsAddMethodOverride(Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: org.inferred/freebuilder

private static boolean hasVarargsAddMethodOverride(Config config, TypeMirror elementType) {
 return overrides(
   config.getBuilder(),
   config.getTypes(),
   addMethod(config.getProperty()),
   config.getTypes().getArrayType(elementType));
}

代码示例来源:origin: com.oracle/truffle-dsl-processor

private Element createGetSuppliedChildrenMethod() {
  ArrayType nodeArray = context.getEnvironment().getTypeUtils().getArrayType(getType(Node.class));
  CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED, FINAL), nodeArray, "getSuppliedChildren");
  method.getAnnotationMirrors().add(new CodeAnnotationMirror(context.getDeclaredType(Override.class)));
  CodeTreeBuilder builder = method.createBuilder();
  builder.startReturn().tree(createGetSuppliedChildren()).end();
  return method;
}

代码示例来源:origin: asakusafw/asakusafw

@Override
  protected void test() {
    TypeMirror type = types.getArrayType(getType(String.class));
    TypeDescription desc = DescriptionHelper.toDescription(env, type);
    assertThat(desc, is((Object) Descriptions.typeOf(String[].class)));
  }
});

相关文章