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


Java ArrayTypeName類代碼示例

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


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

示例1: getTagsBuilderMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private static MethodSpec getTagsBuilderMethod(ClassName name, ClassName tags, int size) {
	
	ParameterSpec parameter = ParameterSpec.builder(ArrayTypeName.of(tags), "tags").build();
	return MethodSpec.methodBuilder("tags")
			.addModifiers(Modifier.PUBLIC)
			.addParameter(parameter)
			.varargs()
			.addStatement("$T clone = new $T[" + size + "]", ArrayTypeName.of(tags), tags)
			.beginControlFlow("if(this.tags != null)")
			.addStatement("System.arraycopy(this.tags, 0, clone, 0, " + size + ")")
			.endControlFlow()
			.beginControlFlow("for($T tag : tags)", tags)
			.addStatement("clone[tag.ordinal()] = tag")
			.endControlFlow()
			.addStatement("this.tags = clone")
			.returns(name)
			.addStatement("return this")
			.build();
}
 
開發者ID:skjolber,項目名稱:json-log-domain,代碼行數:20,代碼來源:MarkerGenerator.java

示例2: typeNeedsTypeVariable

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private static boolean typeNeedsTypeVariable(TypeName type, TypeVariableName typeVariable) {
  if (typeVariable.equals(type)) {
    return true;
  }

  if (type instanceof ParameterizedTypeName) {
    ParameterizedTypeName parameterized = ((ParameterizedTypeName) type);
    for (TypeName typeArgument : parameterized.typeArguments) {
      if (typeVariable.equals(typeArgument)) {
        return true;
      }
    }
  }

  if (type instanceof ArrayTypeName) {
    ArrayTypeName arrayType = (ArrayTypeName) type;
    if (typeVariable.equals(arrayType.componentType)) {
      return true;
    }
  }
  return false;
}
 
開發者ID:spotify,項目名稱:dataenum,代碼行數:23,代碼來源:OutputValueFactory.java

示例3: generateUnboxMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec generateUnboxMethod(
        ClassName className,
        TypeName typeName,
        String primitiveType) {
    String paramName = className.simpleName() + "Param";
    paramName = Character.toLowerCase(paramName.charAt(0)) + paramName.substring(1);
    String primitiveArray = primitiveType + "s";
    return MethodSpec.methodBuilder("toPrimitive")
            .addParameters(ImmutableList.of(ParameterSpec.builder(ArrayTypeName.of(className), paramName).build()))
            .returns(ArrayTypeName.of(typeName))
            .addModifiers(PUBLIC)
            .addModifiers(STATIC)
            .addStatement("$L[] $L = new $L[$L.length]", primitiveType, primitiveArray, primitiveType, paramName)
            .beginControlFlow("for (int i = 0; i < $L.length; i++)", paramName)
            .addStatement("$L[i] = $L[i]", primitiveArray, paramName)
            .endControlFlow()
            .addStatement("return $L", primitiveArray)
            .build();
}
 
開發者ID:uber,項目名稱:auto-value-bundle,代碼行數:20,代碼來源:BundleExtension.java

