List of usage examples for com.google.gson JsonNull INSTANCE
JsonNull INSTANCE
To view the source code for com.google.gson JsonNull INSTANCE.
Click Source Link
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonFields(IBinaryField[] fields) { if (fields == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (IBinaryField field : fields) { array.add(toJsonField(field));/* w w w . ja v a 2s. c o m*/ } return array; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonField(IBinaryField field) { JsonObject object = new JsonObject(); object.addProperty("modifiers", field.getModifiers()); object.add("constant", toJsonConstant(field.getConstant())); object.add("genericSignature", field.getGenericSignature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.getGenericSignature()))); object.add("name", field.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.getName()))); object.addProperty("tagBits", String.valueOf(field.getTagBits())); object.add("typeName", field.getTypeName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.getTypeName()))); object.add("annotations", toJsonAnnotations(field.getAnnotations())); return object; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
public static JsonElement toJsonConstant(Constant constant) { if (constant == null) return JsonNull.INSTANCE; JsonObject con = new JsonObject(); con.addProperty("typeId", constant.typeID()); JsonElement val; switch (constant.typeID()) { case T_int: val = new JsonPrimitive(constant.intValue()); break;/*from w w w . jav a 2s . com*/ case T_byte: val = new JsonPrimitive(constant.byteValue()); break; case T_short: val = new JsonPrimitive(constant.shortValue()); break; case T_char: val = new JsonPrimitive(constant.charValue()); break; case T_float: val = new JsonPrimitive(String.valueOf(constant.floatValue())); break; case T_double: if (Constant.NotAConstant.equals(constant)) { val = new JsonPrimitive("NaN"); con.addProperty("NotAConstant", 1); } else { val = new JsonPrimitive(constant.stringValue()); } break; case T_boolean: val = new JsonPrimitive(constant.booleanValue()); break; case T_long: val = new JsonPrimitive(String.valueOf(constant.longValue())); break; case T_JavaLangString: val = new JsonPrimitive(constant.stringValue()); break; default: val = JsonNull.INSTANCE; } con.add("value", val); return con; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonAnnotations(IBinaryAnnotation[] annotations) { if (annotations == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (IBinaryAnnotation annotation : annotations) { array.add(toJsonAnnotation(annotation)); }/*from w w w. j av a 2 s . co m*/ return array; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonAnnotation(IBinaryAnnotation annotation) { JsonObject object = new JsonObject(); object.add("typeName", annotation.getTypeName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(annotation.getTypeName()))); object.add("elementValuePairs", toJsonElementValuePairs(annotation.getElementValuePairs())); return object; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonElementValuePairs(IBinaryElementValuePair[] elementValuePairs) { if (elementValuePairs == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (IBinaryElementValuePair pair : elementValuePairs) { array.add(toJsonElementValuePair(pair)); }/* w w w . ja va2 s. co m*/ return array; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonElementValuePair(IBinaryElementValuePair pair) { JsonObject object = new JsonObject(); object.add("name", pair.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(pair.getName()))); object.add("value", toJsonDefaultValue(pair.getValue())); return object; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonDefaultValue(Object defaultValue) { if (defaultValue == null) return JsonNull.INSTANCE; JsonObject object = new JsonObject(); if (defaultValue instanceof Constant) { object.add("constant", toJsonConstant((Constant) defaultValue)); } else if (defaultValue instanceof ClassSignature) { object.addProperty("class", new String(((ClassSignature) defaultValue).getTypeName())); } else if (defaultValue instanceof IBinaryAnnotation) { object.add("annotation", toJsonAnnotation((IBinaryAnnotation) defaultValue)); } else if (defaultValue instanceof EnumConstantSignature) { EnumConstantSignature signature = (EnumConstantSignature) defaultValue; JsonObject enumSignature = new JsonObject(); enumSignature.addProperty("typeName", new String(signature.getTypeName())); enumSignature.addProperty("constantName", new String(signature.getEnumConstantName())); object.add("enum", enumSignature); } else if (defaultValue instanceof Object[]) { JsonArray array = new JsonArray(); for (Object o : (Object[]) defaultValue) { array.add(toJsonDefaultValue(o)); }//from w w w .j a v a 2 s .c om object.add("array", array); } return object; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonMemberTypes(IBinaryNestedType[] memberTypes) { if (memberTypes == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (IBinaryNestedType type : memberTypes) { array.add(toJsonMemberType(type)); }/*from w ww . j ava 2s .co m*/ return array; }
From source file:org.eclipse.che.jdt.BinaryTypeConvector.java
License:Open Source License
private static JsonElement toJsonMemberType(IBinaryNestedType type) { JsonObject object = new JsonObject(); object.add("enclosingTypeName", type.getEnclosingTypeName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.getEnclosingTypeName()))); object.addProperty("modifiers", type.getModifiers()); object.add("name", type.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.getName()))); return object; }