本文整理匯總了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);
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例9: getTypeName
import com.squareup.javapoet.ArrayTypeName; //導入方法依賴的package包/類
@Override
public TypeName getTypeName() {
return ArrayTypeName.of(arrayType.getTypeName());
}
示例10: asArray
import com.squareup.javapoet.ArrayTypeName; //導入方法依賴的package包/類
private ArrayTypeName asArray() {
return ArrayTypeName.of(listElementType());
}
示例11: asArrayOfModeledEnum
import com.squareup.javapoet.ArrayTypeName; //導入方法依賴的package包/類
private ArrayTypeName asArrayOfModeledEnum() {
return ArrayTypeName.of(modeledEnumElement());
}
示例12: getArrayTypeName
import com.squareup.javapoet.ArrayTypeName; //導入方法依賴的package包/類
TypeName getArrayTypeName() {
return ArrayTypeName.of(getTypeName());
}
示例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;
}
示例14: getOrderSpecArray
import com.squareup.javapoet.ArrayTypeName; //導入方法依賴的package包/類
public static ArrayTypeName getOrderSpecArray(TypeName modelType) {
return ArrayTypeName.of(ParameterizedTypeName.get(OrderSpec, modelType));
}
示例15: getArrayTypeName
import com.squareup.javapoet.ArrayTypeName; //導入方法依賴的package包/類
public static TypeName getArrayTypeName(final Element parameter) {
return ArrayTypeName.of(TypeName.get(parameter.asType()));
}