下面列出了怎么用com.fasterxml.jackson.annotation.JsonValue的API类实例代码及写法,或者点击链接到github查看源代码。
@Nullable
private static AccessibleObject getAnnotation(Class<?> clazz) {
Set<AccessibleObject> accessibleObjects = new HashSet<>();
// JsonValue METHOD, FIELD
Field[] fields = clazz.getDeclaredFields();
Collections.addAll(accessibleObjects, fields);
// methods
Method[] methods = clazz.getDeclaredMethods();
Collections.addAll(accessibleObjects, methods);
for (AccessibleObject accessibleObject : accessibleObjects) {
// 复用 jackson 的 JsonValue 注解
JsonValue jsonValue = accessibleObject.getAnnotation(JsonValue.class);
if (jsonValue != null && jsonValue.value()) {
accessibleObject.setAccessible(true);
return accessibleObject;
}
}
return null;
}
@JsonValue
@Override
public String toString() {
if (_group == null) {
// When a role has no group the string representation is just the id.
return _id;
}
// Since "/" isn't a valid character in groups or ids it can be used as a separator without
// needing to encode either component.
return _group + "/" + _id;
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@JsonValue
public String getValue() {
return this.value;
}
@JsonValue
public String getValue() {
return value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(this.value);
}
@JsonValue
public String getValue() {
return value;
}
@JsonValue
public String getValue() {
return value;
}
@JsonValue
public String getValue() {
return value;
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
/** Here specifically for Jackson serialization. */
@JsonValue
private Map<Authorization, List<String>> getPermissions() {
return permissions;
}
@JsonValue
public Object getValue() {
return id;
}
@JsonValue
public Integer getValue() {
return value;
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
@JsonValue
public String toString() {
return value;
}
@JsonValue
public Integer getValue() {
return value;
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@JsonValue
@JsonRawValue
public String value() {
return value;
}
@JsonValue
public Double getValue() {
return value;
}
@Override
@JsonValue
public String toString()
{
return queryId + "." + id;
}
@Override
@JsonValue
public String toString() {
return value;
}
@JsonValue
public String getValue() {
return value;
}
@JsonValue
public String getValue() {
return value;
}
@JsonValue
public String getValue() {
return value;
}
@JsonValue
public String getName() {
return name;
}
@JsonValue
public Object getJsonValue() {
return jsonValue == null ? "" : jsonValue;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(this.value);
}
@JsonValue
public @Nonnull String value() {
return _text;
}
@JsonValue
public String getValue() {
return value;
}