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:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonMethods(MethodBinding[] methods) { if (methods == null) return JsonNull.INSTANCE; JsonArray jsonElements = new JsonArray(); for (MethodBinding method : methods) { jsonElements.add(toJsonMethod(method)); }/*from w w w . j av a 2 s. com*/ return jsonElements; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonMethod(MethodBinding method) { JsonObject object = new JsonObject(); object.addProperty("modifiers", method.getAccessFlags()); object.addProperty("constructor", method.isConstructor()); object.add("argumentNames", toJsonParametersName(method.sourceMethod())); object.add("annotations", toJsonAnnotations(method.getAnnotations())); object.add("defaultValue", toJsonDefaultValue(method.getDefaultValue())); object.add("exceptionTypeNames", toJsonExceptionTypeNames(method.thrownExceptions)); object.add("genericSignature", method.genericSignature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.genericSignature()))); object.add("methodDescriptor", method.signature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.signature()))); object.add("parameterAnnotations", toJsonParameterAnnotations(method)); object.add("selector", method.selector == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(method.selector))); object.addProperty("tagBits", String.valueOf(method.getAnnotationTagBits())); object.addProperty("clinit", false); return object; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonParameterAnnotations(MethodBinding method) { AnnotationBinding[][] parameterAnnotations = method.getParameterAnnotations(); if (parameterAnnotations == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (AnnotationBinding[] parameterAnnotation : parameterAnnotations) { array.add(toJsonAnnotations(parameterAnnotation)); }/* www . j ava2 s . co m*/ return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonExceptionTypeNames(ReferenceBinding[] thrownExceptions) { if (thrownExceptions == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ReferenceBinding exception : thrownExceptions) { array.add(new JsonPrimitive(new String(exception.constantPoolName()))); }/*from www . j av a2s. c om*/ return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.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", BinaryTypeConvector.toJsonConstant((Constant) defaultValue)); } else if (defaultValue instanceof TypeBinding) { object.addProperty("class", new String(((TypeBinding) defaultValue).constantPoolName())); } else if (defaultValue instanceof AnnotationBinding) { object.add("annotation", toJsonAnnotation((AnnotationBinding) defaultValue)); } else if (defaultValue instanceof FieldBinding) { FieldBinding signature = (FieldBinding) defaultValue; JsonObject enumSignature = new JsonObject(); enumSignature.addProperty("typeName", new String(signature.type.signature())); enumSignature.addProperty("constantName", new String(signature.name)); object.add("enum", enumSignature); } else if (defaultValue instanceof Object[]) { JsonArray array = new JsonArray(); for (Object o : (Object[]) defaultValue) { array.add(toJsonDefaultValue(o)); }// w w w. j a va 2 s.c o m object.add("array", array); } return object; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonParametersName(AbstractMethodDeclaration parameters) { if (parameters == null || parameters.arguments == null || parameters.arguments.length == 0) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (Argument parameter : parameters.arguments) { array.add(new JsonPrimitive(new String(parameter.binding.name))); }//from ww w. j av a 2 s . c om return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonMemberType(ReferenceBinding type) { JsonObject object = new JsonObject(); object.add("enclosingTypeName", type.enclosingType() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.enclosingType().constantPoolName()))); object.addProperty("modifiers", type.modifiers); object.add("name", type.constantPoolName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.constantPoolName()))); return object; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonInterfaces(ReferenceBinding[] interfaces) { if (interfaces == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ReferenceBinding anInterface : interfaces) { array.add(new JsonPrimitive(new String(anInterface.constantPoolName()))); }//from w ww . j a v a 2 s. c o m return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonFields(FieldBinding[] fields) { if (fields == null || fields.length == 0) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (FieldBinding field : fields) { array.add(toJsonField(field));/*from w ww . j av a2 s . com*/ } return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonField(FieldBinding field) { JsonObject object = new JsonObject(); object.addProperty("modifiers", field.modifiers); object.add("constant", BinaryTypeConvector.toJsonConstant(field.constant())); object.add("genericSignature", field.genericSignature() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.genericSignature()))); object.add("name", field.name == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.name))); object.addProperty("tagBits", String.valueOf(field.tagBits)); object.add("typeName", field.type == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(field.type.signature()))); object.add("annotations", toJsonAnnotations(field.getAnnotations())); return object; }