本文整理汇总了Java中com.workday.meta.InvalidTypeException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidTypeException类的具体用法?Java InvalidTypeException怎么用?Java InvalidTypeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidTypeException类属于com.workday.meta包,在下文中一共展示了InvalidTypeException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeInitializeField
import com.workday.meta.InvalidTypeException; //导入依赖的package包/类
private void writeInitializeField(JavaWriter writer, VariableElement field) throws IOException {
String initialization = null;
DeclaredType type = (DeclaredType) field.asType();
try {
if (metaTypes.isSubtypeErasure(type, Collection.class)) {
initialization = initializers.findCollectionInitializer(type);
} else if (metaTypes.isSubtypeErasure(type, Map.class)) {
initialization = initializers.findMapInitializer(type);
} else {
throw new IllegalArgumentException("Expected field to be of type Collection or Map, but found " + type);
}
} catch (InvalidTypeException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), field);
}
writer.emitStatement("instance.%s = %s", field.getSimpleName(), initialization);
}
示例2: writeFieldReadStatement
import com.workday.meta.InvalidTypeException; //导入依赖的package包/类
@Override
public void writeFieldReadStatement(VariableElement field,
Collection<ExecutableElement> postCreateChildMethods,
JavaWriter writer) throws IOException {
DeclaredType type = (DeclaredType) field.asType();
TypeMirror itemType = type.getTypeArguments().get(0);
TypeMirror itemTypeErasure = processingEnv.getTypeUtils().erasure(itemType);
String collectionInitializer;
try {
collectionInitializer = initializers.findCollectionInitializer(type);
} catch (InvalidTypeException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), field);
collectionInitializer = "null";
}
writer.beginControlFlow("if (bundle.containsKey(\"%s\"))", field.getSimpleName());
writer.emitStatement("object.%s = %s", field.getSimpleName(), collectionInitializer);
writer.emitStatement(
"%1$s.readCollectionFromBundle(object.%2$s, bundle, %3$s.class, \"%2$s\")",
CollectionBundler.class.getCanonicalName(),
field.getSimpleName(),
itemTypeErasure);
writePostCreateChildMethodCalls(field, itemType, postCreateChildMethods, writer);
writer.endControlFlow();
}
示例3: writeUpdateSelfValuesBlock
import com.workday.meta.InvalidTypeException; //导入依赖的package包/类
private void writeUpdateSelfValuesBlock(final JavaWriter writer) throws IOException {
if (selfValueAssignmentInfo.convertJsonTypes) {
ErrorWriter.surroundWithIoTryCatch(writer, new ErrorWriter.ContentWriter() {
@Override
public void writeContent() throws IOException {
writer.emitStatement("map = JsonParserUtils.convertMapValues(map, context)");
}
});
}
if (selfValueAssignmentInfo.member instanceof ExecutableElement) {
writer.emitStatement(selfValueAssignmentInfo.assignmentPattern, "instance", "map");
} else {
Name fieldName = selfValueAssignmentInfo.member.getSimpleName();
writer.beginControlFlow("if (instance.%s == null)", fieldName);
String mapInitializer = null;
try {
mapInitializer = initializers.findMapInitializer(
(DeclaredType) selfValueAssignmentInfo.member.asType());
} catch (InvalidTypeException e) {
processingEnv.getMessager()
.printMessage(Diagnostic.Kind.ERROR, e.getMessage(), selfValueAssignmentInfo.member);
}
writer.emitStatement("instance.%s = %s", fieldName, mapInitializer);
writer.endControlFlow();
writer.emitStatement("instance.%s.putAll(map)", fieldName);
}
}
示例4: writePublicParseJsonObjectMethod
import com.workday.meta.InvalidTypeException; //导入依赖的package包/类
private void writePublicParseJsonObjectMethod(JavaWriter writer) throws IOException {
writer.emitAnnotation(Override.class);
writer.beginMethod(parsedClassName, "parseJsonObject", Modifiers.PUBLIC,
CollectionUtils.newArrayList(AndroidNames.JSON_OBJECT, "jsonObject",
AndroidNames.JSON_READER, "reader", "String",
"discriminationName", "String", "discriminationValue"),
CollectionUtils.newArrayList(IOException.class.getSimpleName()));
writer.emitField(parsedClassName, "result", Modifiers.NONE, "new " + parsedClassName + "()");
if (!discriminationValueAssignmentPatterns.isEmpty()) {
writer.beginControlFlow("if (discriminationValue != null)");
for (String assignmentPattern : discriminationValueAssignmentPatterns) {
writer.emitStatement(assignmentPattern, "result", "discriminationValue");
}
writer.endControlFlow();
}
String selfValuesMapName = null;
if (selfValueAssignmentInfo != null) {
Element member = selfValueAssignmentInfo.member;
String initializer = null;
selfValuesMapName = member.getSimpleName().toString() + SELF_VALUE_NAME_SUFFIX;
try {
initializer = initializers.findMapInitializer((DeclaredType) member.asType());
} catch (InvalidTypeException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), member);
}
writer.emitField(member.asType().toString(), selfValuesMapName, Modifiers.NONE, initializer);
}
writer.beginControlFlow("if (jsonObject != null)");
if (selfValueAssignmentInfo != null) {
writer.emitStatement("parseFromJsonObject(result, jsonObject, discriminationName, %s)", selfValuesMapName);
} else {
writer.emitStatement("parseFromJsonObject(result, jsonObject, discriminationName)");
}
writer.endControlFlow();
writer.beginControlFlow("if (reader != null)");
if (selfValueAssignmentInfo != null) {
writer.emitStatement("parseFromReader(result, reader, discriminationName, %s)", selfValuesMapName);
} else {
writer.emitStatement("parseFromReader(result, reader, discriminationName)");
}
writer.endControlFlow();
if (selfValueAssignmentInfo != null) {
writer.emitStatement(selfValueAssignmentInfo.assignmentPattern, "result", selfValuesMapName);
}
writer.emitStatement("return result");
writer.endMethod();
}