示例4: createIdSearch

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
public static TypeName createIdSearch(ProcessingEnvironment processingEnvironment, LocalConfiguration localConfiguration) {
    TypeName idTypeName = TypeName.get(localConfiguration.getIdTypeMirror());
    if (idTypeName.equals(ClassName.get("java.lang", "Boolean")) || idTypeName.equals(TypeName.BOOLEAN)) {
        return ClassName.get(GlobalConfiguration.BOOLEAN_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.BOOLEAN_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ArrayTypeName.of(TypeName.BYTE))) {
        return ClassName.get(GlobalConfiguration.BYTE_ARRAY_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.BYTE_ARRAY_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "Byte")) || idTypeName.equals(TypeName.BYTE)) {
        return ClassName.get(GlobalConfiguration.BOOLEAN_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.BOOLEAN_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.util", "Date"))) {
        return ClassName.get(GlobalConfiguration.DATE_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.DATE_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "Double")) || idTypeName.equals(TypeName.DOUBLE)) {
        return ClassName.get(GlobalConfiguration.DOUBLE_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.DOUBLE_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "Float")) || idTypeName.equals(TypeName.FLOAT)) {
        return ClassName.get(GlobalConfiguration.FLOAT_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.FLOAT_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "Integer")) || idTypeName.equals(TypeName.INT)) {
        return ClassName.get(GlobalConfiguration.INTEGER_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.INTEGER_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "Long")) || idTypeName.equals(TypeName.LONG)) {
        return ClassName.get(GlobalConfiguration.LONG_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.LONG_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "Short")) || idTypeName.equals(TypeName.SHORT)) {
        return ClassName.get(GlobalConfiguration.SHORT_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.SHORT_ID_SEARCH_CLASS_NAME);
    } else if (idTypeName.equals(ClassName.get("java.lang", "String"))) {
        return ClassName.get(GlobalConfiguration.STRING_ID_SEARCH_CLASS_PACKAGE, GlobalConfiguration.STRING_ID_SEARCH_CLASS_NAME);
    } else {
        throw new RealmRepositoryException("Not supported id type " + idTypeName.toString() + " in " + localConfiguration.getDataRepositoryInterfaceTypeElement().getSimpleName().toString());
    }
}
 
開發者ID:AleksanderMielczarek,項目名稱:RealmRepository,代碼行數:27,代碼來源:IdSearchFactory.java

示例5: valueOf

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
public static Type valueOf(TypeName typeName) {
    if (ArrayTypeName.of(byte.class).equals(typeName)) {
        return CursorRowElement.Type.BLOB;
    } else if (TypeName.DOUBLE.equals(typeName) || TypeName.DOUBLE.box().equals(typeName)) {
        return CursorRowElement.Type.DOUBLE;
    } else if (TypeName.INT.equals(typeName) || TypeName.INT.box().equals(typeName)) {
        return CursorRowElement.Type.INT;
    } else if (TypeName.FLOAT.equals(typeName) || TypeName.FLOAT.box().equals(typeName)) {
        return CursorRowElement.Type.FLOAT;
    } else if (TypeName.LONG.equals(typeName) || TypeName.LONG.box().equals(typeName)) {
        return CursorRowElement.Type.LONG;
    } else if (ClassName.get(String.class).equals(typeName)) {
        return CursorRowElement.Type.STRING;
    } else if (TypeName.SHORT.equals(typeName) || TypeName.SHORT.box().equals(typeName)) {
        return CursorRowElement.Type.SHORT;
    }
    return null;
}
 
開發者ID:dkajiwara,項目名稱:Curson,代碼行數:19,代碼來源:CursorRowElement.java

示例6: 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

示例7: buildGetSingleByRawQueryMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec buildGetSingleByRawQueryMethod() {
    final String cursorVarName = "cursor";
    return MethodSpec.methodBuilder("getSingle")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(getClassNameOfElement())
            .addParameter(CONTEXT, "context", Modifier.FINAL)
            .addParameter(STRING, "rawQueryClause", Modifier.FINAL)
            .addParameter(ArrayTypeName.of(STRING), "rawQueryArgs", Modifier.FINAL)
            .addParameter(TypeName.BOOLEAN, "fromCache", Modifier.FINAL)
            .addStatement("final $T $L = getReadableDatabase($L)"
                            + ".rawQuery(rawQueryClause, rawQueryArgs)",
                    CURSOR, cursorVarName, "context")
            .beginControlFlow("if (!$L.moveToFirst())", cursorVarName)
            .addStatement("$L.close()", cursorVarName)
            .addStatement("return null")
            .endControlFlow()
            .addStatement("$T ret = instantiateObject(cursor, context, fromCache)",
                    getClassNameOfElement())
            .addStatement("$L.close()", cursorVarName)
            .addStatement("return ret")
            .build();
}
 
開發者ID:jeppeman,項目名稱:HighLite,代碼行數:24,代碼來源:SQLiteDAOClass.java

