本文整理匯總了Java中com.parse.ParseClassName類的典型用法代碼示例。如果您正苦於以下問題:Java ParseClassName類的具體用法?Java ParseClassName怎麽用?Java ParseClassName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ParseClassName類屬於com.parse包,在下文中一共展示了ParseClassName類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generate
import com.parse.ParseClassName; //導入依賴的package包/類
public static TypeSpec.Builder generate(AnnotatedClass annotated) {
String classNameUC = UPPER_CAMEL.to(UPPER_CAMEL, annotated.mShortClassName); //to be sure
ClassName parseQuery = ClassName.get("com.parse", "ParseQuery");
ClassName thisElement = ClassName.get("", classNameUC);
TypeName parseQueryOfThisElement = ParameterizedTypeName.get(parseQuery, thisElement);
TypeSpec.Builder builder = TypeSpec.classBuilder(classNameUC)
.superclass(ClassName.get("", PARSE_BASE_OBJECT))
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.addMethod(MethodSpec.constructorBuilder()
.addModifiers(Modifier.PUBLIC)
.build())
.addAnnotation(AnnotationSpec.builder(ParseClassName.class)
.addMember("value", "$S", classNameUC)
.build())
.addStaticBlock(CodeBlock.builder()
.addStatement(STATIC_BLOCK_STATEMENT, classNameUC)
.build())
.addMethod(MethodSpec.methodBuilder(STATIC_GET_QUERY_METHOD_NAME)
.addModifiers(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.returns(parseQueryOfThisElement)
.addStatement(STATIC_GET_QUERY_METHOD_RETURN_STATEMENT, classNameUC)
.build());
String fieldName;
String fieldNameLC;
String fieldNameUC;
String fieldNameUU;
for (int i = 0; i < annotated.mFieldNames.size(); ++i) {
fieldName = annotated.mFieldNames.get(i);
fieldNameLC = LOWER_CAMEL.to(LOWER_CAMEL, fieldName);
fieldNameUC = LOWER_CAMEL.to(UPPER_CAMEL, fieldName);
fieldNameUU = STATIC_KEY_FIELD + LOWER_CAMEL.to(UPPER_UNDERSCORE, fieldName);
builder.addField(FieldSpec
.builder(String.class, fieldNameUU, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.initializer("$S", fieldName)
.build());
FieldType type = annotated.mFieldTypes.get(i);
TypeName setterParameter = type.getTypeName();
builder.addMethod(MethodSpec.methodBuilder(SETTER_METHOD_NAME + fieldNameUC)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addParameter(setterParameter, fieldNameLC)
.addStatement(SETTER_METHOD_STATEMENT, fieldNameUU, fieldNameLC)
.build());
MethodSpec.Builder getterBuilder = MethodSpec.methodBuilder(GETTER_METHOD_NAME + fieldNameUC)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.returns(setterParameter);
type.addGetterStatements(getterBuilder, fieldNameUU);
builder.addMethod(getterBuilder.build());
}
return builder;
}