本文整理汇总了Java中com.bluelinelabs.logansquare.annotation.JsonObject类的典型用法代码示例。如果您正苦于以下问题:Java JsonObject类的具体用法?Java JsonObject怎么用?Java JsonObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonObject类属于com.bluelinelabs.logansquare.annotation包,在下文中一共展示了JsonObject类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isJsonFieldFieldAnnotationValid
import com.bluelinelabs.logansquare.annotation.JsonObject; //导入依赖的package包/类
private boolean isJsonFieldFieldAnnotationValid(Element element, Elements elements) {
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
Annotation objectAnnotation = enclosingElement.getAnnotation(JsonObject.class);
if (objectAnnotation == null) {
error(enclosingElement, "%s: @%s fields can only be in classes annotated with @%s.", enclosingElement.getQualifiedName(), JsonField.class.getSimpleName(), JsonObject.class.getSimpleName());
return false;
}
if (element.getModifiers().contains(PRIVATE) && (TextUtils.isEmpty(JsonFieldHolder.getGetter(element, elements)) || TextUtils.isEmpty(JsonFieldHolder.getSetter(element, elements)))) {
error(element, "@%s annotation can only be used on private fields if both getter and setter are present.", JsonField.class.getSimpleName());
return false;
}
return true;
}
示例2: isCallbackMethodAnnotationValid
import com.bluelinelabs.logansquare.annotation.JsonObject; //导入依赖的package包/类
public boolean isCallbackMethodAnnotationValid(Element element, String annotationName) {
TypeElement enclosingElement = (TypeElement)element.getEnclosingElement();
if (enclosingElement.getAnnotation(JsonObject.class) == null) {
error(enclosingElement, "%s: @%s methods can only be in classes annotated with @%s.", enclosingElement.getQualifiedName(), annotationName, JsonObject.class.getSimpleName());
return false;
}
ExecutableElement executableElement = (ExecutableElement)element;
if (executableElement.getParameters().size() > 0) {
error(element, "%s: @%s methods must not take any parameters.", enclosingElement.getQualifiedName(), annotationName);
return false;
}
List<? extends Element> allElements = enclosingElement.getEnclosedElements();
int methodInstances = 0;
for (Element enclosedElement : allElements) {
for (AnnotationMirror am : enclosedElement.getAnnotationMirrors()) {
if (am.getAnnotationType().asElement().getSimpleName().toString().equals(annotationName)) {
methodInstances++;
}
}
}
if (methodInstances != 1) {
error(element, "%s: There can only be one @%s method per class.", enclosingElement.getQualifiedName(), annotationName);
return false;
}
return true;
}
示例3: findAndParseObjects
import com.bluelinelabs.logansquare.annotation.JsonObject; //导入依赖的package包/类
@Override
public void findAndParseObjects(RoundEnvironment env, Map<String, JsonObjectHolder> jsonObjectMap, Elements elements, Types types) {
for (Element element : env.getElementsAnnotatedWith(JsonObject.class)) {
try {
processJsonObjectAnnotation(element, jsonObjectMap, elements, types);
} catch (Exception e) {
StringWriter stackTrace = new StringWriter();
e.printStackTrace(new PrintWriter(stackTrace));
error(element, "Unable to generate injector for %s. Stack trace incoming:\n%s", JsonObject.class, stackTrace.toString());
}
}
}
示例4: getAnnotation
import com.bluelinelabs.logansquare.annotation.JsonObject; //导入依赖的package包/类
@Override
public Class getAnnotation() {
return JsonObject.class;
}
示例5: fieldTypeFor
import com.bluelinelabs.logansquare.annotation.JsonObject; //导入依赖的package包/类
public static FieldType fieldTypeFor(TypeMirror typeMirror, TypeMirror typeConverterType, Elements elements, Types types) {
if (typeMirror != null) {
if (typeConverterType != null && !"void".equals(typeConverterType.toString())) {
return new TypeConverterFieldType(TypeName.get(typeMirror), ClassName.bestGuess(typeConverterType.toString()));
} else if (typeMirror.getKind() == TypeKind.BOOLEAN) {
return new BooleanFieldType(true);
} else if (Boolean.class.getCanonicalName().equals(typeMirror.toString())) {
return new BooleanFieldType(false);
} else if (typeMirror.getKind() == TypeKind.BYTE) {
return new ByteFieldType(true);
} else if (Byte.class.getCanonicalName().equals(typeMirror.toString())) {
return new ByteFieldType(false);
} else if (typeMirror.getKind() == TypeKind.INT) {
return new IntegerFieldType(true);
} else if (Integer.class.getCanonicalName().equals(typeMirror.toString())) {
return new IntegerFieldType(false);
} else if (typeMirror.getKind() == TypeKind.LONG) {
return new LongFieldType(true);
} else if (Long.class.getCanonicalName().equals(typeMirror.toString())) {
return new LongFieldType(false);
} else if (typeMirror.getKind() == TypeKind.FLOAT) {
return new FloatFieldType(true);
} else if (Float.class.getCanonicalName().equals(typeMirror.toString())) {
return new FloatFieldType(false);
} else if (typeMirror.getKind() == TypeKind.DOUBLE) {
return new DoubleFieldType(true);
} else if (Double.class.getCanonicalName().equals(typeMirror.toString())) {
return new DoubleFieldType(false);
} else if (String.class.getCanonicalName().equals(typeMirror.toString())) {
return new StringFieldType();
} else if (Object.class.getCanonicalName().equals(typeMirror.toString())) {
return new UnknownFieldType();
} else if (typeMirror instanceof DeclaredType) {
Annotation annotation = ((DeclaredType) typeMirror).asElement().getAnnotation(JsonObject.class);
if (annotation != null) {
return new JsonFieldType(ClassName.bestGuess(typeMirror.toString()));
}
}
return new DynamicFieldType(TypeName.get(typeMirror));
} else {
return null;
}
}