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


Java ArrayTypeName.of方法代码示例

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


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

示例1: genNFieldInfo

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
protected void genNFieldInfo() {
  FieldInfo dynfieldinfo, fieldinfo;
  List<long[]> finfo = new ArrayList<long[]>();
  for (String name : m_gettersinfo.keySet()) {
    dynfieldinfo = m_dynfieldsinfo.get(name);
    if (dynfieldinfo.id > 0) {
      finfo.add(new long[]{dynfieldinfo.id, dynfieldinfo.fieldoff, dynfieldinfo.fieldsize});
    }
  }

  fieldinfo = new FieldInfo();
  fieldinfo.name = String.format("m_nfieldinfo_%s", Utils.genRandomString());
  fieldinfo.type = ArrayTypeName.of(ArrayTypeName.of(TypeName.LONG));
  String initlstr = Utils.toInitLiteral(finfo);
  fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE, Modifier.STATIC)
      .initializer("$1L", initlstr);
  m_fieldsinfo.put("nfieldinfo", fieldinfo);
}
 
开发者ID:apache,项目名称:mnemonic,代码行数:19,代码来源:AnnotatedDurableEntityClass.java

示例2: buildSignature

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
@Override
MethodSpec buildSignature(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException {
    if (getRanges() != null) {
        MethodSpec.Builder setter = buildParameterlessSetterSignature(domainClazz, config);

        // Get the vararg parameter type:
        TypeName paramType = ArrayTypeName.of(getParameterType(config, false));


        return setter.addParameter(paramType, "values")
                     .varargs()
                     .build();
    } else {
        return null;
    }
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:17,代码来源:VarArgSetterSupport.java

示例3: buildProjectionField

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
private FieldSpec buildProjectionField() {
    CodeBlock.Builder initializer = CodeBlock.builder();
    initializer.add("{");
    boolean first = true;
    for (RecordField field : parsed.fields) {
        if (!first) {
            initializer.add(", ");
        }
        initializer.add("$N.$L()", projectionsClass, field.name);
        first = false;
    }
    initializer.add("}");

    TypeName arrayOfStrings = ArrayTypeName.of(ClassName.get(String.class));
    return FieldSpec.builder(arrayOfStrings, "PROJECTION", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)
            .initializer(initializer.build().toString())
            .build();
}
 
开发者ID:atomicrobot,项目名称:vinyl,代码行数:19,代码来源:RecordWriter.java

示例4: getTypeNameOrArrayTypeName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
private static TypeName getTypeNameOrArrayTypeName(String name) {
    if (name.endsWith("[]")) {
        String rawName = name.substring(0, name.length() - 2);
        TypeHelper rawTypeHelper = TypeHelper.getTypeHelper(rawName);
        return ArrayTypeName.of(rawTypeHelper.getTypeName());
    } else {
        return ClassName.bestGuess(name);
    }
}
 
开发者ID:AutSoft,项目名称:AxoloTL,代码行数:10,代码来源:TypeHelper.java

示例5: createProcessEventBuilder

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
private MethodSpec.Builder createProcessEventBuilder(TypeMirror dataClass)
{
    ParameterizedTypeName targetType = ParameterizedTypeName.get(ClassName.get(Class.class), WildcardTypeName.subtypeOf(TypeName.OBJECT));
    ArrayTypeName arrTargetType = ArrayTypeName.of(targetType);
    return MethodSpec.methodBuilder("processEvent")
                     .addModifiers(Modifier.PRIVATE)
                     .addParameter(TypeName.get(dataClass), "data", Modifier.FINAL)
                     .addParameter(arrTargetType, "target", Modifier.FINAL);
}
 
开发者ID:aschattney,项目名称:annotated-mvp,代码行数:10,代码来源:AnnotationProcessor.java

示例6: asTypeName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
public TypeName asTypeName() {
  final ClassName className = ClassName.get(getTypeElement());
  if (isArrayElement) {
    return ArrayTypeName.of(className);
  }
  return className;
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:8,代码来源:ExtendedTypeElement.java

示例7: buildAnnotationImpl

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
private JavaFile buildAnnotationImpl(Class<? extends Annotation> annotationClass) {
    String aClassName = annotationClass.getName();
    MethodSpec annotationTypeMethod = MethodSpec.methodBuilder("annotationType")
        .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
        .returns(ClassName.get(java.lang.Class.class))
        .addStatement("return $L.class", aClassName)
        .build();

    TypeSpec.Builder annotationImplType = TypeSpec.classBuilder(annotationClass.getSimpleName() + "$$Impl")
        .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
        .addSuperinterface(util.getClassName(annotationClass))
        .addMethod(annotationTypeMethod);

    System.out.println("annotation methods " + annotationClass.getMethods().size());
    System.out.println("annotation fields " + annotationClass.getFields().length);
    System.out.println("annotation " + annotationClass.toString());

    for (Method method : annotationClass.getMethods()) {
        TypeName type;
        if (method.getReturnType().isArray()) {
            //important to use the component here as there is no method get(TypeName)
            //we fail to be detected as an array (see ArrayTypeName.get implementation)
            type = ArrayTypeName.of(util.getClassName(method.getReturnType().getComponentType()));
        } else {
            type = TypeName.get(method.getReturnType());
        }
        FieldSpec field = FieldSpec.builder(type, method.getName(), Modifier.PRIVATE).build();
        annotationImplType.addField(field);

        MethodSpec setterMethod = createSetterMethod(type, method.getName());
        annotationImplType.addMethod(setterMethod);
        MethodSpec getterMethod = createGetterMethod(type, method.getName());
        annotationImplType.addMethod(getterMethod);
    }

    return JavaFile.builder(targetPackageName, annotationImplType.build()).build();
}
 
开发者ID:stephanenicolas,项目名称:reflection-no-reflection,代码行数:38,代码来源:AnnotationCreatorClassPoolVisitor.java

示例8: getClassName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
public TypeName getClassName(String className) {
    if (className.endsWith("[]")) {
        final String componentName = className.substring(0, className.lastIndexOf('['));
        return ArrayTypeName.of(getClassName(componentName));
    } else if (className.contains(".")) {
        final String packageName = className.substring(0, className.lastIndexOf('.'));
        final String simpleName = className.substring(className.lastIndexOf('.')+1);
        return ClassName.get(packageName, simpleName);
    } else {
        //for primitives
        switch (className) {
            case "short" :
                return TypeName.get(short.class);
            case "byte" :
                return TypeName.get(byte.class);
            case "int" :
                return TypeName.get(int.class);
            case "long" :
                return TypeName.get(long.class);
            case "float" :
                return TypeName.get(float.class);
            case "double" :
                return TypeName.get(double.class);
            case "boolean" :
                return TypeName.get(boolean.class);
            case "char" :
                return TypeName.get(char.class);
        }
        throw new RuntimeException("Impossible to get typename for " + className);
    }
}
 
开发者ID:stephanenicolas,项目名称:reflection-no-reflection,代码行数:32,代码来源:IntrospectorUtil.java

示例9: getTypeName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
@Override
public TypeName getTypeName() {
    return ArrayTypeName.of(arrayType.getTypeName());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:ArrayCollectionType.java

示例10: asArray

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
private ArrayTypeName asArray() {
    return ArrayTypeName.of(listElementType());
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:4,代码来源:ListSetters.java

示例11: asArrayOfModeledEnum

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
private ArrayTypeName asArrayOfModeledEnum() {
    return ArrayTypeName.of(modeledEnumElement());
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:4,代码来源:ListSetters.java

示例12: getArrayTypeName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
TypeName getArrayTypeName() {
  return ArrayTypeName.of(getTypeName());
}
 
开发者ID:ashdavies,项目名称:auto,代码行数:4,代码来源:EnrichedTypeElement.java

示例13: stringTypeToTypeName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
public static TypeName stringTypeToTypeName(String type)
{
    if (type.equals("void") || "VOID".equals(type))
        return TypeName.VOID;
    if (type.equals("boolean"))
        return TypeName.BOOLEAN;
    if (type.equals("byte"))
        return TypeName.BYTE;
    if (type.equals("short"))
        return TypeName.SHORT;
    if (type.equals("int"))
        return TypeName.INT;
    if (type.equals("long"))
        return TypeName.LONG;
    if (type.equals("char"))
        return TypeName.CHAR;
    if (type.equals("float"))
        return TypeName.FLOAT;
    if (type.equals("double"))
        return TypeName.DOUBLE;
    if (type.equals("Object") || type.equals("java.lang.Object"))
        return TypeName.OBJECT;

    if (type.equals("Void") || type.equals("java.lang.Void"))
        return TypeName.VOID.box();
    if (type.equals("Boolean") || type.equals("java.lang.Boolean"))
        return TypeName.BOOLEAN.box();
    if (type.equals("Byte") || type.equals("java.lang.Byte"))
        return TypeName.BYTE.box();
    if (type.equals("Short") || type.equals("java.lang.Short"))
        return TypeName.SHORT.box();
    if (type.equals("Int") || type.equals("java.lang.Int"))
        return TypeName.INT.box();
    if (type.equals("Long") || type.equals("java.lang.Long"))
        return TypeName.LONG.box();
    if (type.equals("Char") || type.equals("java.lang.Char"))
        return TypeName.CHAR.box();
    if (type.equals("Float") || type.equals("java.lang.Float"))
        return TypeName.FLOAT.box();
    if (type.equals("Double") || type.equals("java.lang.Double"))
        return TypeName.DOUBLE.box();

    // Manage array types
    Pattern arrayEnding = Pattern.compile("\\[\\]");
    Matcher matcher = arrayEnding.matcher(type);
    int arrayCount = 0;
    while (matcher.find())
        arrayCount++;

    if (arrayCount > 0)
    {
        type = type.substring(0, type.length() - arrayCount * 2);
    }

    TypeName typeName = ClassName.bestGuess(type);
    for (int i = 0; i < arrayCount; i++)
    {
        typeName = ArrayTypeName.of(typeName);
    }

    return typeName;
}
 
开发者ID:Axellience,项目名称:vue-gwt,代码行数:63,代码来源:GenerationUtil.java

示例14: getOrderSpecArray

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
public static ArrayTypeName getOrderSpecArray(TypeName modelType) {
    return ArrayTypeName.of(ParameterizedTypeName.get(OrderSpec, modelType));
}
 
开发者ID:maskarade,项目名称:Android-Orma,代码行数:4,代码来源:Types.java

示例15: getArrayTypeName

import com.squareup.javapoet.ArrayTypeName; //导入方法依赖的package包/类
public static TypeName getArrayTypeName(final Element parameter) {
    return ArrayTypeName.of(TypeName.get(parameter.asType()));
}
 
开发者ID:vbauer,项目名称:jackdaw,代码行数:4,代码来源:TypeUtils.java


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