示例8: buildGetListByRawQueryMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec buildGetListByRawQueryMethod() {
    final String cursorVarName = "cursor";
    return MethodSpec.methodBuilder("getList")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(ParameterizedTypeName.get(LIST, getClassNameOfElement()))
            .addParameter(CONTEXT, "context", Modifier.FINAL)
            .addParameter(STRING, "rawQueryClause", Modifier.FINAL)
            .addParameter(ArrayTypeName.of(STRING), "rawQueryArgs", Modifier.FINAL)
            .addParameter(TypeName.BOOLEAN, "fromCache", Modifier.FINAL)
            .addStatement("final $T<$T> ret = new $T<>()", LIST, getClassNameOfElement(),
                    ARRAY_LIST)
            .addStatement("final $T $L = getReadableDatabase($L)"
                            + ".rawQuery(rawQueryClause, rawQueryArgs)",
                    CURSOR, cursorVarName, "context")
            .beginControlFlow("if (!$L.moveToFirst())", cursorVarName)
            .addStatement("$L.close()", cursorVarName)
            .addStatement("return ret")
            .endControlFlow()
            .beginControlFlow("do")
            .addStatement("ret.add(instantiateObject(cursor, context, fromCache))")
            .endControlFlow("while(cursor.moveToNext())")
            .addStatement("$L.close()", cursorVarName)
            .addStatement("return ret")
            .build();
}
 
開發者ID:jeppeman,項目名稱:HighLite,代碼行數:27,代碼來源:SQLiteDAOClass.java

示例9: generateUpdateMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec generateUpdateMethod() {
    MethodSpec.Builder saveMethodBuidler = MethodSpec.methodBuilder("update")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(TypeName.INT)
            .addParameter(ClassName.get(Class.class), "clazz")
            .addParameter(ClassName.get(ContentValuesWrapper.class), "valuesWrapper")
            .addParameter(ClassName.get(String.class), "where")
            .addParameter(ArrayTypeName.of(ClassName.get(String.class)), "whereArgs");

    for (TableInfo table : tables) {

        String daoField = table.getDaoClassName().replace("$$", "").toLowerCase();
        saveMethodBuidler.addStatement("if($L.class.equals(clazz)) return $L.update(valuesWrapper, where, whereArgs)", table.getClassName(), daoField);
    }

    saveMethodBuidler.addStatement("return 0");
    return saveMethodBuidler.build();
}
 
開發者ID:baoyongzhang,項目名稱:AirData,代碼行數:20,代碼來源:DatabaseHelperCreator.java

示例10: generateDeleteMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec generateDeleteMethod() {
    MethodSpec.Builder saveMethodBuidler = MethodSpec.methodBuilder("delete")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(TypeName.INT)
            .addParameter(ClassName.get(Class.class), "clazz")
            .addParameter(ClassName.get(String.class), "where")
            .addParameter(ArrayTypeName.of(ClassName.get(String.class)), "whereArgs");

    for (TableInfo table : tables) {

        String daoField = table.getDaoClassName().replace("$$", "").toLowerCase();

        saveMethodBuidler.addStatement("if($L.class.equals(clazz)) return $L.delete(where, whereArgs)", table.getClassName(), daoField);
    }

    saveMethodBuidler.addStatement("return 0");
    return saveMethodBuidler.build();
}
 
開發者ID:baoyongzhang,項目名稱:AirData,代碼行數:20,代碼來源:DatabaseHelperCreator.java

示例11: generateRawQueryMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec generateRawQueryMethod() {
    MethodSpec.Builder queryMethodBuidler = MethodSpec.methodBuilder("rawQuery")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(ClassName.get("android.database", "Cursor"))
            .addParameter(ClassName.get(Class.class), "clazz")
            .addParameter(TypeName.BOOLEAN, "distinct")
            .addParameter(ArrayTypeName.of(ClassName.get(String.class)), "columns")
            .addParameter(ClassName.get(String.class), "selection")
            .addParameter(ArrayTypeName.of(ClassName.get(String.class)), "selectionArgs")
            .addParameter(ClassName.get(String.class), "groupBy")
            .addParameter(ClassName.get(String.class), "having")
            .addParameter(ClassName.get(String.class), "orderBy")
            .addParameter(ClassName.get(String.class), "limit");

    for (TableInfo table : tables) {

        String daoField = table.getDaoClassName().replace("$$", "").toLowerCase();

        queryMethodBuidler.addStatement("if($L.class.equals(clazz)) return $L.rawQuery(distinct, columns, selection, selectionArgs, groupBy, having, orderBy, limit)", table.getClassName(), daoField);
    }

    queryMethodBuidler.addStatement("return null");
    return queryMethodBuidler.build();
}
 
開發者ID:baoyongzhang,項目名稱:AirData,代碼行數:26,代碼來源:DatabaseHelperCreator.java

示例12: generatorQueryMethod

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private MethodSpec generatorQueryMethod() {
    MethodSpec.Builder queryBuilder = MethodSpec.methodBuilder("query")
            .addModifiers(Modifier.PUBLIC)
            .returns(ClassName.get(List.class))
            .addParameter(TypeName.BOOLEAN, "distinct")
            .addParameter(ArrayTypeName.of(ClassName.get(String.class)), "columns")
            .addParameter(ClassName.get(String.class), "selection")
            .addParameter(ArrayTypeName.of(ClassName.get(String.class)), "selectionArgs")
            .addParameter(ClassName.get(String.class), "groupBy")
            .addParameter(ClassName.get(String.class), "having")
            .addParameter(ClassName.get(String.class), "orderBy")
            .addParameter(ClassName.get(String.class), "limit")
            .addStatement("$T cursor = this.rawQuery(distinct, columns, selection, selectionArgs, groupBy, having, orderBy, limit)", ClassName.get("android.database", "Cursor"));
    queryBuilder.addStatement("$T list = new $T()", ArrayList.class, ArrayList.class);
    queryBuilder.addCode("if (cursor.moveToFirst()) {");
    queryBuilder.addCode("  do {");
    queryBuilder.addCode("     list.add(fillData(cursor));");
    queryBuilder.addCode("  } while (cursor.moveToNext());");
    queryBuilder.addCode("}");
    queryBuilder.addStatement("return list");
    return queryBuilder.build();
}
 
開發者ID:baoyongzhang,項目名稱:AirData,代碼行數:23,代碼來源:DAOCreator.java

示例13: 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

示例14: simpleName

import com.squareup.javapoet.ArrayTypeName; //導入依賴的package包/類
private static String simpleName(TypeName typeName) {
  if (typeName instanceof ClassName) {
    return UPPER_CAMEL.to(LOWER_CAMEL, ((ClassName) typeName).simpleName());
  } else if (typeName instanceof ParameterizedTypeName) {
    ParameterizedTypeName parameterizedTypeName = (ParameterizedTypeName) typeName;
    return UPPER_CAMEL.to(LOWER_CAMEL, parameterizedTypeName.rawType.simpleName())
        + (parameterizedTypeName.typeArguments.isEmpty() ? "" : "__")
        + simpleName(parameterizedTypeName.typeArguments);
  } else if (typeName instanceof ArrayTypeName) {
    return "array__" + simpleName(((ArrayTypeName) typeName).componentType);
  } else if (typeName instanceof WildcardTypeName) {
    WildcardTypeName wildcardTypeName = (WildcardTypeName) typeName;
    return "wildcard__"
        + simpleName(ImmutableList.<TypeName>builder().addAll(wildcardTypeName.lowerBounds)
        .addAll(wildcardTypeName.upperBounds)
        .build());
  } else if (typeName instanceof TypeVariableName) {
    TypeVariableName variable = (TypeVariableName) typeName;
    return variable.name
        + (variable.bounds.isEmpty() ? "" : "__")
        + simpleName(variable.bounds);
  } else {
    return typeName.toString();
  }
}
 
開發者ID:rharter,項目名稱:auto-value-gson,代碼行數:26,代碼來源:AutoValueGsonExtension.java

示例15: 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


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