{"repo":"gson","file":"extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java","line":24,"symbol":"RawCollectionsExample","kind":"class","lang":"java","code":"@SuppressWarnings({\"PrivateConstructorForUtilityClass\", \"SystemOut\"})\npublic class RawCollectionsExample {\n static class Event {\n private String name;\n private String source;\n\n private Event(String name, String source) {\n this.name = name;\n this.source = source;\n }\n\n @Override\n public String toString() {\n return String.format(\"(name=%s, source=%s)\", name, source);\n }\n }\n\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n public static void main(String[] args) {\n Gson gson = new Gson();\n Collection collection = new ArrayList();\n collection.add(\"hello\");\n collection.add(5);\n collection.add(new Event(\"GREETINGS\", \"guest\"));\n String json = gson.toJson(collection);\n System.out.println(\"Using Gson.toJson() on a raw collection: \" + json);\n JsonArray array = JsonParser.parseString(json).getAsJsonArray();\n String message = gson.fromJson(array.get(0), String.class);\n int number = gson.fromJson(array.get(1), int.class);\n Event event = gson.fromJson(array.get(2), Event.class);\n System.out.printf(\"Using Gson.fromJson() to get: %s, %d, %s\", message, number, event);\n }\n}"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java","line":26,"symbol":"Event","kind":"class","lang":"java","code":"static class Event {\n private String name;\n private String source;\n\n private Event(String name, String source) {\n this.name = name;\n this.source = source;\n }\n\n @Override\n public String toString() {\n return String.format(\"(name=%s, source=%s)\", name, source);\n }\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java","line":30,"symbol":"Event","kind":"constructor","lang":"java","code":"private Event(String name, String source) {\n this.name = name;\n this.source = source;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java","line":35,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return String.format(\"(name=%s, source=%s)\", name, source);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java","line":41,"symbol":"main","kind":"method","lang":"java","code":"@SuppressWarnings({\"unchecked\", \"rawtypes\"})\n public static void main(String[] args) {\n Gson gson = new Gson();\n Collection collection = new ArrayList();\n collection.add(\"hello\");\n collection.add(5);\n collection.add(new Event(\"GREETINGS\", \"guest\"));\n String json = gson.toJson(collection);\n System.out.println(\"Using Gson.toJson() on a raw collection: \" + json);\n JsonArray array = JsonParser.parseString(json).getAsJsonArray();\n String message = gson.fromJson(array.get(0), String.class);\n int number = gson.fromJson(array.get(1), int.class);\n Event event = gson.fromJson(array.get(2), Event.class);\n System.out.printf(\"Using Gson.fromJson() to get: %s, %d, %s\", message, number, event);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java","line":28,"symbol":"InterceptorFactory","kind":"class","lang":"java","doc":"A type adapter factory that implements {@code @Intercept}.","code":"public final class InterceptorFactory implements TypeAdapterFactory {\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n Intercept intercept = type.getRawType().getAnnotation(Intercept.class);\n if (intercept == null) {\n return null;\n }\n\n TypeAdapter delegate = gson.getDelegateAdapter(this, type);\n return new InterceptorAdapter<>(delegate, intercept);\n }\n\n static class InterceptorAdapter extends TypeAdapter {\n private final TypeAdapter delegate;\n private final JsonPostDeserializer postDeserializer;\n\n @SuppressWarnings(\"unchecked\") // ?\n public InterceptorAdapter(TypeAdapter delegate, Intercept intercept) {\n try {\n this.delegate = delegate;\n this.postDeserializer = intercept.postDeserialize().getDeclaredConstructor().newInstance();\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate.write(out, value);\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n T result = delegate.read(in);\n postDeserializer.postDeserialize(result);\n "} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java","line":29,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n Intercept intercept = type.getRawType().getAnnotation(Intercept.class);\n if (intercept == null) {\n return null;\n }\n\n TypeAdapter delegate = gson.getDelegateAdapter(this, type);\n return new InterceptorAdapter<>(delegate, intercept);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java","line":40,"symbol":"InterceptorAdapter","kind":"class","lang":"java","code":"static class InterceptorAdapter extends TypeAdapter {\n private final TypeAdapter delegate;\n private final JsonPostDeserializer postDeserializer;\n\n @SuppressWarnings(\"unchecked\") // ?\n public InterceptorAdapter(TypeAdapter delegate, Intercept intercept) {\n try {\n this.delegate = delegate;\n this.postDeserializer = intercept.postDeserialize().getDeclaredConstructor().newInstance();\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate.write(out, value);\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n T result = delegate.read(in);\n postDeserializer.postDeserialize(result);\n return result;\n }\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java","line":44,"symbol":"InterceptorAdapter","kind":"constructor","lang":"java","code":"@SuppressWarnings(\"unchecked\") // ?\n public InterceptorAdapter(TypeAdapter delegate, Intercept intercept) {\n try {\n this.delegate = delegate;\n this.postDeserializer = intercept.postDeserialize().getDeclaredConstructor().newInstance();\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java","line":54,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate.write(out, value);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java","line":59,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n T result = delegate.read(in);\n postDeserializer.postDeserialize(result);\n return result;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java","line":27,"symbol":"JsonPostDeserializer","kind":"interface","lang":"java","doc":"This interface is implemented by a class that wishes to inspect or modify an object after it has been deserialized. You must define a no-args constructor or register an {@link InstanceCreator} for such a class. @author Inderjeet Singh","code":"public interface JsonPostDeserializer {\n\n /** This method is called by Gson after the object has been deserialized from JSON. */\n public void postDeserialize(T object);\n}"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java","line":30,"symbol":"postDeserialize","kind":"method","lang":"java","doc":"This method is called by Gson after the object has been deserialized from JSON.","code":"public void postDeserialize(T object);"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java","line":30,"symbol":"PostConstructAdapterFactory","kind":"class","lang":"java","code":"public class PostConstructAdapterFactory implements TypeAdapterFactory {\n // copied from https://gist.github.com/swankjesse/20df26adaf639ed7fd160f145a0b661a\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n for (Class t = type.getRawType();\n (t != Object.class) && (t.getSuperclass() != null);\n t = t.getSuperclass()) {\n for (Method m : t.getDeclaredMethods()) {\n if (m.isAnnotationPresent(PostConstruct.class)) {\n m.setAccessible(true);\n TypeAdapter delegate = gson.getDelegateAdapter(this, type);\n return new PostConstructAdapter<>(delegate, m);\n }\n }\n }\n return null;\n }\n\n static final class PostConstructAdapter extends TypeAdapter {\n private final TypeAdapter delegate;\n private final Method method;\n\n public PostConstructAdapter(TypeAdapter delegate, Method method) {\n this.delegate = delegate;\n this.method = method;\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n T result = delegate.read(in);\n if (result != null) {\n try {\n method.invoke(result);\n } catch (IllegalAccessException e) {\n "} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java","line":32,"symbol":"create","kind":"method","lang":"java","doc":"copied from https://gist.github.com/swankjesse/20df26adaf639ed7fd160f145a0b661a","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n for (Class t = type.getRawType();\n (t != Object.class) && (t.getSuperclass() != null);\n t = t.getSuperclass()) {\n for (Method m : t.getDeclaredMethods()) {\n if (m.isAnnotationPresent(PostConstruct.class)) {\n m.setAccessible(true);\n TypeAdapter delegate = gson.getDelegateAdapter(this, type);\n return new PostConstructAdapter<>(delegate, m);\n }\n }\n }\n return null;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java","line":48,"symbol":"PostConstructAdapter","kind":"class","lang":"java","code":"static final class PostConstructAdapter extends TypeAdapter {\n private final TypeAdapter delegate;\n private final Method method;\n\n public PostConstructAdapter(TypeAdapter delegate, Method method) {\n this.delegate = delegate;\n this.method = method;\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n T result = delegate.read(in);\n if (result != null) {\n try {\n method.invoke(result);\n } catch (IllegalAccessException e) {\n throw new AssertionError(e);\n } catch (InvocationTargetException e) {\n if (e.getCause() instanceof RuntimeException) {\n throw (RuntimeException) e.getCause();\n }\n throw new RuntimeException(e.getCause());\n }\n }\n return result;\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate.write(out, value);\n }\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java","line":52,"symbol":"PostConstructAdapter","kind":"constructor","lang":"java","code":"public PostConstructAdapter(TypeAdapter delegate, Method method) {\n this.delegate = delegate;\n this.method = method;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java","line":57,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n T result = delegate.read(in);\n if (result != null) {\n try {\n method.invoke(result);\n } catch (IllegalAccessException e) {\n throw new AssertionError(e);\n } catch (InvocationTargetException e) {\n if (e.getCause() instanceof RuntimeException) {\n throw (RuntimeException) e.getCause();\n }\n throw new RuntimeException(e.getCause());\n }\n }\n return result;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java","line":75,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate.write(out, value);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":158,"symbol":"RuntimeTypeAdapterFactory","kind":"class","lang":"java","doc":"And then:
{@code Shape shape = gson.fromJson(json, Shape.class); }
","code":"public final class RuntimeTypeAdapterFactory implements TypeAdapterFactory {\n private final Class baseType;\n private final String typeFieldName;\n private final Map> labelToSubtype = new LinkedHashMap<>();\n private final Map, String> subtypeToLabel = new LinkedHashMap<>();\n private final boolean maintainType;\n private boolean recognizeSubtypes;\n\n private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName, boolean maintainType) {\n if (typeFieldName == null || baseType == null) {\n throw new NullPointerException();\n }\n this.baseType = baseType;\n this.typeFieldName = typeFieldName;\n this.maintainType = maintainType;\n }\n\n /**\n * Creates a new runtime type adapter for {@code baseType} using {@code typeFieldName} as the type\n * field name. Type field names are case sensitive.\n *\n * @param maintainType true if the type field should be included in deserialized objects\n */\n public static RuntimeTypeAdapterFactory of(\n Class baseType, String typeFieldName, boolean maintainType) {\n return new RuntimeTypeAdapterFactory<>(baseType, typeFieldName, maintainType);\n }\n\n /**\n * Creates a new ru"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":166,"symbol":"RuntimeTypeAdapterFactory","kind":"constructor","lang":"java","code":"private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName, boolean maintainType) {\n if (typeFieldName == null || baseType == null) {\n throw new NullPointerException();\n }\n this.baseType = baseType;\n this.typeFieldName = typeFieldName;\n this.maintainType = maintainType;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":181,"symbol":"of","kind":"method","lang":"java","doc":"Creates a new runtime type adapter for {@code baseType} using {@code typeFieldName} as the type field name. Type field names are case sensitive. @param maintainType true if the type field should be included in deserialized objects","code":"public static RuntimeTypeAdapterFactory of(\n Class baseType, String typeFieldName, boolean maintainType) {\n return new RuntimeTypeAdapterFactory<>(baseType, typeFieldName, maintainType);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":190,"symbol":"of","kind":"method","lang":"java","doc":"Creates a new runtime type adapter for {@code baseType} using {@code typeFieldName} as the type field name. Type field names are case sensitive.","code":"public static RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) {\n return new RuntimeTypeAdapterFactory<>(baseType, typeFieldName, false);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":198,"symbol":"of","kind":"method","lang":"java","doc":"Creates a new runtime type adapter for {@code baseType} using {@code \"type\"} as the type field name.","code":"public static RuntimeTypeAdapterFactory of(Class baseType) {\n return new RuntimeTypeAdapterFactory<>(baseType, \"type\", false);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":206,"symbol":"recognizeSubtypes","kind":"method","lang":"java","doc":"Ensures that this factory will handle not just the given {@code baseType}, but any subtype of that type.","code":"@CanIgnoreReturnValue\n public RuntimeTypeAdapterFactory recognizeSubtypes() {\n this.recognizeSubtypes = true;\n return this;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":218,"symbol":"registerSubtype","kind":"method","lang":"java","doc":"Registers {@code type} identified by {@code label}. Labels are case sensitive. @throws IllegalArgumentException if either {@code type} or {@code label} have already been registered on this type adapter.","code":"@CanIgnoreReturnValue\n public RuntimeTypeAdapterFactory registerSubtype(Class type, String label) {\n if (type == null || label == null) {\n throw new NullPointerException();\n }\n if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) {\n throw new IllegalArgumentException(\"types and labels must be unique\");\n }\n labelToSubtype.put(label, type);\n subtypeToLabel.put(type, label);\n return this;\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":238,"symbol":"registerSubtype","kind":"method","lang":"java","doc":"Registers {@code type} identified by its {@link Class#getSimpleName simple name}. Labels are case sensitive. @throws IllegalArgumentException if either {@code type} or its simple name have already been registered on this type adapter.","code":"@CanIgnoreReturnValue\n public RuntimeTypeAdapterFactory registerSubtype(Class type) {\n return registerSubtype(type, type.getSimpleName());\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":243,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n if (type == null) {\n return null;\n }\n Class rawType = type.getRawType();\n boolean handle =\n recognizeSubtypes ? baseType.isAssignableFrom(rawType) : baseType.equals(rawType);\n if (!handle) {\n return null;\n }\n\n TypeAdapter jsonElementAdapter = gson.getAdapter(JsonElement.class);\n Map> labelToDelegate = new LinkedHashMap<>();\n Map, TypeAdapter> subtypeToDelegate = new LinkedHashMap<>();\n for (Map.Entry> entry : labelToSubtype.entrySet()) {\n TypeAdapter delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue()));\n labelToDelegate.put(entry.getKey(), delegate);\n subtypeToDelegate.put(entry.getValue(), delegate);\n }\n\n return new TypeAdapter() {\n @Override\n public R read(JsonReader in) throws IOException {\n JsonElement jsonElement = jsonElementAdapter.read(in);\n JsonElement labelJsonElement;\n if (maintainType) {\n labelJsonElement = jsonElement.getAsJsonObject().get(typeFieldName);\n } else {\n labelJsonEl"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":265,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public R read(JsonReader in) throws IOException {\n JsonElement jsonElement = jsonElementAdapter.read(in);\n JsonElement labelJsonElement;\n if (maintainType) {\n labelJsonElement = jsonElement.getAsJsonObject().get(typeFieldName);\n } else {\n labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName);\n }\n\n if (labelJsonElement == null) {\n throw new JsonParseException(\n \"cannot deserialize \"\n + baseType\n + \" because it does not define a field named \"\n + typeFieldName);\n }\n String label = labelJsonElement.getAsString();\n @SuppressWarnings(\"unchecked\") // registration requires that subtype extends T\n TypeAdapter delegate = (TypeAdapter) labelToDelegate.get(label);\n if (delegate == null) {\n throw new JsonParseException(\n \"cannot deserialize \"\n + baseType\n + \" subtype named \"\n + label\n + \"; did you forget to register a subtype?\");\n }\n return delegate.fromJsonTree(jsonElement);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java","line":296,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, R value) throws IOException {\n Class srcType = value.getClass();\n String label = subtypeToLabel.get(srcType);\n @SuppressWarnings(\"unchecked\") // registration requires that subtype extends T\n TypeAdapter delegate = (TypeAdapter) subtypeToDelegate.get(srcType);\n if (delegate == null) {\n throw new JsonParseException(\n \"cannot serialize \" + srcType.getName() + \"; did you forget to register a subtype?\");\n }\n JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject();\n\n if (maintainType) {\n jsonElementAdapter.write(out, jsonObject);\n return;\n }\n\n JsonObject clone = new JsonObject();\n\n if (jsonObject.has(typeFieldName)) {\n throw new JsonParseException(\n \"cannot serialize \"\n + srcType.getName()\n + \" because it already defines a field named \"\n + typeFieldName);\n }\n clone.add(typeFieldName, new JsonPrimitive(label));\n\n for (Map.Entry e : jsonObject.entrySet()) {\n clone.add(e.getKey(), e."} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":33,"symbol":"UtcDateTypeAdapter","kind":"class","lang":"java","code":"public final class UtcDateTypeAdapter extends TypeAdapter {\n private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone(\"UTC\");\n\n @Override\n public void write(JsonWriter out, Date date) throws IOException {\n if (date == null) {\n out.nullValue();\n } else {\n String value = format(date, true, UTC_TIME_ZONE);\n out.value(value);\n }\n }\n\n @Override\n public Date read(JsonReader in) throws IOException {\n try {\n if (in.peek().equals(JsonToken.NULL)) {\n in.nextNull();\n return null;\n } else {\n String date = in.nextString();\n // Instead of using iso8601Format.parse(value), we use Jackson's date parsing\n // This is because Android doesn't support XXX because it is JDK 1.6\n return parse(date, new ParsePosition(0));\n }\n } catch (ParseException e) {\n throw new JsonParseException(e);\n }\n }\n\n // Date parsing code from Jackson databind ISO8601Utils.java\n // https://github.com/FasterXML/jackson-databind/blob/2.8/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java\n private static final String GMT_ID = \"GMT\";\n\n /**\n * Format date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":36,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Date date) throws IOException {\n if (date == null) {\n out.nullValue();\n } else {\n String value = format(date, true, UTC_TIME_ZONE);\n out.value(value);\n }\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":46,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Date read(JsonReader in) throws IOException {\n try {\n if (in.peek().equals(JsonToken.NULL)) {\n in.nextNull();\n return null;\n } else {\n String date = in.nextString();\n // Instead of using iso8601Format.parse(value), we use Jackson's date parsing\n // This is because Android doesn't support XXX because it is JDK 1.6\n return parse(date, new ParsePosition(0));\n }\n } catch (ParseException e) {\n throw new JsonParseException(e);\n }\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":75,"symbol":"format","kind":"method","lang":"java","doc":"@param date the date to format @param millis true to include millis precision otherwise false @param tz timezone to use for the formatting (GMT will produce 'Z') @return the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]","code":"private static String format(Date date, boolean millis, TimeZone tz) {\n Calendar calendar = new GregorianCalendar(tz, Locale.US);\n calendar.setTime(date);\n\n // estimate capacity of buffer as close as we can (yeah, that's pedantic ;)\n int capacity = \"yyyy-MM-ddThh:mm:ss\".length();\n capacity += millis ? \".sss\".length() : 0;\n capacity += tz.getRawOffset() == 0 ? \"Z\".length() : \"+hh:mm\".length();\n StringBuilder formatted = new StringBuilder(capacity);\n\n padInt(formatted, calendar.get(Calendar.YEAR), \"yyyy\".length());\n formatted.append('-');\n padInt(formatted, calendar.get(Calendar.MONTH) + 1, \"MM\".length());\n formatted.append('-');\n padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), \"dd\".length());\n formatted.append('T');\n padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), \"hh\".length());\n formatted.append(':');\n padInt(formatted, calendar.get(Calendar.MINUTE), \"mm\".length());\n formatted.append(':');\n padInt(formatted, calendar.get(Calendar.SECOND), \"ss\".length());\n if (millis) {\n formatted.append('.');\n padInt(formatted, calendar.get(Calendar.MILLISECOND), \"sss\".length());\n }\n\n int offset = tz.getOffset(ca"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":123,"symbol":"padInt","kind":"method","lang":"java","doc":"Zero pad a number to a specified length @param buffer buffer to use for padding @param value the integer value to pad if necessary. @param length the length of the string we should zero pad","code":"private static void padInt(StringBuilder buffer, int value, int length) {\n String strValue = Integer.toString(value);\n for (int i = length - strValue.length(); i > 0; i--) {\n buffer.append('0');\n }\n buffer.append(strValue);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":140,"symbol":"parse","kind":"method","lang":"java","doc":"@param date ISO string to parse in the appropriate format. @param pos The position to start parsing from, updated to where parsing stopped. @return the parsed date @throws ParseException if the date is not in the appropriate format","code":"private static Date parse(String date, ParsePosition pos) throws ParseException {\n Exception fail = null;\n try {\n int offset = pos.getIndex();\n\n // extract year\n int year = parseInt(date, offset, offset += 4);\n if (checkOffset(date, offset, '-')) {\n offset += 1;\n }\n\n // extract month\n int month = parseInt(date, offset, offset += 2);\n if (checkOffset(date, offset, '-')) {\n offset += 1;\n }\n\n // extract day\n int day = parseInt(date, offset, offset += 2);\n // default time value\n int hour = 0;\n int minutes = 0;\n int seconds = 0;\n // always use 0 otherwise returned date will include millis of current time\n int milliseconds = 0;\n if (checkOffset(date, offset, 'T')) {\n\n // extract hours, minutes, seconds and milliseconds\n hour = parseInt(date, offset += 1, offset += 2);\n if (checkOffset(date, offset, ':')) {\n offset += 1;\n }\n\n minutes = parseInt(date, offset, offset += 2);\n if (checkOffset(date, offset, ':')) {\n offset += 1;\n }\n // second and milliseconds can be optional\n if (date.length() > offset) {\n"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":242,"symbol":"checkOffset","kind":"method","lang":"java","doc":"@param value the string to check at the specified offset @param offset the offset to look for the expected character @param expected the expected character @return true if the expected character exist at the given offset","code":"private static boolean checkOffset(String value, int offset, char expected) {\n return (offset < value.length()) && (value.charAt(offset) == expected);\n }"} {"repo":"gson","file":"extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java","line":255,"symbol":"parseInt","kind":"method","lang":"java","doc":"@param value the string to parse @param beginIndex the start index for the integer in the string @param endIndex the end index for the integer in the string @return the int @throws NumberFormatException if the value is not a number","code":"private static int parseInt(String value, int beginIndex, int endIndex)\n throws NumberFormatException {\n if (beginIndex < 0 || endIndex > value.length() || beginIndex > endIndex) {\n throw new NumberFormatException(value);\n }\n // use same logic as in Integer.parseInt() but less generic we're not supporting negative values\n int i = beginIndex;\n int result = 0;\n int digit;\n if (i < endIndex) {\n digit = Character.digit(value.charAt(i++), 10);\n if (digit < 0) {\n throw new NumberFormatException(\"Invalid number: \" + value);\n }\n result = -digit;\n }\n while (i < endIndex) {\n digit = Character.digit(value.charAt(i++), 10);\n if (digit < 0) {\n throw new NumberFormatException(\"Invalid number: \" + value);\n }\n result *= 10;\n result -= digit;\n }\n return -result;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":43,"symbol":"InterceptorTest","kind":"class","lang":"java","doc":"Unit tests for {@link Intercept} and {@link JsonPostDeserializer}. @author Inderjeet Singh","code":"public final class InterceptorTest {\n\n private Gson gson;\n\n @Before\n public void setUp() throws Exception {\n this.gson =\n new GsonBuilder()\n .registerTypeAdapterFactory(new InterceptorFactory())\n .enableComplexMapKeySerialization()\n .create();\n }\n\n @Test\n public void testExceptionsPropagated() {\n var e = assertThrows(JsonParseException.class, () -> gson.fromJson(\"{}\", User.class));\n assertThat(e).hasMessageThat().isEqualTo(\"name and password are required fields.\");\n }\n\n @Test\n public void testTopLevelClass() {\n User user = gson.fromJson(\"{name:'bob',password:'pwd'}\", User.class);\n assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);\n }\n\n @Test\n public void testList() {\n List list =\n gson.fromJson(\"[{name:'bob',password:'pwd'}]\", new TypeToken>() {}.getType());\n User user = list.get(0);\n assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);\n }\n\n @Test\n public void testCollection() {\n Collection list =\n gson.fromJson(\n \"[{name:'bob',password:'pwd'}]\", new TypeToken>() {}.getType());\n User user = list.iterator().next();\n assertThat(u"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":47,"symbol":"setUp","kind":"method","lang":"java","code":"@Before\n public void setUp() throws Exception {\n this.gson =\n new GsonBuilder()\n .registerTypeAdapterFactory(new InterceptorFactory())\n .enableComplexMapKeySerialization()\n .create();\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":56,"symbol":"testExceptionsPropagated","kind":"method","lang":"java","code":"@Test\n public void testExceptionsPropagated() {\n var e = assertThrows(JsonParseException.class, () -> gson.fromJson(\"{}\", User.class));\n assertThat(e).hasMessageThat().isEqualTo(\"name and password are required fields.\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":62,"symbol":"testTopLevelClass","kind":"method","lang":"java","code":"@Test\n public void testTopLevelClass() {\n User user = gson.fromJson(\"{name:'bob',password:'pwd'}\", User.class);\n assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":68,"symbol":"testList","kind":"method","lang":"java","code":"@Test\n public void testList() {\n List list =\n gson.fromJson(\"[{name:'bob',password:'pwd'}]\", new TypeToken>() {}.getType());\n User user = list.get(0);\n assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":76,"symbol":"testCollection","kind":"method","lang":"java","code":"@Test\n public void testCollection() {\n Collection list =\n gson.fromJson(\n \"[{name:'bob',password:'pwd'}]\", new TypeToken>() {}.getType());\n User user = list.iterator().next();\n assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":85,"symbol":"testMapKeyAndValues","kind":"method","lang":"java","code":"@Test\n public void testMapKeyAndValues() {\n Type mapType = new TypeToken>() {}.getType();\n var e =\n assertThrows(\n JsonSyntaxException.class,\n () -> gson.fromJson(\"[[{name:'bob',password:'pwd'},{}]]\", mapType));\n assertThat(e).hasMessageThat().isEqualTo(\"Address city, state and zip are required fields.\");\n\n Map map =\n gson.fromJson(\n \"[[{name:'bob',password:'pwd'},{city:'Mountain View',state:'CA',zip:'94043'}]]\",\n mapType);\n Entry entry = map.entrySet().iterator().next();\n assertThat(entry.getKey().email).isEqualTo(User.DEFAULT_EMAIL);\n assertThat(entry.getValue().firstLine).isEqualTo(Address.DEFAULT_FIRST_LINE);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":103,"symbol":"testField","kind":"method","lang":"java","code":"@Test\n public void testField() {\n UserGroup userGroup = gson.fromJson(\"{user:{name:'bob',password:'pwd'}}\", UserGroup.class);\n assertThat(userGroup.user.email).isEqualTo(User.DEFAULT_EMAIL);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":109,"symbol":"testCustomTypeAdapter","kind":"method","lang":"java","code":"@Test\n public void testCustomTypeAdapter() {\n Gson gson =\n new GsonBuilder()\n .registerTypeAdapter(\n User.class,\n new TypeAdapter() {\n @Override\n public void write(JsonWriter out, User value) throws IOException {\n throw new UnsupportedOperationException();\n }\n\n @Override\n public User read(JsonReader in) throws IOException {\n in.beginObject();\n assertThat(in.nextName()).isEqualTo(\"name\");\n String name = in.nextString();\n assertThat(in.nextName()).isEqualTo(\"password\");\n String password = in.nextString();\n in.endObject();\n return new User(name, password);\n }\n })\n .registerTypeAdapterFactory(new InterceptorFactory())\n .create();\n UserGroup userGroup = gson.fromJson(\"{user:{name:'bob',password:'pwd'}}\", UserGroup.class);\n assertThat(userGroup.user.email).isEqualTo(User.DEFAULT_EMAIL);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":116,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, User value) throws IOException {\n throw new UnsupportedOperationException();\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":121,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public User read(JsonReader in) throws IOException {\n in.beginObject();\n assertThat(in.nextName()).isEqualTo(\"name\");\n String name = in.nextString();\n assertThat(in.nextName()).isEqualTo(\"password\");\n String password = in.nextString();\n in.endObject();\n return new User(name, password);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":138,"symbol":"testDirectInvocationOfTypeAdapter","kind":"method","lang":"java","code":"@Test\n public void testDirectInvocationOfTypeAdapter() throws Exception {\n TypeAdapter adapter = gson.getAdapter(UserGroup.class);\n UserGroup userGroup = adapter.fromJson(\"{\\\"user\\\":{\\\"name\\\":\\\"bob\\\",\\\"password\\\":\\\"pwd\\\"}}\");\n assertThat(userGroup.user.email).isEqualTo(User.DEFAULT_EMAIL);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":145,"symbol":"UserGroup","kind":"class","lang":"java","code":"@SuppressWarnings(\"unused\")\n private static final class UserGroup {\n User user;\n String city;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":151,"symbol":"User","kind":"class","lang":"java","code":"@Intercept(postDeserialize = UserValidator.class)\n @SuppressWarnings(\"unused\")\n private static final class User {\n static final String DEFAULT_EMAIL = \"invalid@invalid.com\";\n String name;\n String password;\n String email;\n Address address;\n\n User(String name, String password) {\n this.name = name;\n this.password = password;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":160,"symbol":"User","kind":"constructor","lang":"java","code":"User(String name, String password) {\n this.name = name;\n this.password = password;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":166,"symbol":"UserValidator","kind":"class","lang":"java","code":"@SuppressWarnings(\"ExposedPrivateType\")\n public static final class UserValidator implements JsonPostDeserializer {\n @Override\n public void postDeserialize(User user) {\n if (user.name == null || user.password == null) {\n throw new JsonSyntaxException(\"name and password are required fields.\");\n }\n if (user.email == null) {\n user.email = User.DEFAULT_EMAIL;\n }\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":168,"symbol":"postDeserialize","kind":"method","lang":"java","code":"@Override\n public void postDeserialize(User user) {\n if (user.name == null || user.password == null) {\n throw new JsonSyntaxException(\"name and password are required fields.\");\n }\n if (user.email == null) {\n user.email = User.DEFAULT_EMAIL;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":179,"symbol":"Address","kind":"class","lang":"java","code":"@Intercept(postDeserialize = AddressValidator.class)\n @SuppressWarnings(\"unused\")\n private static final class Address {\n static final String DEFAULT_FIRST_LINE = \"unknown\";\n String firstLine;\n String secondLine;\n String city;\n String state;\n String zip;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":190,"symbol":"AddressValidator","kind":"class","lang":"java","code":"@SuppressWarnings(\"ExposedPrivateType\")\n public static final class AddressValidator implements JsonPostDeserializer
{\n @Override\n public void postDeserialize(Address address) {\n if (address.city == null || address.state == null || address.zip == null) {\n throw new JsonSyntaxException(\"Address city, state and zip are required fields.\");\n }\n if (address.firstLine == null) {\n address.firstLine = Address.DEFAULT_FIRST_LINE;\n }\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java","line":192,"symbol":"postDeserialize","kind":"method","lang":"java","code":"@Override\n public void postDeserialize(Address address) {\n if (address.city == null || address.state == null || address.zip == null) {\n throw new JsonSyntaxException(\"Address city, state and zip are required fields.\");\n }\n if (address.firstLine == null) {\n address.firstLine = Address.DEFAULT_FIRST_LINE;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":30,"symbol":"PostConstructAdapterFactoryTest","kind":"class","lang":"java","code":"public class PostConstructAdapterFactoryTest {\n @Test\n public void test() throws Exception {\n Gson gson =\n new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();\n Sandwich unused =\n gson.fromJson(\"{\\\"bread\\\": \\\"white\\\", \\\"cheese\\\": \\\"cheddar\\\"}\", Sandwich.class);\n\n var e =\n assertThrows(\n IllegalArgumentException.class,\n () ->\n gson.fromJson(\n \"{\\\"bread\\\": \\\"cheesey bread\\\", \\\"cheese\\\": \\\"swiss\\\"}\", Sandwich.class));\n assertThat(e).hasMessageThat().isEqualTo(\"too cheesey\");\n }\n\n @Test\n public void testList() {\n MultipleSandwiches sandwiches =\n new MultipleSandwiches(\n Arrays.asList(new Sandwich(\"white\", \"cheddar\"), new Sandwich(\"whole wheat\", \"swiss\")));\n\n Gson gson =\n new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();\n\n // Throws NullPointerException without the fix in https://github.com/google/gson/pull/1103\n String json = gson.toJson(sandwiches);\n assertThat(json)\n .isEqualTo(\n \"{\\\"sandwiches\\\":[{\\\"bread\\\":\\\"white\\\",\\\"cheese\\\":\\\"cheddar\\\"},\"\n "} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":31,"symbol":"test","kind":"method","lang":"java","code":"@Test\n public void test() throws Exception {\n Gson gson =\n new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();\n Sandwich unused =\n gson.fromJson(\"{\\\"bread\\\": \\\"white\\\", \\\"cheese\\\": \\\"cheddar\\\"}\", Sandwich.class);\n\n var e =\n assertThrows(\n IllegalArgumentException.class,\n () ->\n gson.fromJson(\n \"{\\\"bread\\\": \\\"cheesey bread\\\", \\\"cheese\\\": \\\"swiss\\\"}\", Sandwich.class));\n assertThat(e).hasMessageThat().isEqualTo(\"too cheesey\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":47,"symbol":"testList","kind":"method","lang":"java","code":"@Test\n public void testList() {\n MultipleSandwiches sandwiches =\n new MultipleSandwiches(\n Arrays.asList(new Sandwich(\"white\", \"cheddar\"), new Sandwich(\"whole wheat\", \"swiss\")));\n\n Gson gson =\n new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();\n\n // Throws NullPointerException without the fix in https://github.com/google/gson/pull/1103\n String json = gson.toJson(sandwiches);\n assertThat(json)\n .isEqualTo(\n \"{\\\"sandwiches\\\":[{\\\"bread\\\":\\\"white\\\",\\\"cheese\\\":\\\"cheddar\\\"},\"\n + \"{\\\"bread\\\":\\\"whole wheat\\\",\\\"cheese\\\":\\\"swiss\\\"}]}\");\n\n MultipleSandwiches sandwichesFromJson = gson.fromJson(json, MultipleSandwiches.class);\n assertThat(sandwichesFromJson).isEqualTo(sandwiches);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":67,"symbol":"Sandwich","kind":"class","lang":"java","code":"@SuppressWarnings({\"overrides\", \"EqualsHashCode\"}) // for missing hashCode() override\n static class Sandwich {\n public String bread;\n public String cheese;\n\n public Sandwich(String bread, String cheese) {\n this.bread = bread;\n this.cheese = cheese;\n }\n\n @PostConstruct\n private void validate() {\n if (bread.equals(\"cheesey bread\") && cheese != null) {\n throw new IllegalArgumentException(\"too cheesey\");\n }\n }\n\n @Override\n public boolean equals(Object o) {\n if (o == this) {\n return true;\n }\n if (!(o instanceof Sandwich)) {\n return false;\n }\n Sandwich other = (Sandwich) o;\n\n return Objects.equals(this.bread, other.bread) && Objects.equals(this.cheese, other.cheese);\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":72,"symbol":"Sandwich","kind":"constructor","lang":"java","code":"public Sandwich(String bread, String cheese) {\n this.bread = bread;\n this.cheese = cheese;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":77,"symbol":"validate","kind":"method","lang":"java","code":"@PostConstruct\n private void validate() {\n if (bread.equals(\"cheesey bread\") && cheese != null) {\n throw new IllegalArgumentException(\"too cheesey\");\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":84,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object o) {\n if (o == this) {\n return true;\n }\n if (!(o instanceof Sandwich)) {\n return false;\n }\n Sandwich other = (Sandwich) o;\n\n return Objects.equals(this.bread, other.bread) && Objects.equals(this.cheese, other.cheese);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":98,"symbol":"MultipleSandwiches","kind":"class","lang":"java","code":"@SuppressWarnings({\"overrides\", \"EqualsHashCode\"}) // for missing hashCode() override\n static class MultipleSandwiches {\n public List sandwiches;\n\n public MultipleSandwiches(List sandwiches) {\n this.sandwiches = sandwiches;\n }\n\n @Override\n public boolean equals(Object o) {\n if (o == this) {\n return true;\n }\n if (!(o instanceof MultipleSandwiches)) {\n return false;\n }\n MultipleSandwiches other = (MultipleSandwiches) o;\n\n return Objects.equals(this.sandwiches, other.sandwiches);\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":102,"symbol":"MultipleSandwiches","kind":"constructor","lang":"java","code":"public MultipleSandwiches(List sandwiches) {\n this.sandwiches = sandwiches;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java","line":106,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object o) {\n if (o == this) {\n return true;\n }\n if (!(o instanceof MultipleSandwiches)) {\n return false;\n }\n MultipleSandwiches other = (MultipleSandwiches) o;\n\n return Objects.equals(this.sandwiches, other.sandwiches);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":28,"symbol":"RuntimeTypeAdapterFactoryTest","kind":"class","lang":"java","code":"public final class RuntimeTypeAdapterFactoryTest {\n\n @Test\n public void testRuntimeTypeAdapter() {\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class).registerSubtype(CreditCard.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();\n\n CreditCard original = new CreditCard(\"Jesse\", 234);\n assertThat(gson.toJson(original, BillingInstrument.class))\n .isEqualTo(\"{\\\"type\\\":\\\"CreditCard\\\",\\\"cvv\\\":234,\\\"ownerName\\\":\\\"Jesse\\\"}\");\n BillingInstrument deserialized =\n gson.fromJson(\"{type:'CreditCard',cvv:234,ownerName:'Jesse'}\", BillingInstrument.class);\n assertThat(deserialized.ownerName).isEqualTo(\"Jesse\");\n assertThat(deserialized).isInstanceOf(CreditCard.class);\n }\n\n @Test\n public void testRuntimeTypeAdapterRecognizeSubtypes() {\n // We don't have an explicit factory for CreditCard.class, but we do have one for\n // BillingInstrument.class that has recognizeSubtypes(). So it should recognize CreditCard, and\n // when we call gson.toJson(original) below, without an explicit type, it should be invoked.\n RuntimeTypeAdapterFactory rta =\n "} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":30,"symbol":"testRuntimeTypeAdapter","kind":"method","lang":"java","code":"@Test\n public void testRuntimeTypeAdapter() {\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class).registerSubtype(CreditCard.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();\n\n CreditCard original = new CreditCard(\"Jesse\", 234);\n assertThat(gson.toJson(original, BillingInstrument.class))\n .isEqualTo(\"{\\\"type\\\":\\\"CreditCard\\\",\\\"cvv\\\":234,\\\"ownerName\\\":\\\"Jesse\\\"}\");\n BillingInstrument deserialized =\n gson.fromJson(\"{type:'CreditCard',cvv:234,ownerName:'Jesse'}\", BillingInstrument.class);\n assertThat(deserialized.ownerName).isEqualTo(\"Jesse\");\n assertThat(deserialized).isInstanceOf(CreditCard.class);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":45,"symbol":"testRuntimeTypeAdapterRecognizeSubtypes","kind":"method","lang":"java","code":"@Test\n public void testRuntimeTypeAdapterRecognizeSubtypes() {\n // We don't have an explicit factory for CreditCard.class, but we do have one for\n // BillingInstrument.class that has recognizeSubtypes(). So it should recognize CreditCard, and\n // when we call gson.toJson(original) below, without an explicit type, it should be invoked.\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class)\n .recognizeSubtypes()\n .registerSubtype(CreditCard.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();\n\n CreditCard original = new CreditCard(\"Jesse\", 234);\n assertThat(gson.toJson(original))\n .isEqualTo(\"{\\\"type\\\":\\\"CreditCard\\\",\\\"cvv\\\":234,\\\"ownerName\\\":\\\"Jesse\\\"}\");\n BillingInstrument deserialized =\n gson.fromJson(\"{type:'CreditCard',cvv:234,ownerName:'Jesse'}\", BillingInstrument.class);\n assertThat(deserialized.ownerName).isEqualTo(\"Jesse\");\n assertThat(deserialized).isInstanceOf(CreditCard.class);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":65,"symbol":"testRuntimeTypeIsBaseType","kind":"method","lang":"java","code":"@Test\n public void testRuntimeTypeIsBaseType() {\n TypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class)\n .registerSubtype(BillingInstrument.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();\n\n BillingInstrument original = new BillingInstrument(\"Jesse\");\n assertThat(gson.toJson(original, BillingInstrument.class))\n .isEqualTo(\"{\\\"type\\\":\\\"BillingInstrument\\\",\\\"ownerName\\\":\\\"Jesse\\\"}\");\n BillingInstrument deserialized =\n gson.fromJson(\"{type:'BillingInstrument',ownerName:'Jesse'}\", BillingInstrument.class);\n assertThat(deserialized.ownerName).isEqualTo(\"Jesse\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":80,"symbol":"testNullBaseType","kind":"method","lang":"java","code":"@Test\n public void testNullBaseType() {\n assertThrows(NullPointerException.class, () -> RuntimeTypeAdapterFactory.of(null));\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":85,"symbol":"testNullTypeFieldName","kind":"method","lang":"java","code":"@Test\n public void testNullTypeFieldName() {\n assertThrows(\n NullPointerException.class,\n () -> RuntimeTypeAdapterFactory.of(BillingInstrument.class, null));\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":92,"symbol":"testNullSubtype","kind":"method","lang":"java","code":"@Test\n public void testNullSubtype() {\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class);\n assertThrows(NullPointerException.class, () -> rta.registerSubtype(null));\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":99,"symbol":"testNullLabel","kind":"method","lang":"java","code":"@Test\n public void testNullLabel() {\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class);\n assertThrows(NullPointerException.class, () -> rta.registerSubtype(CreditCard.class, null));\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":106,"symbol":"testDuplicateSubtype","kind":"method","lang":"java","code":"@Test\n public void testDuplicateSubtype() {\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class);\n rta.registerSubtype(CreditCard.class, \"CC\");\n var e =\n assertThrows(\n IllegalArgumentException.class, () -> rta.registerSubtype(CreditCard.class, \"Visa\"));\n assertThat(e).hasMessageThat().isEqualTo(\"types and labels must be unique\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":117,"symbol":"testDuplicateLabel","kind":"method","lang":"java","code":"@Test\n public void testDuplicateLabel() {\n RuntimeTypeAdapterFactory rta =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class);\n rta.registerSubtype(CreditCard.class, \"CC\");\n var e =\n assertThrows(\n IllegalArgumentException.class, () -> rta.registerSubtype(BankTransfer.class, \"CC\"));\n assertThat(e).hasMessageThat().isEqualTo(\"types and labels must be unique\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":128,"symbol":"testDeserializeMissingTypeField","kind":"method","lang":"java","code":"@Test\n public void testDeserializeMissingTypeField() {\n TypeAdapterFactory billingAdapter =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class).registerSubtype(CreditCard.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(billingAdapter).create();\n var e =\n assertThrows(\n JsonParseException.class,\n () -> gson.fromJson(\"{ownerName:'Jesse'}\", BillingInstrument.class));\n assertThat(e)\n .hasMessageThat()\n .isEqualTo(\n \"cannot deserialize \"\n + BillingInstrument.class\n + \" because it does not define a field named type\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":145,"symbol":"testDeserializeMissingSubtype","kind":"method","lang":"java","code":"@Test\n public void testDeserializeMissingSubtype() {\n TypeAdapterFactory billingAdapter =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class).registerSubtype(BankTransfer.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(billingAdapter).create();\n var e =\n assertThrows(\n JsonParseException.class,\n () -> gson.fromJson(\"{type:'CreditCard',ownerName:'Jesse'}\", BillingInstrument.class));\n assertThat(e)\n .hasMessageThat()\n .isEqualTo(\n \"cannot deserialize \"\n + BillingInstrument.class\n + \" subtype named CreditCard; did you forget to register a subtype?\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":162,"symbol":"testSerializeMissingSubtype","kind":"method","lang":"java","code":"@Test\n public void testSerializeMissingSubtype() {\n TypeAdapterFactory billingAdapter =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class).registerSubtype(BankTransfer.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(billingAdapter).create();\n CreditCard value = new CreditCard(\"Jesse\", 456);\n var e =\n assertThrows(JsonParseException.class, () -> gson.toJson(value, BillingInstrument.class));\n assertThat(e)\n .hasMessageThat()\n .isEqualTo(\n \"cannot serialize \"\n + CreditCard.class.getName()\n + \"; did you forget to register a subtype?\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":178,"symbol":"testSerializeCollidingTypeFieldName","kind":"method","lang":"java","code":"@Test\n public void testSerializeCollidingTypeFieldName() {\n TypeAdapterFactory billingAdapter =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class, \"cvv\")\n .registerSubtype(CreditCard.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(billingAdapter).create();\n CreditCard value = new CreditCard(\"Jesse\", 456);\n var e =\n assertThrows(JsonParseException.class, () -> gson.toJson(value, BillingInstrument.class));\n assertThat(e)\n .hasMessageThat()\n .isEqualTo(\n \"cannot serialize \"\n + CreditCard.class.getName()\n + \" because it already defines a field named cvv\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":195,"symbol":"testSerializeWrappedNullValue","kind":"method","lang":"java","code":"@Test\n public void testSerializeWrappedNullValue() {\n TypeAdapterFactory billingAdapter =\n RuntimeTypeAdapterFactory.of(BillingInstrument.class)\n .registerSubtype(CreditCard.class)\n .registerSubtype(BankTransfer.class);\n Gson gson = new GsonBuilder().registerTypeAdapterFactory(billingAdapter).create();\n String serialized =\n gson.toJson(new BillingInstrumentWrapper(null), BillingInstrumentWrapper.class);\n BillingInstrumentWrapper deserialized =\n gson.fromJson(serialized, BillingInstrumentWrapper.class);\n assertThat(deserialized.instrument).isNull();\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":209,"symbol":"BillingInstrumentWrapper","kind":"class","lang":"java","code":"static class BillingInstrumentWrapper {\n BillingInstrument instrument;\n\n BillingInstrumentWrapper(BillingInstrument instrument) {\n this.instrument = instrument;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":212,"symbol":"BillingInstrumentWrapper","kind":"constructor","lang":"java","code":"BillingInstrumentWrapper(BillingInstrument instrument) {\n this.instrument = instrument;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":217,"symbol":"BillingInstrument","kind":"class","lang":"java","code":"static class BillingInstrument {\n private final String ownerName;\n\n BillingInstrument(String ownerName) {\n this.ownerName = ownerName;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":220,"symbol":"BillingInstrument","kind":"constructor","lang":"java","code":"BillingInstrument(String ownerName) {\n this.ownerName = ownerName;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":225,"symbol":"CreditCard","kind":"class","lang":"java","code":"static class CreditCard extends BillingInstrument {\n int cvv;\n\n CreditCard(String ownerName, int cvv) {\n super(ownerName);\n this.cvv = cvv;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":228,"symbol":"CreditCard","kind":"constructor","lang":"java","code":"CreditCard(String ownerName, int cvv) {\n super(ownerName);\n this.cvv = cvv;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":234,"symbol":"BankTransfer","kind":"class","lang":"java","code":"static class BankTransfer extends BillingInstrument {\n int bankAccount;\n\n BankTransfer(String ownerName, int bankAccount) {\n super(ownerName);\n this.bankAccount = bankAccount;\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java","line":237,"symbol":"BankTransfer","kind":"constructor","lang":"java","code":"BankTransfer(String ownerName, int bankAccount) {\n super(ownerName);\n this.bankAccount = bankAccount;\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":32,"symbol":"UtcDateTypeAdapterTest","kind":"class","lang":"java","code":"@SuppressWarnings(\"JavaUtilDate\")\npublic final class UtcDateTypeAdapterTest {\n private final Gson gson =\n new GsonBuilder().registerTypeAdapter(Date.class, new UtcDateTypeAdapter()).create();\n\n @Test\n public void testLocalTimeZone() {\n Date expected = new Date();\n String json = gson.toJson(expected);\n Date actual = gson.fromJson(json, Date.class);\n assertThat(actual.getTime()).isEqualTo(expected.getTime());\n }\n\n @Test\n public void testDifferentTimeZones() {\n for (String timeZone : TimeZone.getAvailableIDs()) {\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZone));\n Date expected = cal.getTime();\n String json = gson.toJson(expected);\n // System.out.println(json + \": \" + timeZone);\n Date actual = gson.fromJson(json, Date.class);\n assertThat(actual.getTime()).isEqualTo(expected.getTime());\n }\n }\n\n /**\n * JDK 1.7 introduced support for XXX format to indicate UTC date. But Android is older JDK. We\n * want to make sure that this date is parseable in Android.\n */\n @Test\n public void testUtcDatesOnJdkBefore1_7() {\n Gson gson =\n new GsonBuilder().registerTypeAdapter(Date.class, new UtcDateTypeAdapt"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":37,"symbol":"testLocalTimeZone","kind":"method","lang":"java","code":"@Test\n public void testLocalTimeZone() {\n Date expected = new Date();\n String json = gson.toJson(expected);\n Date actual = gson.fromJson(json, Date.class);\n assertThat(actual.getTime()).isEqualTo(expected.getTime());\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":45,"symbol":"testDifferentTimeZones","kind":"method","lang":"java","code":"@Test\n public void testDifferentTimeZones() {\n for (String timeZone : TimeZone.getAvailableIDs()) {\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZone));\n Date expected = cal.getTime();\n String json = gson.toJson(expected);\n // System.out.println(json + \": \" + timeZone);\n Date actual = gson.fromJson(json, Date.class);\n assertThat(actual.getTime()).isEqualTo(expected.getTime());\n }\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":61,"symbol":"testUtcDatesOnJdkBefore1_7","kind":"method","lang":"java","doc":"JDK 1.7 introduced support for XXX format to indicate UTC date. But Android is older JDK. We want to make sure that this date is parseable in Android.","code":"@Test\n public void testUtcDatesOnJdkBefore1_7() {\n Gson gson =\n new GsonBuilder().registerTypeAdapter(Date.class, new UtcDateTypeAdapter()).create();\n Date date = gson.fromJson(\"'2014-12-05T04:00:00.000Z'\", Date.class);\n assertThat(date.getTime()).isEqualTo(1417752000000L);\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":69,"symbol":"testUtcWithJdk7Default","kind":"method","lang":"java","code":"@Test\n public void testUtcWithJdk7Default() {\n Date expected = new Date();\n SimpleDateFormat iso8601Format =\n new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSXXX\", Locale.US);\n iso8601Format.setTimeZone(TimeZone.getTimeZone(\"UTC\"));\n String expectedJson = \"\\\"\" + iso8601Format.format(expected) + \"\\\"\";\n String actualJson = gson.toJson(expected);\n assertThat(actualJson).isEqualTo(expectedJson);\n Date actual = gson.fromJson(expectedJson, Date.class);\n assertThat(actual.getTime()).isEqualTo(expected.getTime());\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":82,"symbol":"testNullDateSerialization","kind":"method","lang":"java","code":"@Test\n public void testNullDateSerialization() {\n String json = gson.toJson(null, Date.class);\n assertThat(json).isEqualTo(\"null\");\n }"} {"repo":"gson","file":"extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java","line":88,"symbol":"testWellFormedParseException","kind":"method","lang":"java","code":"@Test\n public void testWellFormedParseException() {\n var e =\n assertThrows(\n JsonParseException.class, () -> gson.fromJson(\"2017-06-20T14:32:30\", Date.class));\n assertThat(e)\n .hasMessageThat()\n .isEqualTo(\n \"java.text.ParseException: Failed to parse date ['2017-06-20T14']: 2017-06-20T14\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ExclusionStrategy.java","line":94,"symbol":"ExclusionStrategy","kind":"interface","lang":"java","doc":"@author Joel Leitch @see GsonBuilder#setExclusionStrategies(ExclusionStrategy...) @see GsonBuilder#addDeserializationExclusionStrategy(ExclusionStrategy) @see GsonBuilder#addSerializationExclusionStrategy(ExclusionStrategy) @since 1.4","code":"public interface ExclusionStrategy {\n\n /**\n * Decides if a field should be skipped during serialization or deserialization.\n *\n * @param f the field object that is under test\n * @return true if the field should be ignored; otherwise false\n */\n boolean shouldSkipField(FieldAttributes f);\n\n /**\n * Decides if a class should be serialized or deserialized\n *\n * @param clazz the class object that is under test\n * @return true if the class should be ignored; otherwise false\n */\n boolean shouldSkipClass(Class clazz);\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ExclusionStrategy.java","line":102,"symbol":"shouldSkipField","kind":"method","lang":"java","doc":"Decides if a field should be skipped during serialization or deserialization. @param f the field object that is under test @return true if the field should be ignored; otherwise false","code":"boolean shouldSkipField(FieldAttributes f);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ExclusionStrategy.java","line":110,"symbol":"shouldSkipClass","kind":"method","lang":"java","doc":"Decides if a class should be serialized or deserialized @param clazz the class object that is under test @return true if the class should be ignored; otherwise false","code":"boolean shouldSkipClass(Class clazz);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":35,"symbol":"FieldAttributes","kind":"class","lang":"java","doc":"

This class is immutable; therefore, it can be safely shared across threads. @author Inderjeet Singh @author Joel Leitch @since 1.4","code":"public final class FieldAttributes {\n private final Field field;\n\n /**\n * Constructs a Field Attributes object from the {@code f}.\n *\n * @param f the field to pull attributes from\n */\n public FieldAttributes(Field f) {\n this.field = Objects.requireNonNull(f);\n }\n\n /**\n * Gets the declaring Class that contains this field\n *\n * @return the declaring class that contains this field\n */\n public Class getDeclaringClass() {\n return field.getDeclaringClass();\n }\n\n /**\n * Gets the name of the field\n *\n * @return the name of the field\n */\n public String getName() {\n return field.getName();\n }\n\n /**\n * Returns the declared generic type of the field.\n *\n *

For example, assume the following class definition:\n *\n *

\n   * public class Foo {\n   *   private String bar;\n   *   private List<String> red;\n   * }\n   *\n   * Type listParameterizedType = new TypeToken<List<String>>() {}.getType();\n   * 
\n *\n *

This method would return {@code String.class} for the {@code bar} field and {@code\n * listParameterizedType} for the {@code red} field.\n *\n * @return the specific type declared for this f"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":43,"symbol":"FieldAttributes","kind":"constructor","lang":"java","doc":"Constructs a Field Attributes object from the {@code f}. @param f the field to pull attributes from","code":"public FieldAttributes(Field f) {\n this.field = Objects.requireNonNull(f);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":52,"symbol":"getDeclaringClass","kind":"method","lang":"java","doc":"Gets the declaring Class that contains this field @return the declaring class that contains this field","code":"public Class getDeclaringClass() {\n return field.getDeclaringClass();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":61,"symbol":"getName","kind":"method","lang":"java","doc":"Gets the name of the field @return the name of the field","code":"public String getName() {\n return field.getName();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":84,"symbol":"getDeclaredType","kind":"method","lang":"java","doc":"

This method would return {@code String.class} for the {@code bar} field and {@code listParameterizedType} for the {@code red} field. @return the specific type declared for this field","code":"public Type getDeclaredType() {\n return field.getGenericType();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":105,"symbol":"getDeclaredClass","kind":"method","lang":"java","doc":"

This method would return {@code String.class} for the {@code bar} field and {@code List.class} for the {@code red} field. @return the specific class object that was declared for the field","code":"public Class getDeclaredClass() {\n return field.getType();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":116,"symbol":"getAnnotation","kind":"method","lang":"java","doc":"Returns the {@code T} annotation object from this field if it exists; otherwise returns {@code null}. @param annotation the class of the annotation that will be retrieved @return the annotation instance if it is bound to the field; otherwise {@code null}","code":"public T getAnnotation(Class annotation) {\n return field.getAnnotation(annotation);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":126,"symbol":"getAnnotations","kind":"method","lang":"java","doc":"Returns the annotations that are present on this field. @return an array of all the annotations set on the field @since 1.4","code":"public Collection getAnnotations() {\n return Arrays.asList(field.getAnnotations());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":141,"symbol":"hasModifier","kind":"method","lang":"java","doc":"

 boolean hasPublicModifier = fieldAttribute.hasModifier(java.lang.reflect.Modifier.PUBLIC); 
@see java.lang.reflect.Modifier","code":"public boolean hasModifier(int modifier) {\n return (field.getModifiers() & modifier) != 0;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldAttributes.java","line":145,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return field.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":31,"symbol":"FieldNamingPolicy","kind":"type","lang":"java","doc":"instance to properly translate Java field names into the desired JSON field names. @see GsonBuilder#setFieldNamingStrategy(FieldNamingStrategy) @author Inderjeet Singh @author Joel Leitch","code":"public enum FieldNamingPolicy implements FieldNamingStrategy {\n\n /** Using this naming policy with Gson will ensure that the field name is unchanged. */\n IDENTITY() {\n @Override\n public String translateName(Field f) {\n return f.getName();\n }\n },\n\n /**\n * Using this naming policy with Gson will ensure that the first \"letter\" of the Java field name\n * is capitalized when serialized to its JSON form.\n *\n *

Here are a few examples of the form \"Java Field Name\" ---> \"JSON Field Name\":\n *\n *

    \n *
  • someFieldName ---> SomeFieldName\n *
  • _someFieldName ---> _SomeFieldName\n *
\n */\n UPPER_CAMEL_CASE() {\n @Override\n public String translateName(Field f) {\n return upperCaseFirstLetter(f.getName());\n }\n },\n\n /**\n * Using this naming policy with Gson will ensure that the first \"letter\" of the Java field name\n * is capitalized when serialized to its JSON form and the words will be separated by a space.\n *\n *

Here are a few examples of the form \"Java Field Name\" ---> \"JSON Field Name\":\n *\n *

    \n *
  • someFieldName ---> Some Field Name\n *
  • _someFieldName ---> _Some Field Name\n *"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":35,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return f.getName();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":53,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return upperCaseFirstLetter(f.getName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":73,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return upperCaseFirstLetter(separateCamelCase(f.getName(), ' '));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":95,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return separateCamelCase(f.getName(), '_').toUpperCase(Locale.ENGLISH);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":115,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return separateCamelCase(f.getName(), '_').toLowerCase(Locale.ENGLISH);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":142,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return separateCamelCase(f.getName(), '-').toLowerCase(Locale.ENGLISH);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":169,"symbol":"translateName","kind":"method","lang":"java","code":"@Override\n public String translateName(Field f) {\n return separateCamelCase(f.getName(), '.').toLowerCase(Locale.ENGLISH);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":179,"symbol":"separateCamelCase","kind":"method","lang":"java","doc":"Converts the field name that uses camel-case define word separation into separate words that are separated by the provided {@code separator}.","code":"static String separateCamelCase(String name, char separator) {\n StringBuilder translation = new StringBuilder();\n for (int i = 0, length = name.length(); i < length; i++) {\n char character = name.charAt(i);\n if (Character.isUpperCase(character) && translation.length() != 0) {\n translation.append(separator);\n }\n translation.append(character);\n }\n return translation.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingPolicy.java","line":192,"symbol":"upperCaseFirstLetter","kind":"method","lang":"java","doc":"Ensures the JSON field names begins with an upper case letter.","code":"static String upperCaseFirstLetter(String s) {\n int length = s.length();\n for (int i = 0; i < length; i++) {\n char c = s.charAt(i);\n if (Character.isLetter(c)) {\n if (Character.isUpperCase(c)) {\n return s;\n }\n\n char uppercased = Character.toUpperCase(c);\n // For leading letter only need one substring\n if (i == 0) {\n return uppercased + s.substring(1);\n } else {\n return s.substring(0, i) + uppercased + s.substring(i + 1);\n }\n }\n }\n\n return s;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingStrategy.java","line":34,"symbol":"FieldNamingStrategy","kind":"interface","lang":"java","doc":"@see GsonBuilder#setFieldNamingStrategy(FieldNamingStrategy) @author Inderjeet Singh @author Joel Leitch @since 1.3","code":"public interface FieldNamingStrategy {\n\n /**\n * Translates the field name into its JSON field name representation.\n *\n * @param f the field object that we are translating\n * @return the translated field name.\n * @since 1.3\n */\n String translateName(Field f);\n\n /**\n * Returns alternative names for this field when it is being deserialized. This is similar to\n * {@link SerializedName#alternate()}.\n *\n * @param f the field object\n * @return the list of alternative field names.\n * @since 2.13.1\n */\n default List alternateNames(Field f) {\n return Collections.emptyList();\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingStrategy.java","line":43,"symbol":"translateName","kind":"method","lang":"java","doc":"Translates the field name into its JSON field name representation. @param f the field object that we are translating @return the translated field name. @since 1.3","code":"String translateName(Field f);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FieldNamingStrategy.java","line":53,"symbol":"alternateNames","kind":"method","lang":"java","doc":"{@link SerializedName#alternate()}. @param f the field object @return the list of alternative field names. @since 2.13.1","code":"default List alternateNames(Field f) {\n return Collections.emptyList();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":39,"symbol":"FormattingStyle","kind":"class","lang":"java","doc":"@see GsonBuilder#setFormattingStyle(FormattingStyle) @see JsonWriter#setFormattingStyle(FormattingStyle) @see Wikipedia Newline article @since 2.11.0","code":"public final class FormattingStyle {\n private final String newline;\n private final String indent;\n private final boolean spaceAfterSeparators;\n\n /**\n * The default compact formatting style:\n *\n *
      \n *
    • no newline\n *
    • no indent\n *
    • no space after {@code ','} and {@code ':'}\n *
    \n */\n public static final FormattingStyle COMPACT = new FormattingStyle(\"\", \"\", false);\n\n /**\n * The default pretty printing formatting style:\n *\n *
      \n *
    • {@code \"\\n\"} as newline\n *
    • two spaces as indent\n *
    • a space between {@code ':'} and the subsequent value\n *
    \n */\n public static final FormattingStyle PRETTY = new FormattingStyle(\"\\n\", \" \", true);\n\n private FormattingStyle(String newline, String indent, boolean spaceAfterSeparators) {\n Objects.requireNonNull(newline, \"newline == null\");\n Objects.requireNonNull(indent, \"indent == null\");\n if (!newline.matches(\"[\\r\\n]*\")) {\n throw new IllegalArgumentException(\n \"Only combinations of \\\\n and \\\\r are allowed in newline.\");\n }\n if (!indent.matches(\"[ \\t]*\")) {\n throw new IllegalArgumentException(\n \"Only combinations of spaces and tabs"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":66,"symbol":"FormattingStyle","kind":"constructor","lang":"java","code":"private FormattingStyle(String newline, String indent, boolean spaceAfterSeparators) {\n Objects.requireNonNull(newline, \"newline == null\");\n Objects.requireNonNull(indent, \"indent == null\");\n if (!newline.matches(\"[\\r\\n]*\")) {\n throw new IllegalArgumentException(\n \"Only combinations of \\\\n and \\\\r are allowed in newline.\");\n }\n if (!indent.matches(\"[ \\t]*\")) {\n throw new IllegalArgumentException(\n \"Only combinations of spaces and tabs are allowed in indent.\");\n }\n this.newline = newline;\n this.indent = indent;\n this.spaceAfterSeparators = spaceAfterSeparators;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":95,"symbol":"withNewline","kind":"method","lang":"java","doc":"

    Only combinations of {@code \\n} and {@code \\r} are allowed. @param newline the string value that will be used as newline. @return a newly created {@link FormattingStyle} @see #getNewline()","code":"public FormattingStyle withNewline(String newline) {\n return new FormattingStyle(newline, this.indent, this.spaceAfterSeparators);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":108,"symbol":"withIndent","kind":"method","lang":"java","doc":"

    Only combinations of spaces and tabs are allowed in indent. @param indent the string value that will be used as indent. @return a newly created {@link FormattingStyle} @see #getIndent()","code":"public FormattingStyle withIndent(String indent) {\n return new FormattingStyle(this.newline, indent, this.spaceAfterSeparators);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":124,"symbol":"withSpaceAfterSeparators","kind":"method","lang":"java","doc":"added after the {@code ','} in that case. @param spaceAfterSeparators whether to output a space after {@code ','} and {@code ':'}. @return a newly created {@link FormattingStyle} @see #usesSpaceAfterSeparators()","code":"public FormattingStyle withSpaceAfterSeparators(boolean spaceAfterSeparators) {\n return new FormattingStyle(this.newline, this.indent, spaceAfterSeparators);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":134,"symbol":"getNewline","kind":"method","lang":"java","doc":"Returns the string value that will be used as a newline. @return the newline value. @see #withNewline(String)","code":"public String getNewline() {\n return this.newline;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":144,"symbol":"getIndent","kind":"method","lang":"java","doc":"Returns the string value that will be used as indent. @return the indent value. @see #withIndent(String)","code":"public String getIndent() {\n return this.indent;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/FormattingStyle.java","line":153,"symbol":"usesSpaceAfterSeparators","kind":"method","lang":"java","doc":"Returns whether a space will be used after {@code ','} and {@code ':'}. @see #withSpaceAfterSeparators(boolean)","code":"public boolean usesSpaceAfterSeparators() {\n return this.spaceAfterSeparators;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":156,"symbol":"Gson","kind":"class","lang":"java","doc":"@see GsonBuilder @author Inderjeet Singh @author Joel Leitch @author Jesse Wilson","code":"public final class Gson {\n\n private static final String JSON_NON_EXECUTABLE_PREFIX = \")]}'\\n\";\n\n /**\n * This thread local guards against reentrant calls to {@link #getAdapter(TypeToken)}. In certain\n * object graphs, creating an adapter for a type may recursively require an adapter for the same\n * type! Without intervention, the recursive lookup would stack overflow. We cheat by returning a\n * proxy type adapter, {@link FutureTypeAdapter}, which is wired up once the initial adapter has\n * been created.\n *\n *

    The map stores the type adapters for ongoing {@code getAdapter} calls, with the type token\n * provided to {@code getAdapter} as key and either {@code FutureTypeAdapter} or a regular {@code\n * TypeAdapter} as value.\n */\n @SuppressWarnings(\"ThreadLocalUsage\")\n private final ThreadLocal, TypeAdapter>> threadLocalAdapterResults =\n new ThreadLocal<>();\n\n private final ConcurrentMap, TypeAdapter> typeTokenCache =\n new ConcurrentHashMap<>();\n\n private final ConstructorConstructor constructorConstructor;\n private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;\n\n final List"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":243,"symbol":"Gson","kind":"constructor","lang":"java","doc":"for serialization and deserialization. You can change this behavior through {@link GsonBuilder#excludeFieldsWithModifiers(int...)}.

  • No explicit strictness is set. You can change this by calling {@link GsonBuilder#setStrictness(Strictness)}.
","code":"public Gson() {\n this(GsonBuilder.DEFAULT);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":247,"symbol":"Gson","kind":"constructor","lang":"java","code":"Gson(GsonBuilder builder) {\n this.excluder = builder.excluder;\n this.fieldNamingStrategy = builder.fieldNamingPolicy;\n this.instanceCreators = new HashMap<>(builder.instanceCreators);\n this.serializeNulls = builder.serializeNulls;\n this.complexMapKeySerialization = builder.complexMapKeySerialization;\n this.generateNonExecutableJson = builder.generateNonExecutableJson;\n this.htmlSafe = builder.escapeHtmlChars;\n this.formattingStyle = builder.formattingStyle;\n this.strictness = builder.strictness;\n this.serializeSpecialFloatingPointValues = builder.serializeSpecialFloatingPointValues;\n this.useJdkUnsafe = builder.useJdkUnsafe;\n this.longSerializationPolicy = builder.longSerializationPolicy;\n this.datePattern = builder.datePattern;\n this.dateStyle = builder.dateStyle;\n this.timeStyle = builder.timeStyle;\n this.builderFactories = newImmutableList(builder.factories);\n this.builderHierarchyFactories = newImmutableList(builder.hierarchyFactories);\n this.objectToNumberStrategy = builder.objectToNumberStrategy;\n this.numberToNumberStrategy = builder.numberToNumberStrategy;\n this.reflectionFilters = newImmutableList(builder.reflecti"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":287,"symbol":"newBuilder","kind":"method","lang":"java","doc":"Returns a new GsonBuilder containing all custom factories and configuration used by the current instance. @return a GsonBuilder instance. @since 2.8.3","code":"public GsonBuilder newBuilder() {\n return new GsonBuilder(this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":295,"symbol":"excluder","kind":"method","lang":"java","doc":"@deprecated This method by accident exposes an internal Gson class; it might be removed in a future version.","code":"@Deprecated\n public Excluder excluder() {\n return excluder;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":305,"symbol":"fieldNamingStrategy","kind":"method","lang":"java","doc":"Returns the field naming strategy used by this Gson instance. @see GsonBuilder#setFieldNamingStrategy(FieldNamingStrategy)","code":"public FieldNamingStrategy fieldNamingStrategy() {\n return fieldNamingStrategy;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":315,"symbol":"serializeNulls","kind":"method","lang":"java","doc":"Returns whether this Gson instance is serializing JSON object properties with {@code null} values, or just omits them. @see GsonBuilder#serializeNulls()","code":"public boolean serializeNulls() {\n return serializeNulls;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":325,"symbol":"htmlSafe","kind":"method","lang":"java","doc":"Returns whether this Gson instance produces JSON output which is HTML-safe, that means all HTML characters are escaped. @see GsonBuilder#disableHtmlEscaping()","code":"public boolean htmlSafe() {\n return htmlSafe;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":340,"symbol":"getAdapter","kind":"method","lang":"java","doc":"should normally not be an issue because {@code TypeAdapter} implementations are supposed to be stateless. @throws IllegalArgumentException if this Gson instance cannot serialize and deserialize {@code type}.","code":"public TypeAdapter getAdapter(TypeToken type) {\n Objects.requireNonNull(type, \"type must not be null\");\n TypeAdapter cached = typeTokenCache.get(type);\n if (cached != null) {\n @SuppressWarnings(\"unchecked\")\n TypeAdapter adapter = (TypeAdapter) cached;\n return adapter;\n }\n\n Map, TypeAdapter> threadCalls = threadLocalAdapterResults.get();\n boolean isInitialAdapterRequest = false;\n if (threadCalls == null) {\n threadCalls = new HashMap<>();\n threadLocalAdapterResults.set(threadCalls);\n isInitialAdapterRequest = true;\n } else {\n // the key and value type parameters always agree\n @SuppressWarnings(\"unchecked\")\n TypeAdapter ongoingCall = (TypeAdapter) threadCalls.get(type);\n if (ongoingCall != null) {\n return ongoingCall;\n }\n }\n\n TypeAdapter candidate = null;\n try {\n FutureTypeAdapter call = new FutureTypeAdapter<>();\n threadCalls.put(type, call);\n\n for (TypeAdapterFactory factory : factories) {\n candidate = factory.create(this, type);\n if (candidate != null) {\n call.setDelegate(candidate);\n // Replace "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":407,"symbol":"getAdapter","kind":"method","lang":"java","doc":"Returns the type adapter for {@code type}. @throws IllegalArgumentException if this Gson instance cannot serialize and deserialize {@code type}.","code":"public TypeAdapter getAdapter(Class type) {\n return getAdapter(TypeToken.get(type));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":472,"symbol":"getDelegateAdapter","kind":"method","lang":"java","doc":"@param skipPast The type adapter factory that needs to be skipped while searching for a matching type adapter. In most cases, you should just pass this (the type adapter factory from where {@code getDelegateAdapter} method is being invoked). @param type Type for which the delegate adapter is being searched for. @since 2.2","code":"public TypeAdapter getDelegateAdapter(TypeAdapterFactory skipPast, TypeToken type) {\n Objects.requireNonNull(skipPast, \"skipPast must not be null\");\n Objects.requireNonNull(type, \"type must not be null\");\n\n if (jsonAdapterFactory.isClassJsonAdapterFactory(type, skipPast)) {\n skipPast = jsonAdapterFactory;\n }\n\n boolean skipPastFound = false;\n for (TypeAdapterFactory factory : factories) {\n if (!skipPastFound) {\n @SuppressWarnings(\"ReferenceEquality\")\n boolean isSkipPast = factory == skipPast;\n if (isSkipPast) {\n skipPastFound = true;\n }\n continue;\n }\n\n TypeAdapter candidate = factory.create(this, type);\n if (candidate != null) {\n return candidate;\n }\n }\n\n if (skipPastFound) {\n throw new IllegalArgumentException(\"GSON cannot serialize or deserialize \" + type);\n } else {\n // Probably a factory from @JsonAdapter on a field\n return getAdapter(type);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":519,"symbol":"toJsonTree","kind":"method","lang":"java","doc":"@param src the object for which JSON representation is to be created @return JSON representation of {@code src}. @since 1.4 @see #toJsonTree(Object, Type)","code":"public JsonElement toJsonTree(Object src) {\n if (src == null) {\n return JsonNull.INSTANCE;\n }\n return toJsonTree(src, src.getClass());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":544,"symbol":"toJsonTree","kind":"method","lang":"java","doc":" @return JSON representation of {@code src}. @since 1.4 @see #toJsonTree(Object)","code":"public JsonElement toJsonTree(Object src, Type typeOfSrc) {\n JsonTreeWriter writer = new JsonTreeWriter();\n toJson(src, typeOfSrc, writer);\n return writer.get();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":565,"symbol":"toJson","kind":"method","lang":"java","doc":"@param src the object for which JSON representation is to be created @return JSON representation of {@code src}. @see #toJson(Object, Appendable) @see #toJson(Object, Type)","code":"public String toJson(Object src) {\n if (src == null) {\n return toJson(JsonNull.INSTANCE);\n }\n return toJson(src, src.getClass());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":590,"symbol":"toJson","kind":"method","lang":"java","doc":" @return JSON representation of {@code src}. @see #toJson(Object, Type, Appendable) @see #toJson(Object)","code":"public String toJson(Object src, Type typeOfSrc) {\n StringBuilder writer = new StringBuilder();\n toJson(src, typeOfSrc, writer);\n return writer.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":612,"symbol":"toJson","kind":"method","lang":"java","doc":"@param writer Writer to which the JSON representation needs to be written @throws JsonIOException if there was a problem writing to the writer @since 1.2 @see #toJson(Object) @see #toJson(Object, Type, Appendable)","code":"public void toJson(Object src, Appendable writer) throws JsonIOException {\n if (src != null) {\n toJson(src, src.getClass(), writer);\n } else {\n toJson(JsonNull.INSTANCE, writer);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":640,"symbol":"toJson","kind":"method","lang":"java","doc":"@param writer Writer to which the JSON representation of src needs to be written @throws JsonIOException if there was a problem writing to the writer @since 1.2 @see #toJson(Object, Type) @see #toJson(Object, Appendable)","code":"public void toJson(Object src, Type typeOfSrc, Appendable writer) throws JsonIOException {\n try {\n JsonWriter jsonWriter = newJsonWriter(Streams.writerForAppendable(writer));\n toJson(src, typeOfSrc, jsonWriter);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":670,"symbol":"toJson","kind":"method","lang":"java","doc":"@param src the object for which JSON representation is to be created @param typeOfSrc the type of the object to be written @param writer Writer to which the JSON representation of src needs to be written @throws JsonIOException if there was a problem writing to the writer","code":"public void toJson(Object src, Type typeOfSrc, JsonWriter writer) throws JsonIOException {\n @SuppressWarnings(\"unchecked\")\n TypeAdapter adapter = (TypeAdapter) getAdapter(TypeToken.get(typeOfSrc));\n\n Strictness oldStrictness = writer.getStrictness();\n if (this.strictness != null) {\n writer.setStrictness(this.strictness);\n } else if (writer.getStrictness() == Strictness.LEGACY_STRICT) {\n // For backward compatibility change to LENIENT if writer has default strictness LEGACY_STRICT\n writer.setStrictness(Strictness.LENIENT);\n }\n\n boolean oldHtmlSafe = writer.isHtmlSafe();\n boolean oldSerializeNulls = writer.getSerializeNulls();\n\n writer.setHtmlSafe(htmlSafe);\n writer.setSerializeNulls(serializeNulls);\n try {\n adapter.write(writer, src);\n } catch (IOException e) {\n throw new JsonIOException(e);\n } catch (AssertionError e) {\n throw new AssertionError(\n \"AssertionError (GSON \" + GsonBuildConfig.VERSION + \"): \" + e.getMessage(), e);\n } finally {\n writer.setStrictness(oldStrictness);\n writer.setHtmlSafe(oldHtmlSafe);\n writer.setSerializeNulls(oldSerializeNulls);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":708,"symbol":"toJson","kind":"method","lang":"java","doc":"Converts a tree of {@link JsonElement}s into its equivalent JSON representation. @param jsonElement root of a tree of {@link JsonElement}s @return JSON String representation of the tree. @since 1.4","code":"public String toJson(JsonElement jsonElement) {\n StringBuilder writer = new StringBuilder();\n toJson(jsonElement, writer);\n return writer.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":722,"symbol":"toJson","kind":"method","lang":"java","doc":"@param jsonElement root of a tree of {@link JsonElement}s @param writer Writer to which the JSON representation needs to be written @throws JsonIOException if there was a problem writing to the writer @since 1.4","code":"public void toJson(JsonElement jsonElement, Appendable writer) throws JsonIOException {\n try {\n JsonWriter jsonWriter = newJsonWriter(Streams.writerForAppendable(writer));\n toJson(jsonElement, jsonWriter);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":751,"symbol":"toJson","kind":"method","lang":"java","doc":"are restored once this method returns. @param jsonElement the JSON element to be written @param writer the JSON writer to which the provided element will be written @throws JsonIOException if there was a problem writing to the writer","code":"public void toJson(JsonElement jsonElement, JsonWriter writer) throws JsonIOException {\n Strictness oldStrictness = writer.getStrictness();\n boolean oldHtmlSafe = writer.isHtmlSafe();\n boolean oldSerializeNulls = writer.getSerializeNulls();\n\n writer.setHtmlSafe(htmlSafe);\n writer.setSerializeNulls(serializeNulls);\n\n if (this.strictness != null) {\n writer.setStrictness(this.strictness);\n } else if (writer.getStrictness() == Strictness.LEGACY_STRICT) {\n // For backward compatibility change to LENIENT if writer has default strictness LEGACY_STRICT\n writer.setStrictness(Strictness.LENIENT);\n }\n\n try {\n Streams.write(jsonElement, writer);\n } catch (IOException e) {\n throw new JsonIOException(e);\n } catch (AssertionError e) {\n throw new AssertionError(\n \"AssertionError (GSON \" + GsonBuildConfig.VERSION + \"): \" + e.getMessage(), e);\n } finally {\n writer.setStrictness(oldStrictness);\n writer.setHtmlSafe(oldHtmlSafe);\n writer.setSerializeNulls(oldSerializeNulls);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":797,"symbol":"newJsonWriter","kind":"method","lang":"java","doc":"writer will have a strictness of {@link Strictness#LEGACY_STRICT}. Otherwise, the strictness of the {@code Gson} instance will be used for the created writer.
  • {@link GsonBuilder#setPrettyPrinting()}
  • {@link GsonBuilder#setFormattingStyle(FormattingStyle)} ","code":"public JsonWriter newJsonWriter(Writer writer) throws IOException {\n if (generateNonExecutableJson) {\n writer.write(JSON_NON_EXECUTABLE_PREFIX);\n }\n JsonWriter jsonWriter = new JsonWriter(writer);\n jsonWriter.setFormattingStyle(formattingStyle);\n jsonWriter.setHtmlSafe(htmlSafe);\n jsonWriter.setStrictness(strictness == null ? Strictness.LEGACY_STRICT : strictness);\n jsonWriter.setSerializeNulls(serializeNulls);\n return jsonWriter;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":821,"symbol":"newJsonReader","kind":"method","lang":"java","doc":"
  • {@link GsonBuilder#setStrictness(Strictness)}. If no {@linkplain GsonBuilder#setStrictness(Strictness) explicit strictness has been set} the created reader will have a strictness of {@link Strictness#LEGACY_STRICT}. Otherwise, the strictness of the {@code Gson} instance will be used for the created reader. ","code":"public JsonReader newJsonReader(Reader reader) {\n JsonReader jsonReader = new JsonReader(reader);\n jsonReader.setStrictness(strictness == null ? Strictness.LEGACY_STRICT : strictness);\n return jsonReader;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":850,"symbol":"fromJson","kind":"method","lang":"java","doc":"null} or if {@code json} is empty. @throws JsonSyntaxException if json is not a valid representation for an object of type classOfT @see #fromJson(Reader, Class) @see #fromJson(String, TypeToken)","code":"public T fromJson(String json, Class classOfT) throws JsonSyntaxException {\n return fromJson(json, TypeToken.get(classOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":878,"symbol":"fromJson","kind":"method","lang":"java","doc":"null} or if {@code json} is empty. @throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT @see #fromJson(Reader, Type) @see #fromJson(String, Class) @see #fromJson(String, TypeToken)","code":"@SuppressWarnings({\"unchecked\", \"TypeParameterUnusedInFormals\"})\n public T fromJson(String json, Type typeOfT) throws JsonSyntaxException {\n return (T) fromJson(json, TypeToken.get(typeOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":909,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonSyntaxException if json is not a valid representation for an object of the type typeOfT @see #fromJson(Reader, TypeToken) @see #fromJson(String, Class) @since 2.10","code":"public T fromJson(String json, TypeToken typeOfT) throws JsonSyntaxException {\n if (json == null) {\n return null;\n }\n StringReader reader = new StringReader(json);\n return fromJson(reader, typeOfT);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":940,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonIOException if there was a problem reading from the Reader @throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT @since 1.2 @see #fromJson(String, Class) @see #fromJson(Reader, TypeToken)","code":"public T fromJson(Reader json, Class classOfT)\n throws JsonSyntaxException, JsonIOException {\n return fromJson(json, TypeToken.get(classOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":970,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT @since 1.2 @see #fromJson(String, Type) @see #fromJson(Reader, Class) @see #fromJson(Reader, TypeToken)","code":"@SuppressWarnings({\"unchecked\", \"TypeParameterUnusedInFormals\"})\n public T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException {\n return (T) fromJson(json, TypeToken.get(typeOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1001,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonSyntaxException if json is not a valid representation for an object of type of typeOfT @see #fromJson(String, TypeToken) @see #fromJson(Reader, Class) @since 2.10","code":"public T fromJson(Reader json, TypeToken typeOfT)\n throws JsonIOException, JsonSyntaxException {\n JsonReader jsonReader = newJsonReader(json);\n T object = fromJson(jsonReader, typeOfT);\n assertFullConsumption(object, jsonReader);\n return object;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1045,"symbol":"fromJson","kind":"method","lang":"java","doc":"EOF. @throws JsonIOException if there was a problem reading from the JsonReader @throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT @see #fromJson(Reader, Type) @see #fromJson(JsonReader, TypeToken)","code":"@SuppressWarnings({\"unchecked\", \"TypeParameterUnusedInFormals\"})\n public T fromJson(JsonReader reader, Type typeOfT)\n throws JsonIOException, JsonSyntaxException {\n return (T) fromJson(reader, TypeToken.get(typeOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1087,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonSyntaxException if json is not a valid representation for an object of the type typeOfT @see #fromJson(Reader, TypeToken) @see #fromJson(JsonReader, Type) @since 2.10","code":"public T fromJson(JsonReader reader, TypeToken typeOfT)\n throws JsonIOException, JsonSyntaxException {\n boolean isEmpty = true;\n Strictness oldStrictness = reader.getStrictness();\n\n if (this.strictness != null) {\n reader.setStrictness(this.strictness);\n } else if (reader.getStrictness() == Strictness.LEGACY_STRICT) {\n // For backward compatibility change to LENIENT if reader has default strictness LEGACY_STRICT\n reader.setStrictness(Strictness.LENIENT);\n }\n\n try {\n JsonToken unused = reader.peek();\n isEmpty = false;\n TypeAdapter typeAdapter = getAdapter(typeOfT);\n T object = typeAdapter.read(reader);\n Class expectedTypeWrapped = Primitives.wrap(typeOfT.getRawType());\n if (object != null && !expectedTypeWrapped.isInstance(object)) {\n throw new ClassCastException(\n \"Type adapter '\"\n + typeAdapter\n + \"' returned wrong type; requested \"\n + typeOfT.getRawType()\n + \" but got instance of \"\n + object.getClass()\n + \"\\nVerify that the adapter was registered for the correct type.\");\n }\n return obj"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1159,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonSyntaxException if json is not a valid representation for an object of type classOfT @since 1.3 @see #fromJson(Reader, Class) @see #fromJson(JsonElement, TypeToken)","code":"public T fromJson(JsonElement json, Class classOfT) throws JsonSyntaxException {\n return fromJson(json, TypeToken.get(classOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1185,"symbol":"fromJson","kind":"method","lang":"java","doc":"@throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT @since 1.3 @see #fromJson(Reader, Type) @see #fromJson(JsonElement, Class) @see #fromJson(JsonElement, TypeToken)","code":"@SuppressWarnings({\"unchecked\", \"TypeParameterUnusedInFormals\"})\n public T fromJson(JsonElement json, Type typeOfT) throws JsonSyntaxException {\n return (T) fromJson(json, TypeToken.get(typeOfT));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1212,"symbol":"fromJson","kind":"method","lang":"java","doc":"or if {@code json} is empty. @throws JsonSyntaxException if json is not a valid representation for an object of type typeOfT @see #fromJson(Reader, TypeToken) @see #fromJson(JsonElement, Class) @since 2.10","code":"public T fromJson(JsonElement json, TypeToken typeOfT) throws JsonSyntaxException {\n if (json == null) {\n return null;\n }\n return fromJson(new JsonTreeReader(json), typeOfT);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1219,"symbol":"assertFullConsumption","kind":"method","lang":"java","code":"private static void assertFullConsumption(Object obj, JsonReader reader) {\n try {\n if (obj != null && reader.peek() != JsonToken.END_DOCUMENT) {\n throw new JsonSyntaxException(\"JSON document was not fully consumed.\");\n }\n } catch (MalformedJsonException e) {\n throw new JsonSyntaxException(e);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1239,"symbol":"FutureTypeAdapter","kind":"class","lang":"java","doc":"

    Important: Setting the delegate adapter is not thread-safe; instances of {@code FutureTypeAdapter} must only be published to other threads after the delegate has been set. @see Gson#threadLocalAdapterResults","code":"static class FutureTypeAdapter extends SerializationDelegatingTypeAdapter {\n private TypeAdapter delegate = null;\n\n public void setDelegate(TypeAdapter typeAdapter) {\n if (delegate != null) {\n throw new AssertionError(\"Delegate is already set\");\n }\n delegate = typeAdapter;\n }\n\n private TypeAdapter delegate() {\n TypeAdapter delegate = this.delegate;\n if (delegate == null) {\n // Can occur when adapter is leaked to other thread or when adapter is used for\n // (de-)serialization\n // directly within the TypeAdapterFactory which requested it\n throw new IllegalStateException(\n \"Adapter for type with cyclic dependency has been used\"\n + \" before dependency has been resolved\");\n }\n return delegate;\n }\n\n @Override\n public TypeAdapter getSerializationDelegate() {\n return delegate();\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n return delegate().read(in);\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate().write(out, value);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1242,"symbol":"setDelegate","kind":"method","lang":"java","code":"public void setDelegate(TypeAdapter typeAdapter) {\n if (delegate != null) {\n throw new AssertionError(\"Delegate is already set\");\n }\n delegate = typeAdapter;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1249,"symbol":"delegate","kind":"method","lang":"java","code":"private TypeAdapter delegate() {\n TypeAdapter delegate = this.delegate;\n if (delegate == null) {\n // Can occur when adapter is leaked to other thread or when adapter is used for\n // (de-)serialization\n // directly within the TypeAdapterFactory which requested it\n throw new IllegalStateException(\n \"Adapter for type with cyclic dependency has been used\"\n + \" before dependency has been resolved\");\n }\n return delegate;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1262,"symbol":"getSerializationDelegate","kind":"method","lang":"java","code":"@Override\n public TypeAdapter getSerializationDelegate() {\n return delegate();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1267,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n return delegate().read(in);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1272,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n delegate().write(out, value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Gson.java","line":1278,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"{serializeNulls:\"\n + serializeNulls\n + \",factories:\"\n + factories\n + \",instanceCreators:\"\n + constructorConstructor\n + \"}\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":93,"symbol":"GsonBuilder","kind":"class","lang":"java","doc":" @author Inderjeet Singh @author Joel Leitch @author Jesse Wilson","code":"public final class GsonBuilder {\n private static final boolean DEFAULT_JSON_NON_EXECUTABLE = false;\n // Strictness of `null` is the legacy mode where some Gson APIs are always lenient\n private static final Strictness DEFAULT_STRICTNESS = null;\n private static final FormattingStyle DEFAULT_FORMATTING_STYLE = FormattingStyle.COMPACT;\n private static final boolean DEFAULT_ESCAPE_HTML = true;\n private static final boolean DEFAULT_SERIALIZE_NULLS = false;\n private static final boolean DEFAULT_COMPLEX_MAP_KEYS = false;\n private static final boolean DEFAULT_SPECIALIZE_FLOAT_VALUES = false;\n private static final boolean DEFAULT_USE_JDK_UNSAFE = true;\n private static final String DEFAULT_DATE_PATTERN = null;\n private static final FieldNamingStrategy DEFAULT_FIELD_NAMING_STRATEGY =\n FieldNamingPolicy.IDENTITY;\n private static final ToNumberStrategy DEFAULT_OBJECT_TO_NUMBER_STRATEGY = ToNumberPolicy.DOUBLE;\n private static final ToNumberStrategy DEFAULT_NUMBER_TO_NUMBER_STRATEGY =\n ToNumberPolicy.LAZILY_PARSED_NUMBER;\n\n static final ConstructorConstructor DEFAULT_CONSTRUCTOR_CONSTRUCTOR =\n new ConstructorConstructor(\n Collections.emptyMap(), DEFAULT_USE_J"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":158,"symbol":"GsonBuilder","kind":"constructor","lang":"java","doc":"Creates a GsonBuilder instance that can be used to build Gson with various configuration settings. GsonBuilder follows the builder pattern, and it is typically used by first invoking various configuration methods to set desired options, and finally calling {@link #create()}.","code":"public GsonBuilder() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":166,"symbol":"GsonBuilder","kind":"constructor","lang":"java","doc":"Constructs a GsonBuilder instance from a Gson instance. The newly constructed GsonBuilder has the same configuration as the previously built Gson instance. @param gson the gson instance whose configuration should be applied to a new GsonBuilder.","code":"GsonBuilder(Gson gson) {\n this.excluder = gson.excluder;\n this.fieldNamingPolicy = gson.fieldNamingStrategy;\n this.instanceCreators.putAll(gson.instanceCreators);\n this.serializeNulls = gson.serializeNulls;\n this.complexMapKeySerialization = gson.complexMapKeySerialization;\n this.generateNonExecutableJson = gson.generateNonExecutableJson;\n this.escapeHtmlChars = gson.htmlSafe;\n this.formattingStyle = gson.formattingStyle;\n this.strictness = gson.strictness;\n this.serializeSpecialFloatingPointValues = gson.serializeSpecialFloatingPointValues;\n this.longSerializationPolicy = gson.longSerializationPolicy;\n this.datePattern = gson.datePattern;\n this.dateStyle = gson.dateStyle;\n this.timeStyle = gson.timeStyle;\n this.factories.addAll(gson.builderFactories);\n this.hierarchyFactories.addAll(gson.builderHierarchyFactories);\n this.useJdkUnsafe = gson.useJdkUnsafe;\n this.objectToNumberStrategy = gson.objectToNumberStrategy;\n this.numberToNumberStrategy = gson.numberToNumberStrategy;\n this.reflectionFilters.addAll(gson.reflectionFilters);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":204,"symbol":"setVersion","kind":"method","lang":"java","doc":"@param version the version number to use. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @throws IllegalArgumentException if the version number is NaN or negative @see Since @see Until","code":"@CanIgnoreReturnValue\n public GsonBuilder setVersion(double version) {\n if (Double.isNaN(version) || version < 0.0) {\n throw new IllegalArgumentException(\"Invalid version: \" + version);\n }\n excluder = excluder.withVersion(version);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":227,"symbol":"excludeFieldsWithModifiers","kind":"method","lang":"java","doc":"@param modifiers the field modifiers. You must use the modifiers specified in the {@link java.lang.reflect.Modifier} class. For example, {@link java.lang.reflect.Modifier#TRANSIENT}, {@link java.lang.reflect.Modifier#STATIC}. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern","code":"@CanIgnoreReturnValue\n public GsonBuilder excludeFieldsWithModifiers(int... modifiers) {\n Objects.requireNonNull(modifiers);\n excluder = excluder.withModifiers(modifiers);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":242,"symbol":"generateNonExecutableJson","kind":"method","lang":"java","doc":"special text. This prevents attacks from third-party sites through script sourcing. See Gson Issue 42 for details. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.3","code":"@CanIgnoreReturnValue\n public GsonBuilder generateNonExecutableJson() {\n this.generateNonExecutableJson = true;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":258,"symbol":"excludeFieldsWithoutExposeAnnotation","kind":"method","lang":"java","doc":"

    This is a convenience method which behaves as if an {@link ExclusionStrategy} which excludes these fields was {@linkplain #setExclusionStrategies(ExclusionStrategy...) registered with this builder}. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern","code":"@CanIgnoreReturnValue\n public GsonBuilder excludeFieldsWithoutExposeAnnotation() {\n excluder = excluder.excludeFieldsWithoutExposeAnnotation();\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":271,"symbol":"serializeNulls","kind":"method","lang":"java","doc":"Configures Gson to serialize null fields. By default, Gson omits all fields that are null during serialization. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.2","code":"@CanIgnoreReturnValue\n public GsonBuilder serializeNulls() {\n this.serializeNulls = true;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":359,"symbol":"enableComplexMapKeySerialization","kind":"method","lang":"java","doc":"] } @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.7","code":"@CanIgnoreReturnValue\n public GsonBuilder enableComplexMapKeySerialization() {\n complexMapKeySerialization = true;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":386,"symbol":"disableInnerClassSerialization","kind":"method","lang":"java","doc":"

    In general using inner classes with Gson should be avoided; they should be converted to {@code static} nested classes if possible. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.3","code":"@CanIgnoreReturnValue\n public GsonBuilder disableInnerClassSerialization() {\n excluder = excluder.disableInnerClassSerialization();\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":400,"symbol":"setLongSerializationPolicy","kind":"method","lang":"java","doc":"objects. @param serializationPolicy the particular policy to use for serializing longs. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.3","code":"@CanIgnoreReturnValue\n public GsonBuilder setLongSerializationPolicy(LongSerializationPolicy serializationPolicy) {\n this.longSerializationPolicy = Objects.requireNonNull(serializationPolicy);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":412,"symbol":"setFieldNamingPolicy","kind":"method","lang":"java","doc":"Configures Gson to apply a specific naming policy to an object's fields during serialization and deserialization.

    This method just delegates to {@link #setFieldNamingStrategy(FieldNamingStrategy)}.","code":"@CanIgnoreReturnValue\n public GsonBuilder setFieldNamingPolicy(FieldNamingPolicy namingConvention) {\n return setFieldNamingStrategy(namingConvention);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":429,"symbol":"setFieldNamingStrategy","kind":"method","lang":"java","doc":"value of a field is serialized or deserialized. @param fieldNamingStrategy the naming strategy to apply to the fields @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.3","code":"@CanIgnoreReturnValue\n public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) {\n this.fieldNamingPolicy = Objects.requireNonNull(fieldNamingStrategy);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":443,"symbol":"setObjectToNumberStrategy","kind":"method","lang":"java","doc":"@param objectToNumberStrategy the actual object-to-number strategy @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @see ToNumberPolicy#DOUBLE The default object-to-number strategy @since 2.8.9","code":"@CanIgnoreReturnValue\n public GsonBuilder setObjectToNumberStrategy(ToNumberStrategy objectToNumberStrategy) {\n this.objectToNumberStrategy = Objects.requireNonNull(objectToNumberStrategy);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":457,"symbol":"setNumberToNumberStrategy","kind":"method","lang":"java","doc":"@param numberToNumberStrategy the actual number-to-number strategy @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @see ToNumberPolicy#LAZILY_PARSED_NUMBER The default number-to-number strategy @since 2.8.9","code":"@CanIgnoreReturnValue\n public GsonBuilder setNumberToNumberStrategy(ToNumberStrategy numberToNumberStrategy) {\n this.numberToNumberStrategy = Objects.requireNonNull(numberToNumberStrategy);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":488,"symbol":"setExclusionStrategies","kind":"method","lang":"java","doc":"value of a field or a class is serialized or deserialized. @param strategies the set of strategy object to apply during object (de)serialization. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.4","code":"@CanIgnoreReturnValue\n public GsonBuilder setExclusionStrategies(ExclusionStrategy... strategies) {\n Objects.requireNonNull(strategies);\n for (ExclusionStrategy strategy : strategies) {\n excluder = excluder.withExclusionStrategy(strategy, true, true);\n }\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":511,"symbol":"addSerializationExclusionStrategy","kind":"method","lang":"java","doc":"detailed description of the effect of exclusion strategies. @param strategy an exclusion strategy to apply during serialization. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.7","code":"@CanIgnoreReturnValue\n public GsonBuilder addSerializationExclusionStrategy(ExclusionStrategy strategy) {\n Objects.requireNonNull(strategy);\n excluder = excluder.withExclusionStrategy(strategy, true, false);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":532,"symbol":"addDeserializationExclusionStrategy","kind":"method","lang":"java","doc":"detailed description of the effect of exclusion strategies. @param strategy an exclusion strategy to apply during deserialization. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.7","code":"@CanIgnoreReturnValue\n public GsonBuilder addDeserializationExclusionStrategy(ExclusionStrategy strategy) {\n Objects.requireNonNull(strategy);\n excluder = excluder.withExclusionStrategy(strategy, false, true);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":548,"symbol":"setPrettyPrinting","kind":"method","lang":"java","doc":"

    This is a convenience method which simply calls {@link #setFormattingStyle(FormattingStyle)} with {@link FormattingStyle#PRETTY}. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern","code":"@CanIgnoreReturnValue\n public GsonBuilder setPrettyPrinting() {\n return setFormattingStyle(FormattingStyle.PRETTY);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":562,"symbol":"setFormattingStyle","kind":"method","lang":"java","doc":"compact JSON output without any formatting. @param formattingStyle the formatting style to use. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 2.11.0","code":"@CanIgnoreReturnValue\n public GsonBuilder setFormattingStyle(FormattingStyle formattingStyle) {\n this.formattingStyle = Objects.requireNonNull(formattingStyle);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":578,"symbol":"setLenient","kind":"method","lang":"java","doc":"Strictness#LENIENT}: {@code setStrictness(Strictness.LENIENT)} @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern. @see JsonReader#setStrictness(Strictness) @see JsonWriter#setStrictness(Strictness) @see #setStrictness(Strictness)","code":"@Deprecated\n @InlineMe(\n replacement = \"this.setStrictness(Strictness.LENIENT)\",\n imports = \"com.google.gson.Strictness\")\n @CanIgnoreReturnValue\n public GsonBuilder setLenient() {\n return setStrictness(Strictness.LENIENT);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":600,"symbol":"setStrictness","kind":"method","lang":"java","doc":"@param strictness the new strictness mode. May not be {@code null}. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern. @see JsonReader#setStrictness(Strictness) @see JsonWriter#setStrictness(Strictness) @since 2.11.0","code":"@CanIgnoreReturnValue\n public GsonBuilder setStrictness(Strictness strictness) {\n this.strictness = Objects.requireNonNull(strictness);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":613,"symbol":"disableHtmlEscaping","kind":"method","lang":"java","doc":"By default, Gson escapes HTML characters such as < > etc. Use this option to configure Gson to pass-through HTML characters as is. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.3","code":"@CanIgnoreReturnValue\n public GsonBuilder disableHtmlEscaping() {\n this.escapeHtmlChars = false;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":638,"symbol":"setDateFormat","kind":"method","lang":"java","doc":"@param pattern the pattern that dates will be serialized/deserialized to/from; can be {@code null} to reset the pattern @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @throws IllegalArgumentException if the pattern is invalid @since 1.2","code":"@CanIgnoreReturnValue\n public GsonBuilder setDateFormat(String pattern) {\n if (pattern != null) {\n try {\n SimpleDateFormat unused = new SimpleDateFormat(pattern);\n } catch (IllegalArgumentException e) {\n // Throw exception if it is an invalid date format\n throw new IllegalArgumentException(\"The date pattern '\" + pattern + \"' is not valid\", e);\n }\n }\n this.datePattern = pattern;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":672,"symbol":"setDateFormat","kind":"method","lang":"java","doc":"@param dateStyle the predefined date style that date objects will be serialized/deserialized to/from @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @throws IllegalArgumentException if the style is invalid @since 1.2","code":"@Deprecated\n @CanIgnoreReturnValue\n public GsonBuilder setDateFormat(int dateStyle) {\n this.dateStyle = checkDateFormatStyle(dateStyle);\n this.datePattern = null;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":696,"symbol":"setDateFormat","kind":"method","lang":"java","doc":"to/from @param timeStyle the predefined style for the time portion of the date objects @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @throws IllegalArgumentException if the style values are invalid @since 1.2","code":"@CanIgnoreReturnValue\n public GsonBuilder setDateFormat(int dateStyle, int timeStyle) {\n this.dateStyle = checkDateFormatStyle(dateStyle);\n this.timeStyle = checkDateFormatStyle(timeStyle);\n this.datePattern = null;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":704,"symbol":"checkDateFormatStyle","kind":"method","lang":"java","code":"private static int checkDateFormatStyle(int style) {\n // Valid DateFormat styles are: 0, 1, 2, 3 (FULL, LONG, MEDIUM, SHORT)\n if (style < 0 || style > 3) {\n throw new IllegalArgumentException(\"Invalid style: \" + style);\n }\n return style;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":739,"symbol":"registerTypeAdapter","kind":"method","lang":"java","doc":"InstanceCreator}, {@link JsonSerializer}, and a {@link JsonDeserializer} interfaces. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @throws IllegalArgumentException if the type adapter being registered is for {@code Object} class or {@link JsonElement} or any of its subclasses @see #registerTypeHierarchyAdapter(Class, Object)","code":"@CanIgnoreReturnValue\n public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {\n Objects.requireNonNull(type);\n Objects.requireNonNull(typeAdapter);\n if (!(typeAdapter instanceof JsonSerializer\n || typeAdapter instanceof JsonDeserializer\n || typeAdapter instanceof InstanceCreator\n || typeAdapter instanceof TypeAdapter)) {\n throw new IllegalArgumentException(\n \"Class \"\n + typeAdapter.getClass().getName()\n + \" does not implement any supported type adapter class or interface\");\n }\n\n if (hasNonOverridableAdapter(type)) {\n throw new IllegalArgumentException(\"Cannot override built-in adapter for \" + type);\n }\n\n if (typeAdapter instanceof InstanceCreator) {\n instanceCreators.put(type, (InstanceCreator) typeAdapter);\n }\n if (typeAdapter instanceof JsonSerializer || typeAdapter instanceof JsonDeserializer) {\n TypeToken typeToken = TypeToken.get(type);\n factories.add(TreeTypeAdapter.newFactoryWithMatchRawType(typeToken, typeAdapter));\n }\n if (typeAdapter instanceof TypeAdapter) {\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":774,"symbol":"hasNonOverridableAdapter","kind":"method","lang":"java","doc":"Whether the type has a built-in adapter which cannot be overridden.","code":"private static boolean hasNonOverridableAdapter(Type type) {\n return type == Object.class;\n // This should also cover `JsonElement.class.isAssignableFrom(type)`, however for backward\n // compatibility this is not covered here because really old Gson versions had no built-in\n // adapter for JsonElement so users registered custom adapters. These adapters don't have any\n // effect in recent Gson versions. See\n // https://github.com/google/gson/issues/2787#issuecomment-2581568157\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":795,"symbol":"registerTypeAdapterFactory","kind":"method","lang":"java","doc":"

    The created Gson instance might only use the factory once to create an adapter for a specific type and cache the result. It is not guaranteed that the factory will be used again every time the type is serialized or deserialized. @since 2.1","code":"@CanIgnoreReturnValue\n public GsonBuilder registerTypeAdapterFactory(TypeAdapterFactory factory) {\n Objects.requireNonNull(factory);\n factories.add(factory);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":818,"symbol":"registerTypeHierarchyAdapter","kind":"method","lang":"java","doc":"JsonSerializer} or {@link JsonDeserializer} interfaces. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @throws IllegalArgumentException if the type adapter being registered is for {@link JsonElement} or any of its subclasses @since 1.7","code":"@CanIgnoreReturnValue\n public GsonBuilder registerTypeHierarchyAdapter(Class baseType, Object typeAdapter) {\n Objects.requireNonNull(baseType);\n Objects.requireNonNull(typeAdapter);\n if (!(typeAdapter instanceof JsonSerializer\n || typeAdapter instanceof JsonDeserializer\n || typeAdapter instanceof TypeAdapter)) {\n throw new IllegalArgumentException(\n \"Class \"\n + typeAdapter.getClass().getName()\n + \" does not implement any supported type adapter class or interface\");\n }\n\n if (typeAdapter instanceof JsonDeserializer || typeAdapter instanceof JsonSerializer) {\n hierarchyFactories.add(TreeTypeAdapter.newTypeHierarchyFactory(baseType, typeAdapter));\n }\n if (typeAdapter instanceof TypeAdapter) {\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n TypeAdapterFactory factory =\n TypeAdapters.newTypeHierarchyFactory(baseType, (TypeAdapter) typeAdapter);\n factories.add(factory);\n }\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":862,"symbol":"serializeSpecialFloatingPointValues","kind":"method","lang":"java","doc":"an {@link IllegalArgumentException}. This method provides a way to override the default behavior when you know that the JSON receiver will be able to handle these special values. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 1.3","code":"@CanIgnoreReturnValue\n public GsonBuilder serializeSpecialFloatingPointValues() {\n this.serializeSpecialFloatingPointValues = true;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":883,"symbol":"disableJdkUnsafe","kind":"method","lang":"java","doc":"to detect classes which cannot be deserialized in an early stage of development, this method allows disabling usage of {@code Unsafe}. @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 2.9.0","code":"@CanIgnoreReturnValue\n public GsonBuilder disableJdkUnsafe() {\n this.useJdkUnsafe = false;\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":909,"symbol":"addReflectionAccessFilter","kind":"method","lang":"java","doc":"class or its members are accessed during serialization or deserialization. @param filter filter to add @return a reference to this {@code GsonBuilder} object to fulfill the \"Builder\" pattern @since 2.9.1","code":"@CanIgnoreReturnValue\n public GsonBuilder addReflectionAccessFilter(ReflectionAccessFilter filter) {\n Objects.requireNonNull(filter);\n reflectionFilters.addFirst(filter);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":922,"symbol":"create","kind":"method","lang":"java","doc":"Creates a {@link Gson} instance based on the current configuration. This method is free of side-effects to this {@code GsonBuilder} instance and hence can be called multiple times. @return an instance of Gson configured with the options currently set in this builder","code":"public Gson create() {\n return new Gson(this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":926,"symbol":"createFactories","kind":"method","lang":"java","code":"List createFactories(\n ConstructorConstructor constructorConstructor,\n JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory) {\n ArrayList factories = new ArrayList<>();\n\n // built-in type adapters that cannot be overridden\n factories.add(TypeAdapters.JSON_ELEMENT_FACTORY);\n factories.add(ObjectTypeAdapter.getFactory(objectToNumberStrategy));\n\n // the excluder must precede all adapters that handle user-defined types\n factories.add(excluder);\n\n // users' type adapters\n addUserDefinedAdapters(factories);\n\n // custom Date adapters\n addDateTypeAdapters(factories);\n\n // type adapters for basic platform types\n factories.add(TypeAdapters.STRING_FACTORY);\n factories.add(TypeAdapters.INTEGER_FACTORY);\n factories.add(TypeAdapters.BOOLEAN_FACTORY);\n factories.add(TypeAdapters.BYTE_FACTORY);\n factories.add(TypeAdapters.SHORT_FACTORY);\n TypeAdapter longAdapter = longSerializationPolicy.typeAdapter();\n factories.add(TypeAdapters.newFactory(long.class, Long.class, longAdapter));\n factories.add(TypeAdapters.newFactory(double.class, Double.class, doubleAdapter()));\n factories.a"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":1005,"symbol":"newImmutableList","kind":"method","lang":"java","code":"static List newImmutableList(Collection collection) {\n if (collection.isEmpty()) {\n return Collections.emptyList();\n }\n if (collection.size() == 1) {\n return Collections.singletonList(\n collection instanceof List\n ? ((List) collection).get(0)\n : collection.iterator().next());\n }\n @SuppressWarnings(\"unchecked\")\n List list = (List) Collections.unmodifiableList(Arrays.asList(collection.toArray()));\n return list;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":1020,"symbol":"doubleAdapter","kind":"method","lang":"java","code":"private TypeAdapter doubleAdapter() {\n return serializeSpecialFloatingPointValues ? TypeAdapters.DOUBLE : TypeAdapters.DOUBLE_STRICT;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":1024,"symbol":"floatAdapter","kind":"method","lang":"java","code":"private TypeAdapter floatAdapter() {\n return serializeSpecialFloatingPointValues ? TypeAdapters.FLOAT : TypeAdapters.FLOAT_STRICT;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":1028,"symbol":"addUserDefinedAdapters","kind":"method","lang":"java","code":"private void addUserDefinedAdapters(List all) {\n if (!this.factories.isEmpty()) {\n List reversedFactories = new ArrayList<>(this.factories);\n Collections.reverse(reversedFactories);\n all.addAll(reversedFactories);\n }\n\n if (!this.hierarchyFactories.isEmpty()) {\n List reversedHierarchyFactories =\n new ArrayList<>(this.hierarchyFactories);\n Collections.reverse(reversedHierarchyFactories);\n all.addAll(reversedHierarchyFactories);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/GsonBuilder.java","line":1043,"symbol":"addDateTypeAdapters","kind":"method","lang":"java","code":"private void addDateTypeAdapters(List factories) {\n TypeAdapterFactory dateAdapterFactory;\n boolean sqlTypesSupported = SqlTypesSupport.SUPPORTS_SQL_TYPES;\n TypeAdapterFactory sqlTimestampAdapterFactory = null;\n TypeAdapterFactory sqlDateAdapterFactory = null;\n\n if (datePattern != null && !datePattern.trim().isEmpty()) {\n dateAdapterFactory = DefaultDateTypeAdapter.DateType.DATE.createAdapterFactory(datePattern);\n\n if (sqlTypesSupported) {\n sqlTimestampAdapterFactory =\n SqlTypesSupport.TIMESTAMP_DATE_TYPE.createAdapterFactory(datePattern);\n sqlDateAdapterFactory = SqlTypesSupport.DATE_DATE_TYPE.createAdapterFactory(datePattern);\n }\n } else if (dateStyle != DateFormat.DEFAULT || timeStyle != DateFormat.DEFAULT) {\n dateAdapterFactory =\n DefaultDateTypeAdapter.DateType.DATE.createAdapterFactory(dateStyle, timeStyle);\n\n if (sqlTypesSupported) {\n sqlTimestampAdapterFactory =\n SqlTypesSupport.TIMESTAMP_DATE_TYPE.createAdapterFactory(dateStyle, timeStyle);\n sqlDateAdapterFactory =\n SqlTypesSupport.DATE_DATE_TYPE.createAdapterFactory(dateStyle, timeStyle);\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/InstanceCreator.java","line":80,"symbol":"InstanceCreator","kind":"interface","lang":"java","doc":"@param the type of object that will be created by this implementation. @see GsonBuilder#registerTypeAdapter(Type, Object) @author Inderjeet Singh @author Joel Leitch","code":"public interface InstanceCreator {\n\n /**\n * Gson invokes this call-back method during deserialization to create an instance of the\n * specified type. The fields of the returned instance are overwritten with the data present in\n * the JSON. Since the prior contents of the object are destroyed and overwritten, do not return\n * an instance that is useful elsewhere. In particular, do not return a common instance, always\n * use {@code new} to create a new instance.\n *\n * @param type the parameterized T represented as a {@link Type}.\n * @return a default object instance of type T.\n */\n T createInstance(Type type);\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/InstanceCreator.java","line":92,"symbol":"createInstance","kind":"method","lang":"java","doc":"an instance that is useful elsewhere. In particular, do not return a common instance, always use {@code new} to create a new instance. @param type the parameterized T represented as a {@link Type}. @return a default object instance of type T.","code":"T createInstance(Type type);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":42,"symbol":"JsonArray","kind":"class","lang":"java","doc":"

    See the {@link JsonElement} documentation for details on how to convert {@code JsonArray} and generally any {@code JsonElement} from and to JSON. @author Inderjeet Singh @author Joel Leitch","code":"public final class JsonArray extends JsonElement implements Iterable {\n private final ArrayList elements;\n\n /** Creates an empty JsonArray. */\n @SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonArray() {\n elements = new ArrayList<>();\n }\n\n /**\n * Creates an empty JsonArray with the desired initial capacity.\n *\n * @param capacity initial capacity.\n * @throws IllegalArgumentException if the {@code capacity} is negative\n * @since 2.8.1\n */\n @SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonArray(int capacity) {\n elements = new ArrayList<>(capacity);\n }\n\n /**\n * Creates a deep copy of this element and all its children.\n *\n * @since 2.8.2\n */\n @Override\n public JsonArray deepCopy() {\n if (!elements.isEmpty()) {\n JsonArray result = new JsonArray(elements.size());\n for (JsonElement element : elements) {\n result.add(element.deepCopy());\n }\n return result;\n }\n return new JsonArray();\n }\n\n /**\n * Adds the specified boolean to self.\n *\n * @param bool the boolean that needs to be added to the array.\n * @since 2.4\n */\n public void add(Boolean"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":46,"symbol":"JsonArray","kind":"constructor","lang":"java","doc":"Creates an empty JsonArray.","code":"@SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonArray() {\n elements = new ArrayList<>();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":58,"symbol":"JsonArray","kind":"constructor","lang":"java","doc":"Creates an empty JsonArray with the desired initial capacity. @param capacity initial capacity. @throws IllegalArgumentException if the {@code capacity} is negative @since 2.8.1","code":"@SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonArray(int capacity) {\n elements = new ArrayList<>(capacity);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":68,"symbol":"deepCopy","kind":"method","lang":"java","doc":"Creates a deep copy of this element and all its children. @since 2.8.2","code":"@Override\n public JsonArray deepCopy() {\n if (!elements.isEmpty()) {\n JsonArray result = new JsonArray(elements.size());\n for (JsonElement element : elements) {\n result.add(element.deepCopy());\n }\n return result;\n }\n return new JsonArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":86,"symbol":"add","kind":"method","lang":"java","doc":"Adds the specified boolean to self. @param bool the boolean that needs to be added to the array. @since 2.4","code":"public void add(Boolean bool) {\n elements.add(bool == null ? JsonNull.INSTANCE : new JsonPrimitive(bool));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":96,"symbol":"add","kind":"method","lang":"java","doc":"Adds the specified character to self. @param character the character that needs to be added to the array. @since 2.4","code":"public void add(Character character) {\n elements.add(character == null ? JsonNull.INSTANCE : new JsonPrimitive(character));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":106,"symbol":"add","kind":"method","lang":"java","doc":"Adds the specified number to self. @param number the number that needs to be added to the array. @since 2.4","code":"public void add(Number number) {\n elements.add(number == null ? JsonNull.INSTANCE : new JsonPrimitive(number));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":116,"symbol":"add","kind":"method","lang":"java","doc":"Adds the specified string to self. @param string the string that needs to be added to the array. @since 2.4","code":"public void add(String string) {\n elements.add(string == null ? JsonNull.INSTANCE : new JsonPrimitive(string));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":125,"symbol":"add","kind":"method","lang":"java","doc":"Adds the specified element to self. @param element the element that needs to be added to the array.","code":"public void add(JsonElement element) {\n if (element == null) {\n element = JsonNull.INSTANCE;\n }\n elements.add(element);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":137,"symbol":"addAll","kind":"method","lang":"java","doc":"Adds all the elements of the specified array to self. @param array the array whose elements need to be added to the array.","code":"public void addAll(JsonArray array) {\n elements.addAll(array.elements);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":149,"symbol":"set","kind":"method","lang":"java","doc":"@param index index of the element to replace @param element element to be stored at the specified position @return the element previously at the specified position @throws IndexOutOfBoundsException if the specified index is outside the array bounds","code":"@CanIgnoreReturnValue\n public JsonElement set(int index, JsonElement element) {\n return elements.set(index, element == null ? JsonNull.INSTANCE : element);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":162,"symbol":"remove","kind":"method","lang":"java","doc":"array does not contain the element, it is unchanged. @param element element to be removed from this array, if present @return true if this array contained the specified element, false otherwise @since 2.3","code":"@CanIgnoreReturnValue\n public boolean remove(JsonElement element) {\n return elements.remove(element);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":177,"symbol":"remove","kind":"method","lang":"java","doc":"@param index index the index of the element to be removed @return the element previously at the specified position @throws IndexOutOfBoundsException if the specified index is outside the array bounds @since 2.3","code":"@CanIgnoreReturnValue\n public JsonElement remove(int index) {\n return elements.remove(index);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":189,"symbol":"contains","kind":"method","lang":"java","doc":"Returns true if this array contains the specified element. @return true if this array contains the specified element. @param element whose presence in this array is to be tested @since 2.3","code":"public boolean contains(JsonElement element) {\n return elements.contains(element);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":198,"symbol":"size","kind":"method","lang":"java","doc":"Returns the number of elements in the array. @return the number of elements in the array.","code":"public int size() {\n return elements.size();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":208,"symbol":"isEmpty","kind":"method","lang":"java","doc":"Returns true if the array is empty. @return true if the array is empty. @since 2.8.7","code":"public boolean isEmpty() {\n return elements.isEmpty();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":218,"symbol":"iterator","kind":"method","lang":"java","doc":"Returns an iterator to navigate the elements of the array. Since the array is an ordered list, the iterator navigates the elements in the order they were inserted. @return an iterator to navigate the elements of the array.","code":"@Override\n public Iterator iterator() {\n return elements.iterator();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":231,"symbol":"get","kind":"method","lang":"java","doc":"@param i the index of the element that is being sought. @return the element present at the i-th index. @throws IndexOutOfBoundsException if {@code i} is negative or greater than or equal to the {@link #size()} of the array.","code":"public JsonElement get(int i) {\n return elements.get(i);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":235,"symbol":"getAsSingleElement","kind":"method","lang":"java","code":"private JsonElement getAsSingleElement() {\n int size = elements.size();\n if (size == 1) {\n return elements.get(0);\n }\n throw new IllegalStateException(\"Array must have size 1, but has size \" + size);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":251,"symbol":"getAsNumber","kind":"method","lang":"java","doc":"method calls {@link JsonElement#getAsNumber()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a number if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public Number getAsNumber() {\n return getAsSingleElement().getAsNumber();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":264,"symbol":"getAsString","kind":"method","lang":"java","doc":"method calls {@link JsonElement#getAsString()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a String if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public String getAsString() {\n return getAsSingleElement().getAsString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":277,"symbol":"getAsDouble","kind":"method","lang":"java","doc":"calls {@link JsonElement#getAsDouble()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a double if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public double getAsDouble() {\n return getAsSingleElement().getAsDouble();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":291,"symbol":"getAsBigDecimal","kind":"method","lang":"java","doc":"exceptions declared by that method can occur. @return this element as a {@link BigDecimal} if it is single element array. @throws IllegalStateException if the array is empty or has more than one element. @since 1.2","code":"@Override\n public BigDecimal getAsBigDecimal() {\n return getAsSingleElement().getAsBigDecimal();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":305,"symbol":"getAsBigInteger","kind":"method","lang":"java","doc":"exceptions declared by that method can occur. @return this element as a {@link BigInteger} if it is single element array. @throws IllegalStateException if the array is empty or has more than one element. @since 1.2","code":"@Override\n public BigInteger getAsBigInteger() {\n return getAsSingleElement().getAsBigInteger();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":318,"symbol":"getAsFloat","kind":"method","lang":"java","doc":"calls {@link JsonElement#getAsFloat()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a float if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public float getAsFloat() {\n return getAsSingleElement().getAsFloat();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":331,"symbol":"getAsLong","kind":"method","lang":"java","doc":"calls {@link JsonElement#getAsLong()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a long if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public long getAsLong() {\n return getAsSingleElement().getAsLong();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":344,"symbol":"getAsInt","kind":"method","lang":"java","doc":"calls {@link JsonElement#getAsInt()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as an integer if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public int getAsInt() {\n return getAsSingleElement().getAsInt();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":357,"symbol":"getAsByte","kind":"method","lang":"java","doc":"method calls {@link JsonElement#getAsByte()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a primitive byte if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public byte getAsByte() {\n return getAsSingleElement().getAsByte();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":372,"symbol":"getAsCharacter","kind":"method","lang":"java","doc":"@return this element as a character if it is single element array. @throws IllegalStateException if the array is empty or has more than one element. @deprecated This method is misleading, as it does not get this element as a char but rather as a string's first character.","code":"@Deprecated\n @Override\n public char getAsCharacter() {\n return getAsSingleElement().getAsCharacter();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":386,"symbol":"getAsShort","kind":"method","lang":"java","doc":"method calls {@link JsonElement#getAsShort()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a primitive short if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public short getAsShort() {\n return getAsSingleElement().getAsShort();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":399,"symbol":"getAsBoolean","kind":"method","lang":"java","doc":"calls {@link JsonElement#getAsBoolean()} on the element, therefore any of the exceptions declared by that method can occur. @return this element as a boolean if it is single element array. @throws IllegalStateException if the array is empty or has more than one element.","code":"@Override\n public boolean getAsBoolean() {\n return getAsSingleElement().getAsBoolean();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":415,"symbol":"asList","kind":"method","lang":"java","doc":"null} handling, a {@link NullPointerException} is thrown when trying to add {@code null}. Use {@link JsonNull} for JSON null values. @return mutable {@code List} view @since 2.10","code":"public List asList() {\n return new NonNullElementWrapperList<>(elements);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":423,"symbol":"equals","kind":"method","lang":"java","doc":"Returns whether the other object is equal to this. This method only considers the other object to be equal if it is an instance of {@code JsonArray} and has equal elements in the same order.","code":"@Override\n public boolean equals(Object o) {\n return (o == this) || (o instanceof JsonArray && ((JsonArray) o).elements.equals(elements));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonArray.java","line":432,"symbol":"hashCode","kind":"method","lang":"java","doc":"Returns the hash code of this array. This method calculates the hash code based on the elements of this array.","code":"@Override\n public int hashCode() {\n return elements.hashCode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonDeserializationContext.java","line":28,"symbol":"JsonDeserializationContext","kind":"interface","lang":"java","doc":"Context for deserialization that is passed to a custom deserializer during invocation of its {@link JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)} method. @author Inderjeet Singh @author Joel Leitch","code":"public interface JsonDeserializationContext {\n\n /**\n * Invokes default deserialization on the specified object. It should never be invoked on the\n * element received as a parameter of the {@link JsonDeserializer#deserialize(JsonElement, Type,\n * JsonDeserializationContext)} method. Doing so will result in an infinite loop since Gson will\n * in-turn call the custom deserializer again.\n *\n * @param json the parse tree.\n * @param typeOfT type of the expected return value.\n * @param The type of the deserialized object.\n * @return An object of type typeOfT.\n * @throws JsonParseException if the parse tree does not contain expected data.\n */\n @SuppressWarnings(\"TypeParameterUnusedInFormals\")\n T deserialize(JsonElement json, Type typeOfT) throws JsonParseException;\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonDeserializationContext.java","line":42,"symbol":"deserialize","kind":"method","lang":"java","doc":"@param json the parse tree. @param typeOfT type of the expected return value. @param The type of the deserialized object. @return An object of type typeOfT. @throws JsonParseException if the parse tree does not contain expected data.","code":"@SuppressWarnings(\"TypeParameterUnusedInFormals\")\n T deserialize(JsonElement json, Type typeOfT) throws JsonParseException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonDeserializer.java","line":77,"symbol":"JsonDeserializer","kind":"interface","lang":"java","doc":"@author Inderjeet Singh @author Joel Leitch @param type for which the deserializer is being registered. It is possible that a deserializer may be asked to deserialize a specific generic type of the T. @see GsonBuilder#registerTypeAdapter(Type, Object)","code":"public interface JsonDeserializer {\n\n /**\n * Gson invokes this call-back method during deserialization when it encounters a field of the\n * specified type.\n *\n *

    In the implementation of this call-back method, you should consider invoking {@link\n * JsonDeserializationContext#deserialize(JsonElement, Type)} method to create objects for any\n * non-trivial field of the returned object. However, you should never invoke it on the same type\n * passing {@code json} since that will cause an infinite loop (Gson will call your call-back\n * method again).\n *\n * @param json The JSON data being deserialized\n * @param typeOfT The type of the Object to deserialize to\n * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T}\n * @throws JsonParseException if json is not in the expected format of {@code typeOfT}\n */\n T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)\n throws JsonParseException;\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonDeserializer.java","line":94,"symbol":"deserialize","kind":"method","lang":"java","doc":"@param json The JSON data being deserialized @param typeOfT The type of the Object to deserialize to @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} @throws JsonParseException if json is not in the expected format of {@code typeOfT}","code":"T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)\n throws JsonParseException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":96,"symbol":"JsonElement","kind":"class","lang":"java","doc":"

  • {@link TypeAdapter#toJsonTree(Object)} @author Inderjeet Singh @author Joel Leitch","code":"public abstract class JsonElement {\n /**\n * @deprecated Creating custom {@code JsonElement} subclasses is highly discouraged and can lead\n * to undefined behavior.
    \n * This constructor is only kept for backward compatibility.\n */\n @Deprecated\n public JsonElement() {}\n\n /**\n * Returns a deep copy of this element. Immutable elements like primitives and nulls are not\n * copied.\n *\n * @since 2.8.2\n */\n public abstract JsonElement deepCopy();\n\n /**\n * Provides a check for verifying if this element is a JSON array or not.\n *\n * @return true if this element is of type {@link JsonArray}, false otherwise.\n */\n public boolean isJsonArray() {\n return this instanceof JsonArray;\n }\n\n /**\n * Provides a check for verifying if this element is a JSON object or not.\n *\n * @return true if this element is of type {@link JsonObject}, false otherwise.\n */\n public boolean isJsonObject() {\n return this instanceof JsonObject;\n }\n\n /**\n * Provides a check for verifying if this element is a primitive or not.\n *\n * @return true if this element is of type {@link JsonPrimitive}, false otherwise.\n */\n public boolean isJsonPrimitive() {\n r"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":102,"symbol":"JsonElement","kind":"constructor","lang":"java","doc":"@deprecated Creating custom {@code JsonElement} subclasses is highly discouraged and can lead to undefined behavior.
    This constructor is only kept for backward compatibility.","code":"@Deprecated\n public JsonElement() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":111,"symbol":"deepCopy","kind":"method","lang":"java","doc":"Returns a deep copy of this element. Immutable elements like primitives and nulls are not copied. @since 2.8.2","code":"public abstract JsonElement deepCopy();"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":118,"symbol":"isJsonArray","kind":"method","lang":"java","doc":"Provides a check for verifying if this element is a JSON array or not. @return true if this element is of type {@link JsonArray}, false otherwise.","code":"public boolean isJsonArray() {\n return this instanceof JsonArray;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":127,"symbol":"isJsonObject","kind":"method","lang":"java","doc":"Provides a check for verifying if this element is a JSON object or not. @return true if this element is of type {@link JsonObject}, false otherwise.","code":"public boolean isJsonObject() {\n return this instanceof JsonObject;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":136,"symbol":"isJsonPrimitive","kind":"method","lang":"java","doc":"Provides a check for verifying if this element is a primitive or not. @return true if this element is of type {@link JsonPrimitive}, false otherwise.","code":"public boolean isJsonPrimitive() {\n return this instanceof JsonPrimitive;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":146,"symbol":"isJsonNull","kind":"method","lang":"java","doc":"Provides a check for verifying if this element represents a null value or not. @return true if this element is of type {@link JsonNull}, false otherwise. @since 1.2","code":"public boolean isJsonNull() {\n return this instanceof JsonNull;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":159,"symbol":"getAsJsonObject","kind":"method","lang":"java","doc":"after ensuring that this element is of the desired type by calling {@link #isJsonObject()} first. @return this element as a {@link JsonObject}. @throws IllegalStateException if this element is of another type.","code":"public JsonObject getAsJsonObject() {\n if (isJsonObject()) {\n return (JsonObject) this;\n }\n throw new IllegalStateException(\"Not a JSON Object: \" + this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":174,"symbol":"getAsJsonArray","kind":"method","lang":"java","doc":"type, an {@link IllegalStateException} will result. Hence it is best to use this method after ensuring that this element is of the desired type by calling {@link #isJsonArray()} first. @return this element as a {@link JsonArray}. @throws IllegalStateException if this element is of another type.","code":"public JsonArray getAsJsonArray() {\n if (isJsonArray()) {\n return (JsonArray) this;\n }\n throw new IllegalStateException(\"Not a JSON Array: \" + this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":190,"symbol":"getAsJsonPrimitive","kind":"method","lang":"java","doc":"after ensuring that this element is of the desired type by calling {@link #isJsonPrimitive()} first. @return this element as a {@link JsonPrimitive}. @throws IllegalStateException if this element is of another type.","code":"public JsonPrimitive getAsJsonPrimitive() {\n if (isJsonPrimitive()) {\n return (JsonPrimitive) this;\n }\n throw new IllegalStateException(\"Not a JSON Primitive: \" + this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":206,"symbol":"getAsJsonNull","kind":"method","lang":"java","doc":"ensuring that this element is of the desired type by calling {@link #isJsonNull()} first. @return this element as a {@link JsonNull}. @throws IllegalStateException if this element is of another type. @since 1.2","code":"@CanIgnoreReturnValue // When this method is used only to verify that the value is JsonNull\n public JsonNull getAsJsonNull() {\n if (isJsonNull()) {\n return (JsonNull) this;\n }\n throw new IllegalStateException(\"Not a JSON Null: \" + this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":223,"symbol":"getAsBoolean","kind":"method","lang":"java","doc":"@return this element as a primitive boolean value. @throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public boolean getAsBoolean() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":236,"symbol":"getAsNumber","kind":"method","lang":"java","doc":"@return this element as a {@link Number}. @throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}, or cannot be converted to a number. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public Number getAsNumber() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":249,"symbol":"getAsString","kind":"method","lang":"java","doc":"@return this element as a string value. @throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public String getAsString() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":263,"symbol":"getAsDouble","kind":"method","lang":"java","doc":"@throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws NumberFormatException if the value contained is not a valid double. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public double getAsDouble() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":277,"symbol":"getAsFloat","kind":"method","lang":"java","doc":"@throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws NumberFormatException if the value contained is not a valid float. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public float getAsFloat() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":291,"symbol":"getAsLong","kind":"method","lang":"java","doc":"@throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws NumberFormatException if the value contained is not a valid long. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public long getAsLong() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":305,"symbol":"getAsInt","kind":"method","lang":"java","doc":"@throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws NumberFormatException if the value contained is not a valid integer. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public int getAsInt() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":320,"symbol":"getAsByte","kind":"method","lang":"java","doc":"JsonArray}. @throws NumberFormatException if the value contained is not a valid byte. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element. @since 1.3","code":"public byte getAsByte() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":336,"symbol":"getAsCharacter","kind":"method","lang":"java","doc":"@throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element. @since 1.3 @deprecated This method is misleading, as it does not get this element as a char but rather as a string's first character.","code":"@Deprecated\n public char getAsCharacter() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":352,"symbol":"getAsBigDecimal","kind":"method","lang":"java","doc":"JsonArray}. @throws NumberFormatException if this element is not a valid {@link BigDecimal}. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element. @since 1.2","code":"public BigDecimal getAsBigDecimal() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":367,"symbol":"getAsBigInteger","kind":"method","lang":"java","doc":"JsonArray}. @throws NumberFormatException if this element is not a valid {@link BigInteger}. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element. @since 1.2","code":"public BigInteger getAsBigInteger() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":381,"symbol":"getAsShort","kind":"method","lang":"java","doc":"@throws UnsupportedOperationException if this element is not a {@link JsonPrimitive} or {@link JsonArray}. @throws NumberFormatException if the value contained is not a valid short. @throws IllegalStateException if this element is of the type {@link JsonArray} but contains more than a single element.","code":"public short getAsShort() {\n throw new UnsupportedOperationException(getClass().getSimpleName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonElement.java","line":420,"symbol":"toString","kind":"method","lang":"java","doc":"String json = jsonPrimitive.toString(); // json: \"with \\\" quote\" String value = jsonPrimitive.getAsString(); // value: with \" quote ","code":"@Override\n public String toString() {\n try {\n StringBuilder stringBuilder = new StringBuilder();\n JsonWriter jsonWriter = new JsonWriter(Streams.writerForAppendable(stringBuilder));\n // Make writer lenient because toString() must not fail, even if for example JsonPrimitive\n // contains NaN\n jsonWriter.setStrictness(Strictness.LENIENT);\n Streams.write(this, jsonWriter);\n return stringBuilder.toString();\n } catch (IOException e) {\n throw new AssertionError(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonIOException.java","line":24,"symbol":"JsonIOException","kind":"class","lang":"java","doc":"This exception is raised when Gson was unable to read an input stream or write to one. @author Inderjeet Singh @author Joel Leitch","code":"@SuppressWarnings(\"MemberName\") // class name is part of the public API\npublic final class JsonIOException extends JsonParseException {\n private static final long serialVersionUID = 1L;\n\n public JsonIOException(String msg) {\n super(msg);\n }\n\n public JsonIOException(String msg, Throwable cause) {\n super(msg, cause);\n }\n\n /**\n * Creates exception with the specified cause. Consider using {@link #JsonIOException(String,\n * Throwable)} instead if you can describe what happened.\n *\n * @param cause root exception that caused this exception to be thrown.\n */\n public JsonIOException(Throwable cause) {\n super(cause);\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonIOException.java","line":28,"symbol":"JsonIOException","kind":"constructor","lang":"java","code":"public JsonIOException(String msg) {\n super(msg);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonIOException.java","line":32,"symbol":"JsonIOException","kind":"constructor","lang":"java","code":"public JsonIOException(String msg, Throwable cause) {\n super(msg, cause);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonIOException.java","line":42,"symbol":"JsonIOException","kind":"constructor","lang":"java","doc":"Creates exception with the specified cause. Consider using {@link #JsonIOException(String, Throwable)} instead if you can describe what happened. @param cause root exception that caused this exception to be thrown.","code":"public JsonIOException(Throwable cause) {\n super(cause);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonNull.java","line":26,"symbol":"JsonNull","kind":"class","lang":"java","doc":"A class representing a JSON {@code null} value. @author Inderjeet Singh @author Joel Leitch @since 1.2","code":"public final class JsonNull extends JsonElement {\n /**\n * Singleton for {@code JsonNull}.\n *\n * @since 1.8\n */\n public static final JsonNull INSTANCE = new JsonNull();\n\n /**\n * Creates a new {@code JsonNull} object.\n *\n * @deprecated Deprecated since Gson version 1.8, use {@link #INSTANCE} instead.\n */\n @Deprecated\n public JsonNull() {\n // Do nothing\n }\n\n /**\n * Returns the same instance since it is an immutable value.\n *\n * @since 2.8.2\n */\n @Override\n public JsonNull deepCopy() {\n return INSTANCE;\n }\n\n /** All instances of {@code JsonNull} have the same hash code since they are indistinguishable. */\n @Override\n public int hashCode() {\n return JsonNull.class.hashCode();\n }\n\n /** All instances of {@code JsonNull} are considered equal. */\n @Override\n public boolean equals(Object other) {\n return other instanceof JsonNull;\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonNull.java","line":39,"symbol":"JsonNull","kind":"constructor","lang":"java","doc":"Creates a new {@code JsonNull} object. @deprecated Deprecated since Gson version 1.8, use {@link #INSTANCE} instead.","code":"@Deprecated\n public JsonNull() {\n // Do nothing\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonNull.java","line":49,"symbol":"deepCopy","kind":"method","lang":"java","doc":"Returns the same instance since it is an immutable value. @since 2.8.2","code":"@Override\n public JsonNull deepCopy() {\n return INSTANCE;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonNull.java","line":55,"symbol":"hashCode","kind":"method","lang":"java","doc":"All instances of {@code JsonNull} have the same hash code since they are indistinguishable.","code":"@Override\n public int hashCode() {\n return JsonNull.class.hashCode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonNull.java","line":61,"symbol":"equals","kind":"method","lang":"java","doc":"All instances of {@code JsonNull} are considered equal.","code":"@Override\n public boolean equals(Object other) {\n return other instanceof JsonNull;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":40,"symbol":"JsonObject","kind":"class","lang":"java","doc":"

    See the {@link JsonElement} documentation for details on how to convert {@code JsonObject} and generally any {@code JsonElement} from and to JSON. @author Inderjeet Singh @author Joel Leitch","code":"public final class JsonObject extends JsonElement {\n private final LinkedTreeMap members = new LinkedTreeMap<>(false);\n\n /** Creates an empty JsonObject. */\n @SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonObject() {}\n\n /**\n * Creates a deep copy of this element and all its children.\n *\n * @since 2.8.2\n */\n @Override\n public JsonObject deepCopy() {\n JsonObject result = new JsonObject();\n for (Map.Entry entry : members.entrySet()) {\n result.add(entry.getKey(), entry.getValue().deepCopy());\n }\n return result;\n }\n\n /**\n * Adds a member, which is a name-value pair, to self. The name must be a String, but the value\n * can be an arbitrary {@link JsonElement}, thereby allowing you to build a full tree of\n * JsonElements rooted at this node.\n *\n * @param property name of the member.\n * @param value the member object.\n */\n public void add(String property, JsonElement value) {\n members.put(property, value == null ? JsonNull.INSTANCE : value);\n }\n\n /**\n * Removes the {@code property} from this object.\n *\n * @param property name of the member that should be removed.\n *"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":44,"symbol":"JsonObject","kind":"constructor","lang":"java","doc":"Creates an empty JsonObject.","code":"@SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonObject() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":52,"symbol":"deepCopy","kind":"method","lang":"java","doc":"Creates a deep copy of this element and all its children. @since 2.8.2","code":"@Override\n public JsonObject deepCopy() {\n JsonObject result = new JsonObject();\n for (Map.Entry entry : members.entrySet()) {\n result.add(entry.getKey(), entry.getValue().deepCopy());\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":69,"symbol":"add","kind":"method","lang":"java","doc":"can be an arbitrary {@link JsonElement}, thereby allowing you to build a full tree of JsonElements rooted at this node. @param property name of the member. @param value the member object.","code":"public void add(String property, JsonElement value) {\n members.put(property, value == null ? JsonNull.INSTANCE : value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":81,"symbol":"remove","kind":"method","lang":"java","doc":"@param property name of the member that should be removed. @return the {@link JsonElement} object that is being removed, or {@code null} if no member with this name exists. @since 1.3","code":"@CanIgnoreReturnValue\n public JsonElement remove(String property) {\n return members.remove(property);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":93,"symbol":"addProperty","kind":"method","lang":"java","doc":"Convenience method to add a string member. The specified value is converted to a {@link JsonPrimitive} of String. @param property name of the member. @param value the string value associated with the member.","code":"public void addProperty(String property, String value) {\n add(property, value == null ? JsonNull.INSTANCE : new JsonPrimitive(value));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":104,"symbol":"addProperty","kind":"method","lang":"java","doc":"Convenience method to add a number member. The specified value is converted to a {@link JsonPrimitive} of Number. @param property name of the member. @param value the number value associated with the member.","code":"public void addProperty(String property, Number value) {\n add(property, value == null ? JsonNull.INSTANCE : new JsonPrimitive(value));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":115,"symbol":"addProperty","kind":"method","lang":"java","doc":"Convenience method to add a boolean member. The specified value is converted to a {@link JsonPrimitive} of Boolean. @param property name of the member. @param value the boolean value associated with the member.","code":"public void addProperty(String property, Boolean value) {\n add(property, value == null ? JsonNull.INSTANCE : new JsonPrimitive(value));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":126,"symbol":"addProperty","kind":"method","lang":"java","doc":"Convenience method to add a char member. The specified value is converted to a {@link JsonPrimitive} of Character. @param property name of the member. @param value the char value associated with the member.","code":"public void addProperty(String property, Character value) {\n add(property, value == null ? JsonNull.INSTANCE : new JsonPrimitive(value));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":136,"symbol":"entrySet","kind":"method","lang":"java","doc":"Returns a set of members of this object. The set is ordered, and the order is in which the elements were added. @return a set of members of this object.","code":"public Set> entrySet() {\n return members.entrySet();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":146,"symbol":"keySet","kind":"method","lang":"java","doc":"Returns a set of members key values. @return a set of member keys as Strings @since 2.8.1","code":"public Set keySet() {\n return members.keySet();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":156,"symbol":"size","kind":"method","lang":"java","doc":"Returns the number of key/value pairs in the object. @return the number of key/value pairs in the object. @since 2.7","code":"public int size() {\n return members.size();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":166,"symbol":"isEmpty","kind":"method","lang":"java","doc":"Returns true if the number of key/value pairs in the object is zero. @return true if the number of key/value pairs in the object is zero. @since 2.10.1","code":"public boolean isEmpty() {\n return members.isEmpty();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":176,"symbol":"has","kind":"method","lang":"java","doc":"Convenience method to check if a member with the specified name is present in this object. @param memberName name of the member that is being checked for presence. @return true if there is a member with the specified name, false otherwise.","code":"public boolean has(String memberName) {\n return members.containsKey(memberName);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":186,"symbol":"get","kind":"method","lang":"java","doc":"Returns the member with the specified name. @param memberName name of the member that is being requested. @return the member matching the name, or {@code null} if no such member exists.","code":"public JsonElement get(String memberName) {\n return members.get(memberName);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":198,"symbol":"getAsJsonPrimitive","kind":"method","lang":"java","doc":"@param memberName name of the member being requested. @return the {@code JsonPrimitive} corresponding to the specified member, or {@code null} if no member with this name exists. @throws ClassCastException if the member is not of type {@code JsonPrimitive}.","code":"public JsonPrimitive getAsJsonPrimitive(String memberName) {\n return (JsonPrimitive) members.get(memberName);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":210,"symbol":"getAsJsonArray","kind":"method","lang":"java","doc":"@param memberName name of the member being requested. @return the {@code JsonArray} corresponding to the specified member, or {@code null} if no member with this name exists. @throws ClassCastException if the member is not of type {@code JsonArray}.","code":"public JsonArray getAsJsonArray(String memberName) {\n return (JsonArray) members.get(memberName);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":222,"symbol":"getAsJsonObject","kind":"method","lang":"java","doc":"@param memberName name of the member being requested. @return the {@code JsonObject} corresponding to the specified member, or {@code null} if no member with this name exists. @throws ClassCastException if the member is not of type {@code JsonObject}.","code":"public JsonObject getAsJsonObject(String memberName) {\n return (JsonObject) members.get(memberName);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":237,"symbol":"asMap","kind":"method","lang":"java","doc":"{@code null} handling, a {@link NullPointerException} is thrown when trying to add {@code null}. Use {@link JsonNull} for JSON null values. @return mutable {@code Map} view @since 2.10","code":"public Map asMap() {\n // It is safe to expose the underlying map because it disallows null keys and values\n return members;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":246,"symbol":"equals","kind":"method","lang":"java","doc":"Returns whether the other object is equal to this. This method only considers the other object to be equal if it is an instance of {@code JsonObject} and has equal members, ignoring order.","code":"@Override\n public boolean equals(Object o) {\n return (o == this) || (o instanceof JsonObject && ((JsonObject) o).members.equals(members));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonObject.java","line":255,"symbol":"hashCode","kind":"method","lang":"java","doc":"Returns the hash code of this object. This method calculates the hash code based on the members of this object, ignoring order.","code":"@Override\n public int hashCode() {\n return members.hashCode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParseException.java","line":32,"symbol":"JsonParseException","kind":"class","lang":"java","doc":"exception and do nothing. It is often the case that you want to blow up if there is a parsing error (i.e. often clients do not know how to recover from a {@link JsonParseException}). @author Inderjeet Singh @author Joel Leitch","code":"public class JsonParseException extends RuntimeException {\n static final long serialVersionUID = -4086729973971783390L;\n\n /**\n * Creates exception with the specified message. If you are wrapping another exception, consider\n * using {@link #JsonParseException(String, Throwable)} instead.\n *\n * @param msg error message describing a possible cause of this exception.\n */\n public JsonParseException(String msg) {\n super(msg);\n }\n\n /**\n * Creates exception with the specified message and cause.\n *\n * @param msg error message describing what happened.\n * @param cause root exception that caused this exception to be thrown.\n */\n public JsonParseException(String msg, Throwable cause) {\n super(msg, cause);\n }\n\n /**\n * Creates exception with the specified cause. Consider using {@link #JsonParseException(String,\n * Throwable)} instead if you can describe what happened.\n *\n * @param cause root exception that caused this exception to be thrown.\n */\n public JsonParseException(Throwable cause) {\n super(cause);\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParseException.java","line":41,"symbol":"JsonParseException","kind":"constructor","lang":"java","doc":"Creates exception with the specified message. If you are wrapping another exception, consider using {@link #JsonParseException(String, Throwable)} instead. @param msg error message describing a possible cause of this exception.","code":"public JsonParseException(String msg) {\n super(msg);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParseException.java","line":51,"symbol":"JsonParseException","kind":"constructor","lang":"java","doc":"Creates exception with the specified message and cause. @param msg error message describing what happened. @param cause root exception that caused this exception to be thrown.","code":"public JsonParseException(String msg, Throwable cause) {\n super(msg, cause);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParseException.java","line":61,"symbol":"JsonParseException","kind":"constructor","lang":"java","doc":"Creates exception with the specified cause. Consider using {@link #JsonParseException(String, Throwable)} instead if you can describe what happened. @param cause root exception that caused this exception to be thrown.","code":"public JsonParseException(Throwable cause) {\n super(cause);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":73,"symbol":"JsonParser","kind":"class","lang":"java","doc":" @author Inderjeet Singh @author Joel Leitch @since 1.3","code":"public final class JsonParser {\n /**\n * @deprecated No need to instantiate this class, use the static methods instead.\n */\n @Deprecated\n public JsonParser() {}\n\n /**\n * Parses the specified JSON string into a parse tree. An exception is thrown if the JSON string\n * has multiple top-level JSON elements, or if there is trailing data.\n *\n *

    The JSON string is parsed in {@linkplain JsonReader#setStrictness(Strictness) lenient mode}.\n *\n * @param json JSON text\n * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON\n * @throws JsonParseException if the specified text is not valid JSON\n * @since 2.8.6\n */\n public static JsonElement parseString(String json) throws JsonSyntaxException {\n return parseReader(new StringReader(json));\n }\n\n /**\n * Parses the complete JSON string provided by the reader into a parse tree. An exception is\n * thrown if the JSON string has multiple top-level JSON elements, or if there is trailing data.\n *\n *

    The JSON data is parsed in {@linkplain JsonReader#setStrictness(Strictness) lenient mode}.\n *\n * @param reader JSON text\n * @return a parse tree of {@link JsonElement}s correspondi"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":77,"symbol":"JsonParser","kind":"constructor","lang":"java","doc":"@deprecated No need to instantiate this class, use the static methods instead.","code":"@Deprecated\n public JsonParser() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":91,"symbol":"parseString","kind":"method","lang":"java","doc":"@param json JSON text @return a parse tree of {@link JsonElement}s corresponding to the specified JSON @throws JsonParseException if the specified text is not valid JSON @since 2.8.6","code":"public static JsonElement parseString(String json) throws JsonSyntaxException {\n return parseReader(new StringReader(json));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":107,"symbol":"parseReader","kind":"method","lang":"java","doc":"@param reader JSON text @return a parse tree of {@link JsonElement}s corresponding to the specified JSON @throws JsonParseException if there is an IOException or if the specified text is not valid JSON @since 2.8.6","code":"public static JsonElement parseReader(Reader reader) throws JsonIOException, JsonSyntaxException {\n try {\n JsonReader jsonReader = new JsonReader(reader);\n JsonElement element = parseReader(jsonReader);\n if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {\n throw new JsonSyntaxException(\"Did not consume the entire document.\");\n }\n return element;\n } catch (MalformedJsonException | NumberFormatException e) {\n throw new JsonSyntaxException(e);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":136,"symbol":"parseReader","kind":"method","lang":"java","doc":"returns. @throws JsonParseException if there is an IOException or if the specified text is not valid JSON @since 2.8.6","code":"public static JsonElement parseReader(JsonReader reader)\n throws JsonIOException, JsonSyntaxException {\n Strictness strictness = reader.getStrictness();\n if (strictness == Strictness.LEGACY_STRICT) {\n // For backward compatibility change to LENIENT if reader has default strictness LEGACY_STRICT\n reader.setStrictness(Strictness.LENIENT);\n }\n try {\n return Streams.parse(reader);\n } catch (StackOverflowError | OutOfMemoryError e) {\n throw new JsonParseException(\"Failed parsing JSON source: \" + reader + \" to Json\", e);\n } finally {\n reader.setStrictness(strictness);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":155,"symbol":"parse","kind":"method","lang":"java","doc":"@deprecated Use {@link JsonParser#parseString}","code":"@Deprecated\n @InlineMe(replacement = \"JsonParser.parseString(json)\", imports = \"com.google.gson.JsonParser\")\n public JsonElement parse(String json) throws JsonSyntaxException {\n return parseString(json);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":164,"symbol":"parse","kind":"method","lang":"java","doc":"@deprecated Use {@link JsonParser#parseReader(Reader)}","code":"@Deprecated\n @InlineMe(replacement = \"JsonParser.parseReader(json)\", imports = \"com.google.gson.JsonParser\")\n public JsonElement parse(Reader json) throws JsonIOException, JsonSyntaxException {\n return parseReader(json);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonParser.java","line":173,"symbol":"parse","kind":"method","lang":"java","doc":"@deprecated Use {@link JsonParser#parseReader(JsonReader)}","code":"@Deprecated\n @InlineMe(replacement = \"JsonParser.parseReader(json)\", imports = \"com.google.gson.JsonParser\")\n public JsonElement parse(JsonReader json) throws JsonIOException, JsonSyntaxException {\n return parseReader(json);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":35,"symbol":"JsonPrimitive","kind":"class","lang":"java","doc":"

    See the {@link JsonElement} documentation for details on how to convert {@code JsonPrimitive} and generally any {@code JsonElement} from and to JSON. @author Inderjeet Singh @author Joel Leitch","code":"public final class JsonPrimitive extends JsonElement {\n\n private final Object value;\n\n /**\n * Create a primitive containing a boolean value.\n *\n * @param bool the value to create the primitive with.\n */\n // \"deprecation\" suppression for superclass constructor\n // \"UnnecessaryBoxedVariable\" Error Prone warning is correct since method does not accept\n // null, but cannot be changed anymore since this is public API\n @SuppressWarnings({\"deprecation\", \"UnnecessaryBoxedVariable\"})\n public JsonPrimitive(Boolean bool) {\n value = Objects.requireNonNull(bool);\n }\n\n /**\n * Create a primitive containing a {@link Number}.\n *\n * @param number the value to create the primitive with.\n */\n @SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonPrimitive(Number number) {\n value = Objects.requireNonNull(number);\n }\n\n /**\n * Create a primitive containing a String value.\n *\n * @param string the value to create the primitive with.\n */\n @SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonPrimitive(String string) {\n value = Objects.requireNonNull(string);\n }\n\n /**\n * Create a primitive containing a character. The charac"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":47,"symbol":"JsonPrimitive","kind":"constructor","lang":"java","doc":"@param bool the value to create the primitive with. \"deprecation\" suppression for superclass constructor \"UnnecessaryBoxedVariable\" Error Prone warning is correct since method does not accept null, but cannot be changed anymore since this is public API","code":"@SuppressWarnings({\"deprecation\", \"UnnecessaryBoxedVariable\"})\n public JsonPrimitive(Boolean bool) {\n value = Objects.requireNonNull(bool);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":57,"symbol":"JsonPrimitive","kind":"constructor","lang":"java","doc":"Create a primitive containing a {@link Number}. @param number the value to create the primitive with.","code":"@SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonPrimitive(Number number) {\n value = Objects.requireNonNull(number);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":67,"symbol":"JsonPrimitive","kind":"constructor","lang":"java","doc":"Create a primitive containing a String value. @param string the value to create the primitive with.","code":"@SuppressWarnings(\"deprecation\") // superclass constructor\n public JsonPrimitive(String string) {\n value = Objects.requireNonNull(string);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":81,"symbol":"JsonPrimitive","kind":"constructor","lang":"java","doc":"@param c the value to create the primitive with. \"deprecation\" suppression for superclass constructor \"UnnecessaryBoxedVariable\" Error Prone warning is correct since method does not accept null, but cannot be changed anymore since this is public API","code":"@SuppressWarnings({\"deprecation\", \"UnnecessaryBoxedVariable\"})\n public JsonPrimitive(Character c) {\n // convert characters to strings since in JSON, characters are represented as a single\n // character string\n value = Objects.requireNonNull(c).toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":93,"symbol":"deepCopy","kind":"method","lang":"java","doc":"Returns the same value as primitives are immutable. @since 2.8.2","code":"@Override\n public JsonPrimitive deepCopy() {\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":103,"symbol":"isBoolean","kind":"method","lang":"java","doc":"Check whether this primitive contains a boolean value. @return true if this primitive contains a boolean value, false otherwise.","code":"public boolean isBoolean() {\n return value instanceof Boolean;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":113,"symbol":"getAsBoolean","kind":"method","lang":"java","doc":"Convenience method to get this element as a boolean value. If this primitive {@linkplain #isBoolean() is not a boolean}, the string value is parsed using {@link Boolean#parseBoolean(String)}. This means {@code \"true\"} (ignoring case) is considered {@code true} and any other value is considered {@code false}.","code":"@Override\n public boolean getAsBoolean() {\n if (isBoolean()) {\n return (Boolean) value;\n }\n // Check to see if the value as a String is \"true\" in any case.\n return Boolean.parseBoolean(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":127,"symbol":"isNumber","kind":"method","lang":"java","doc":"Check whether this primitive contains a Number. @return true if this primitive contains a Number, false otherwise.","code":"public boolean isNumber() {\n return value instanceof Number;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":138,"symbol":"getAsNumber","kind":"method","lang":"java","doc":"Convenience method to get this element as a {@link Number}. If this primitive {@linkplain #isString() is a string}, a lazily parsed {@code Number} is constructed which parses the string when any of its methods are called (which can lead to a {@link NumberFormatException}). @throws UnsupportedOperationException if this primitive is neither a number nor a string.","code":"@Override\n public Number getAsNumber() {\n if (value instanceof Number) {\n return (Number) value;\n } else if (value instanceof String) {\n return new LazilyParsedNumber((String) value);\n }\n throw new UnsupportedOperationException(\"Primitive is neither a number nor a string\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":153,"symbol":"isString","kind":"method","lang":"java","doc":"Check whether this primitive contains a String value. @return true if this primitive contains a String value, false otherwise.","code":"public boolean isString() {\n return value instanceof String;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":158,"symbol":"getAsString","kind":"method","lang":"java","doc":"Don't add Javadoc, inherit it from super implementation; no exceptions are thrown here","code":"@Override\n public String getAsString() {\n if (value instanceof String) {\n return (String) value;\n } else if (isNumber()) {\n return getAsNumber().toString();\n } else if (isBoolean()) {\n return ((Boolean) value).toString();\n }\n throw new AssertionError(\"Unexpected value type: \" + value.getClass());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":173,"symbol":"getAsDouble","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public double getAsDouble() {\n return isNumber() ? getAsNumber().doubleValue() : Double.parseDouble(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":181,"symbol":"getAsBigDecimal","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public BigDecimal getAsBigDecimal() {\n return value instanceof BigDecimal\n ? (BigDecimal) value\n : NumberLimits.parseBigDecimal(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":191,"symbol":"getAsBigInteger","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public BigInteger getAsBigInteger() {\n return value instanceof BigInteger\n ? (BigInteger) value\n : isIntegral(this)\n ? BigInteger.valueOf(this.getAsNumber().longValue())\n : NumberLimits.parseBigInteger(this.getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":203,"symbol":"getAsFloat","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public float getAsFloat() {\n return isNumber() ? getAsNumber().floatValue() : Float.parseFloat(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":214,"symbol":"getAsLong","kind":"method","lang":"java","doc":"Convenience method to get this element as a primitive long. @return this element as a primitive long. @throws NumberFormatException {@inheritDoc}","code":"@Override\n public long getAsLong() {\n return isNumber() ? getAsNumber().longValue() : Long.parseLong(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":222,"symbol":"getAsShort","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public short getAsShort() {\n return isNumber() ? getAsNumber().shortValue() : Short.parseShort(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":230,"symbol":"getAsInt","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public int getAsInt() {\n return isNumber() ? getAsNumber().intValue() : Integer.parseInt(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":238,"symbol":"getAsByte","kind":"method","lang":"java","doc":"@throws NumberFormatException {@inheritDoc}","code":"@Override\n public byte getAsByte() {\n return isNumber() ? getAsNumber().byteValue() : Byte.parseByte(getAsString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":248,"symbol":"getAsCharacter","kind":"method","lang":"java","doc":"@throws UnsupportedOperationException if the string value of this primitive is empty. @deprecated This method is misleading, as it does not get this element as a char but rather as a string's first character.","code":"@Deprecated\n @Override\n public char getAsCharacter() {\n String s = getAsString();\n if (s.isEmpty()) {\n throw new UnsupportedOperationException(\"String value is empty\");\n } else {\n return s.charAt(0);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":260,"symbol":"hashCode","kind":"method","lang":"java","doc":"Returns the hash code of this object.","code":"@Override\n public int hashCode() {\n if (value == null) {\n return 31;\n }\n // The conditions below parallel the structure of equals(Object). Unlike in equals, every\n // numeric branch must delegate to the same double-based hash: equals can consider primitives\n // from *different* branches equal (for example Integer 42 equals Double 42.0 and a lazily\n // parsed number 42 through the floating-point comparison), so a branch hashing anything other\n // than the double value would give equal primitives different hash codes, see\n // https://github.com/google/gson/issues/992\n if (isIntegral(this)) {\n // equals compares two integral primitives by their BigInteger values or long values;\n // primitives equal under either comparison also have the same double value, so the\n // double-based hash is consistent with this branch of equals. It is also consistent with\n // the mixed comparisons handled below, such as Integer 42 vs Double 42.0.\n return hashOfDoubleValue(getAsNumber().doubleValue());\n }\n if (value instanceof Number) {\n // equals compares the remaining numbers by their double values. (For two BigDecimals it\n // uses "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":297,"symbol":"hashOfDoubleValue","kind":"method","lang":"java","doc":"recommended by Effective Java for longs; this keeps the hash code unchanged for the common integral types and also normalizes {@code -0.0} to {@code 0.0} (which {@code equals} considers equal to {@code 0}). All other values hash their {@link Double#doubleToLongBits} bits, which collapses all NaN bit patterns to a single canonical value, matching {@code equals} which considers all NaN values equal.","code":"private static int hashOfDoubleValue(double doubleValue) {\n long longValue = (long) doubleValue;\n return (doubleValue == longValue) ? Long.hashCode(longValue) : Double.hashCode(doubleValue);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":306,"symbol":"equals","kind":"method","lang":"java","doc":"Returns whether the other object is equal to this. This method only considers the other object to be equal if it is an instance of {@code JsonPrimitive} and has an equal value.","code":"@Override\n public boolean equals(Object obj) {\n if (this == obj) {\n return true;\n }\n if (obj == null || getClass() != obj.getClass()) {\n return false;\n }\n JsonPrimitive other = (JsonPrimitive) obj;\n if (value == null) {\n return other.value == null;\n }\n if (isIntegral(this) && isIntegral(other)) {\n return (this.value instanceof BigInteger || other.value instanceof BigInteger)\n ? this.getAsBigInteger().equals(other.getAsBigInteger())\n : this.getAsNumber().longValue() == other.getAsNumber().longValue();\n }\n if (value instanceof Number && other.value instanceof Number) {\n if (value instanceof BigDecimal && other.value instanceof BigDecimal) {\n // Uses compareTo to ignore scale of values, e.g. `0` and `0.00` should be considered equal\n return this.getAsBigDecimal().compareTo(other.getAsBigDecimal()) == 0;\n }\n\n double thisAsDouble = this.getAsDouble();\n double otherAsDouble = other.getAsDouble();\n // Don't use Double.compare(double, double) because that considers -0.0 and +0.0 not equal\n return (thisAsDouble == otherAsDouble)\n || (Double.isNaN(thisAsDouble) && Double."} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonPrimitive.java","line":342,"symbol":"isIntegral","kind":"method","lang":"java","doc":"Returns true if the specified number is an integral type (Long, Integer, Short, Byte, BigInteger)","code":"private static boolean isIntegral(JsonPrimitive primitive) {\n if (primitive.value instanceof Number) {\n Number number = (Number) primitive.value;\n return number instanceof BigInteger\n || number instanceof Long\n || number instanceof Integer\n || number instanceof Short\n || number instanceof Byte;\n }\n return false;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSerializationContext.java","line":28,"symbol":"JsonSerializationContext","kind":"interface","lang":"java","doc":"Context for serialization that is passed to a custom serializer during invocation of its {@link JsonSerializer#serialize(Object, Type, JsonSerializationContext)} method. @author Inderjeet Singh @author Joel Leitch","code":"public interface JsonSerializationContext {\n\n /**\n * Invokes default serialization on the specified object.\n *\n * @param src the object that needs to be serialized.\n * @return a tree of {@link JsonElement}s corresponding to the serialized form of {@code src}.\n */\n JsonElement serialize(Object src);\n\n /**\n * Invokes default serialization on the specified object passing the specific type information. It\n * should never be invoked on the element received as a parameter of the {@link\n * JsonSerializer#serialize(Object, Type, JsonSerializationContext)} method. Doing so will result\n * in an infinite loop since Gson will in-turn call the custom serializer again.\n *\n * @param src the object that needs to be serialized.\n * @param typeOfSrc the actual genericized type of src object.\n * @return a tree of {@link JsonElement}s corresponding to the serialized form of {@code src}.\n */\n JsonElement serialize(Object src, Type typeOfSrc);\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSerializationContext.java","line":36,"symbol":"serialize","kind":"method","lang":"java","doc":"Invokes default serialization on the specified object. @param src the object that needs to be serialized. @return a tree of {@link JsonElement}s corresponding to the serialized form of {@code src}.","code":"JsonElement serialize(Object src);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSerializationContext.java","line":48,"symbol":"serialize","kind":"method","lang":"java","doc":"in an infinite loop since Gson will in-turn call the custom serializer again. @param src the object that needs to be serialized. @param typeOfSrc the actual genericized type of src object. @return a tree of {@link JsonElement}s corresponding to the serialized form of {@code src}.","code":"JsonElement serialize(Object src, Type typeOfSrc);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSerializer.java","line":75,"symbol":"JsonSerializer","kind":"interface","lang":"java","doc":"@author Inderjeet Singh @author Joel Leitch @param type for which the serializer is being registered. It is possible that a serializer may be asked to serialize a specific generic type of the T. @see GsonBuilder#registerTypeAdapter(Type, Object)","code":"public interface JsonSerializer {\n\n /**\n * Gson invokes this call-back method during serialization when it encounters a field of the\n * specified type.\n *\n *

    In the implementation of this call-back method, you should consider invoking {@link\n * JsonSerializationContext#serialize(Object, Type)} method to create JsonElements for any\n * non-trivial field of the {@code src} object. However, you should never invoke it on the {@code\n * src} object itself since that will cause an infinite loop (Gson will call your call-back method\n * again).\n *\n * @param src the object that needs to be converted to JSON.\n * @param typeOfSrc the actual type (fully genericized version) of the source object.\n * @return a JsonElement corresponding to the specified object.\n */\n JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context);\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSerializer.java","line":91,"symbol":"serialize","kind":"method","lang":"java","doc":"again). @param src the object that needs to be converted to JSON. @param typeOfSrc the actual type (fully genericized version) of the source object. @return a JsonElement corresponding to the specified object.","code":"JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonStreamParser.java","line":51,"symbol":"JsonStreamParser","kind":"class","lang":"java","doc":" @author Inderjeet Singh @author Joel Leitch @since 1.4","code":"public final class JsonStreamParser implements Iterator {\n private final JsonReader parser;\n private final Object lock;\n\n /**\n * @param json The string containing JSON elements concatenated to each other.\n * @since 1.4\n */\n public JsonStreamParser(String json) {\n this(new StringReader(json));\n }\n\n /**\n * @param reader The data stream containing JSON elements concatenated to each other.\n * @since 1.4\n */\n public JsonStreamParser(Reader reader) {\n parser = new JsonReader(reader);\n parser.setStrictness(Strictness.LENIENT);\n lock = new Object();\n }\n\n /**\n * Returns the next available {@link JsonElement} on the reader. Throws a {@link\n * NoSuchElementException} if no element is available.\n *\n * @return the next available {@code JsonElement} on the reader.\n * @throws JsonParseException if the incoming stream is malformed JSON.\n * @throws NoSuchElementException if no {@code JsonElement} is available.\n * @since 1.4\n */\n @Override\n public JsonElement next() throws JsonParseException {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n\n try {\n return Streams.parse(parser);\n } catch (StackOverflowEr"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonStreamParser.java","line":59,"symbol":"JsonStreamParser","kind":"constructor","lang":"java","doc":"@param json The string containing JSON elements concatenated to each other. @since 1.4","code":"public JsonStreamParser(String json) {\n this(new StringReader(json));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonStreamParser.java","line":67,"symbol":"JsonStreamParser","kind":"constructor","lang":"java","doc":"@param reader The data stream containing JSON elements concatenated to each other. @since 1.4","code":"public JsonStreamParser(Reader reader) {\n parser = new JsonReader(reader);\n parser.setStrictness(Strictness.LENIENT);\n lock = new Object();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonStreamParser.java","line":82,"symbol":"next","kind":"method","lang":"java","doc":"@return the next available {@code JsonElement} on the reader. @throws JsonParseException if the incoming stream is malformed JSON. @throws NoSuchElementException if no {@code JsonElement} is available. @since 1.4","code":"@Override\n public JsonElement next() throws JsonParseException {\n if (!hasNext()) {\n throw new NoSuchElementException();\n }\n\n try {\n return Streams.parse(parser);\n } catch (StackOverflowError | OutOfMemoryError e) {\n throw new JsonParseException(\"Failed parsing JSON source to Json\", e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonStreamParser.java","line":102,"symbol":"hasNext","kind":"method","lang":"java","doc":"Returns true if a {@link JsonElement} is available on the input for consumption @return true if a {@link JsonElement} is available on the input, false otherwise @throws JsonParseException if the incoming stream is malformed JSON. @since 1.4","code":"@Override\n public boolean hasNext() {\n synchronized (lock) {\n try {\n return parser.peek() != JsonToken.END_DOCUMENT;\n } catch (MalformedJsonException e) {\n throw new JsonSyntaxException(e);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonStreamParser.java","line":121,"symbol":"remove","kind":"method","lang":"java","doc":"This optional {@link Iterator} method is not relevant for stream parsing and hence is not implemented. @since 1.4","code":"@Override\n public void remove() {\n throw new UnsupportedOperationException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSyntaxException.java","line":24,"symbol":"JsonSyntaxException","kind":"class","lang":"java","doc":"This exception is raised when Gson attempts to read (or write) a malformed JSON element. @author Inderjeet Singh @author Joel Leitch","code":"public final class JsonSyntaxException extends JsonParseException {\n\n private static final long serialVersionUID = 1L;\n\n public JsonSyntaxException(String msg) {\n super(msg);\n }\n\n public JsonSyntaxException(String msg, Throwable cause) {\n super(msg, cause);\n }\n\n /**\n * Creates exception with the specified cause. Consider using {@link #JsonSyntaxException(String,\n * Throwable)} instead if you can describe what actually happened.\n *\n * @param cause root exception that caused this exception to be thrown.\n */\n public JsonSyntaxException(Throwable cause) {\n super(cause);\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSyntaxException.java","line":28,"symbol":"JsonSyntaxException","kind":"constructor","lang":"java","code":"public JsonSyntaxException(String msg) {\n super(msg);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSyntaxException.java","line":32,"symbol":"JsonSyntaxException","kind":"constructor","lang":"java","code":"public JsonSyntaxException(String msg, Throwable cause) {\n super(msg, cause);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/JsonSyntaxException.java","line":42,"symbol":"JsonSyntaxException","kind":"constructor","lang":"java","doc":"Creates exception with the specified cause. Consider using {@link #JsonSyntaxException(String, Throwable)} instead if you can describe what actually happened. @param cause root exception that caused this exception to be thrown.","code":"public JsonSyntaxException(Throwable cause) {\n super(cause);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":29,"symbol":"LongSerializationPolicy","kind":"type","lang":"java","doc":"@see GsonBuilder#setLongSerializationPolicy(LongSerializationPolicy) @since 1.3 @author Inderjeet Singh @author Joel Leitch","code":"public enum LongSerializationPolicy {\n /**\n * This is the \"default\" serialization policy that will output a {@code Long} object as a JSON\n * number. For example, assume an object has a long field named \"f\" then the serialized output\n * would be: {@code {\"f\":123}}\n *\n *

    A {@code null} value is serialized as {@link JsonNull}.\n */\n DEFAULT() {\n @Override\n public JsonElement serialize(Long value) {\n if (value == null) {\n return JsonNull.INSTANCE;\n }\n return new JsonPrimitive(value);\n }\n\n @Override\n TypeAdapter typeAdapter() {\n return TypeAdapters.LONG;\n }\n },\n\n /**\n * Serializes a long value as a quoted string. For example, assume an object has a long field\n * named \"f\" then the serialized output would be: {@code {\"f\":\"123\"}}\n *\n *

    A {@code null} value is serialized as {@link JsonNull}.\n */\n STRING() {\n @Override\n public JsonElement serialize(Long value) {\n if (value == null) {\n return JsonNull.INSTANCE;\n }\n return new JsonPrimitive(value.toString());\n }\n\n @Override\n TypeAdapter typeAdapter() {\n return TypeAdapters.LONG_AS_STRING;\n }\n };\n\n /**\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":38,"symbol":"serialize","kind":"method","lang":"java","code":"@Override\n public JsonElement serialize(Long value) {\n if (value == null) {\n return JsonNull.INSTANCE;\n }\n return new JsonPrimitive(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":46,"symbol":"typeAdapter","kind":"method","lang":"java","code":"@Override\n TypeAdapter typeAdapter() {\n return TypeAdapters.LONG;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":59,"symbol":"serialize","kind":"method","lang":"java","code":"@Override\n public JsonElement serialize(Long value) {\n if (value == null) {\n return JsonNull.INSTANCE;\n }\n return new JsonPrimitive(value.toString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":67,"symbol":"typeAdapter","kind":"method","lang":"java","code":"@Override\n TypeAdapter typeAdapter() {\n return TypeAdapters.LONG_AS_STRING;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":79,"symbol":"serialize","kind":"method","lang":"java","doc":"Serialize this {@code value} using this serialization policy. @param value the long value to be serialized into a {@link JsonElement} @return the serialized version of {@code value}","code":"public abstract JsonElement serialize(Long value);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/LongSerializationPolicy.java","line":83,"symbol":"typeAdapter","kind":"method","lang":"java","doc":"Returns the corresponding {@link TypeAdapter} for this serialization policy. Internal method","code":"abstract TypeAdapter typeAdapter();"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":45,"symbol":"ReflectionAccessFilter","kind":"interface","lang":"java","doc":"difference that a filter will cause an exception to be thrown when access is disallowed while an exclusion strategy just skips fields and classes. @see GsonBuilder#addReflectionAccessFilter(ReflectionAccessFilter) @since 2.9.1","code":"public interface ReflectionAccessFilter {\n /**\n * Result of a filter check.\n *\n * @since 2.9.1\n */\n enum FilterResult {\n /**\n * Reflection access for the class is allowed.\n *\n *

    Note that this does not affect the Java access checks in any way, it only permits Gson to\n * try using reflection for a class. The Java runtime might still deny such access.\n */\n ALLOW,\n /**\n * The filter is indecisive whether reflection access should be allowed. The next registered\n * filter will be consulted to get the result. If there is no next filter, this result acts like\n * {@link #ALLOW}.\n */\n INDECISIVE,\n /**\n * Blocks reflection access if a member of the class is not accessible by default and would have\n * to be made accessible. This is unaffected by any {@code java} command line arguments being\n * used to make packages accessible, or by module declaration directives which open the\n * complete module or certain packages for reflection and will consider such packages\n * inaccessible.\n *\n *

    Note that this only works for Java 9 and higher, for older Java versions its\n * functionality will "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":51,"symbol":"FilterResult","kind":"type","lang":"java","doc":"Result of a filter check. @since 2.9.1","code":"enum FilterResult {\n /**\n * Reflection access for the class is allowed.\n *\n *

    Note that this does not affect the Java access checks in any way, it only permits Gson to\n * try using reflection for a class. The Java runtime might still deny such access.\n */\n ALLOW,\n /**\n * The filter is indecisive whether reflection access should be allowed. The next registered\n * filter will be consulted to get the result. If there is no next filter, this result acts like\n * {@link #ALLOW}.\n */\n INDECISIVE,\n /**\n * Blocks reflection access if a member of the class is not accessible by default and would have\n * to be made accessible. This is unaffected by any {@code java} command line arguments being\n * used to make packages accessible, or by module declaration directives which open the\n * complete module or certain packages for reflection and will consider such packages\n * inaccessible.\n *\n *

    Note that this only works for Java 9 and higher, for older Java versions its\n * functionality will be limited and it might behave like {@link #ALLOW}. Access checks are only\n * performed as defined by the "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":114,"symbol":"check","kind":"method","lang":"java","code":"@Override\n public FilterResult check(Class rawClass) {\n return ReflectionAccessFilterHelper.isJavaType(rawClass)\n ? FilterResult.BLOCK_INACCESSIBLE\n : FilterResult.INDECISIVE;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":121,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"ReflectionAccessFilter#BLOCK_INACCESSIBLE_JAVA\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":145,"symbol":"check","kind":"method","lang":"java","code":"@Override\n public FilterResult check(Class rawClass) {\n return ReflectionAccessFilterHelper.isJavaType(rawClass)\n ? FilterResult.BLOCK_ALL\n : FilterResult.INDECISIVE;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":152,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"ReflectionAccessFilter#BLOCK_ALL_JAVA\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":176,"symbol":"check","kind":"method","lang":"java","code":"@Override\n public FilterResult check(Class rawClass) {\n return ReflectionAccessFilterHelper.isAndroidType(rawClass)\n ? FilterResult.BLOCK_ALL\n : FilterResult.INDECISIVE;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":183,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"ReflectionAccessFilter#BLOCK_ALL_ANDROID\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":208,"symbol":"check","kind":"method","lang":"java","code":"@Override\n public FilterResult check(Class rawClass) {\n return ReflectionAccessFilterHelper.isAnyPlatformType(rawClass)\n ? FilterResult.BLOCK_ALL\n : FilterResult.INDECISIVE;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":215,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"ReflectionAccessFilter#BLOCK_ALL_PLATFORM\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ReflectionAccessFilter.java","line":227,"symbol":"check","kind":"method","lang":"java","doc":"Checks if reflection access should be allowed for a class. @param rawClass Class to check @return Result indicating whether reflection access is allowed","code":"FilterResult check(Class rawClass);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/Strictness.java","line":20,"symbol":"Strictness","kind":"type","lang":"java","doc":"@see GsonBuilder#setStrictness(Strictness) @see JsonReader#setStrictness(Strictness) @see JsonWriter#setStrictness(Strictness) @since 2.11.0","code":"public enum Strictness {\n /** Allow large deviations from the JSON specification. */\n LENIENT,\n\n /** Allow certain small deviations from the JSON specification for legacy reasons. */\n LEGACY_STRICT,\n\n /** Strict compliance with the JSON specification. */\n STRICT\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberPolicy.java","line":36,"symbol":"ToNumberPolicy","kind":"type","lang":"java","doc":"@see ToNumberStrategy @see GsonBuilder#setObjectToNumberStrategy(ToNumberStrategy) @see GsonBuilder#setNumberToNumberStrategy(ToNumberStrategy) @since 2.8.9","code":"public enum ToNumberPolicy implements ToNumberStrategy {\n\n /**\n * Using this policy will ensure that numbers will be read as {@link Double} values. This is the\n * default strategy used during deserialization of numbers as {@link Object}.\n */\n DOUBLE {\n @Override\n public Double readNumber(JsonReader in) throws IOException {\n return in.nextDouble();\n }\n },\n\n /**\n * Using this policy will ensure that numbers will be read as a lazily parsed number backed by a\n * string. This is the default strategy used during deserialization of numbers as {@link Number}.\n */\n LAZILY_PARSED_NUMBER {\n @Override\n public Number readNumber(JsonReader in) throws IOException {\n return new LazilyParsedNumber(in.nextString());\n }\n },\n\n /**\n * Using this policy will ensure that numbers will be read as {@link Long} or {@link Double}\n * values depending on how JSON numbers are represented: {@code Long} if the JSON number can be\n * parsed as a {@code Long} value, or otherwise {@code Double} if it can be parsed as a {@code\n * Double} value. If the parsed double-precision number results in a positive or negative infinity\n * ({@link Double#isInfinite()}) or a N"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberPolicy.java","line":43,"symbol":"readNumber","kind":"method","lang":"java","code":"@Override\n public Double readNumber(JsonReader in) throws IOException {\n return in.nextDouble();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberPolicy.java","line":54,"symbol":"readNumber","kind":"method","lang":"java","code":"@Override\n public Number readNumber(JsonReader in) throws IOException {\n return new LazilyParsedNumber(in.nextString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberPolicy.java","line":70,"symbol":"readNumber","kind":"method","lang":"java","code":"@Override\n public Number readNumber(JsonReader in) throws IOException, JsonParseException {\n String value = in.nextString();\n if (value.indexOf('.') >= 0) {\n return parseAsDouble(value, in);\n } else {\n try {\n return Long.parseLong(value);\n } catch (NumberFormatException e) {\n return parseAsDouble(value, in);\n }\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberPolicy.java","line":84,"symbol":"parseAsDouble","kind":"method","lang":"java","code":"private Number parseAsDouble(String value, JsonReader in) throws IOException {\n try {\n Double d = Double.valueOf(value);\n if ((d.isInfinite() || d.isNaN()) && !in.isLenient()) {\n throw new MalformedJsonException(\n \"JSON forbids NaN and infinities: \" + d + \"; at path \" + in.getPreviousPath());\n }\n return d;\n } catch (NumberFormatException e) {\n throw new JsonParseException(\n \"Cannot parse \" + value + \"; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberPolicy.java","line":104,"symbol":"readNumber","kind":"method","lang":"java","code":"@Override\n public BigDecimal readNumber(JsonReader in) throws IOException {\n String value = in.nextString();\n try {\n return NumberLimits.parseBigDecimal(value);\n } catch (NumberFormatException e) {\n throw new JsonParseException(\n \"Cannot parse \" + value + \"; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberStrategy.java","line":60,"symbol":"ToNumberStrategy","kind":"interface","lang":"java","doc":"@see ToNumberPolicy @see GsonBuilder#setObjectToNumberStrategy(ToNumberStrategy) @see GsonBuilder#setNumberToNumberStrategy(ToNumberStrategy) @since 2.8.9","code":"public interface ToNumberStrategy {\n\n /**\n * Reads a number from the given JSON reader. A strategy is supposed to read a single value from\n * the reader, and the read value is guaranteed never to be {@code null}.\n *\n * @param in JSON reader to read a number from\n * @return number read from the JSON reader.\n */\n Number readNumber(JsonReader in) throws IOException;\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/ToNumberStrategy.java","line":69,"symbol":"readNumber","kind":"method","lang":"java","doc":"Reads a number from the given JSON reader. A strategy is supposed to read a single value from the reader, and the read value is guaranteed never to be {@code null}. @param in JSON reader to read a number from @return number read from the JSON reader.","code":"Number readNumber(JsonReader in) throws IOException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":122,"symbol":"TypeAdapter","kind":"class","lang":"java","doc":"}

    Type adapters are type-specific. For example, a {@code TypeAdapter} can convert {@code Date} instances to JSON and JSON to instances of {@code Date}, but cannot convert any other types.","code":"public abstract class TypeAdapter {\n\n public TypeAdapter() {}\n\n /**\n * Writes one JSON value (an array, object, string, number, boolean or null) for {@code value}.\n *\n * @param value the Java object to write. May be null.\n */\n public abstract void write(JsonWriter out, T value) throws IOException;\n\n /**\n * Converts {@code value} to a JSON document and writes it to {@code out}.\n *\n *

    A {@link JsonWriter} with default configuration is used for writing the JSON data. To\n * customize this behavior, create a {@link JsonWriter}, configure it and then use {@link\n * #write(JsonWriter, Object)} instead.\n *\n * @param value the Java object to convert. May be {@code null}.\n * @since 2.2\n */\n public final void toJson(Writer out, T value) throws IOException {\n JsonWriter writer = new JsonWriter(out);\n write(writer, value);\n }\n\n /**\n * Converts {@code value} to a JSON document.\n *\n *

    A {@link JsonWriter} with default configuration is used for writing the JSON data. To\n * customize this behavior, create a {@link JsonWriter}, configure it and then use {@link\n * #write(JsonWriter, Object)} instead.\n *\n * @throws JsonIOException wrapping {"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":124,"symbol":"TypeAdapter","kind":"constructor","lang":"java","code":"public TypeAdapter() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":131,"symbol":"write","kind":"method","lang":"java","doc":"Writes one JSON value (an array, object, string, number, boolean or null) for {@code value}. @param value the Java object to write. May be null.","code":"public abstract void write(JsonWriter out, T value) throws IOException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":143,"symbol":"toJson","kind":"method","lang":"java","doc":"customize this behavior, create a {@link JsonWriter}, configure it and then use {@link #write(JsonWriter, Object)} instead. @param value the Java object to convert. May be {@code null}. @since 2.2","code":"public final void toJson(Writer out, T value) throws IOException {\n JsonWriter writer = new JsonWriter(out);\n write(writer, value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":160,"symbol":"toJson","kind":"method","lang":"java","doc":"@throws JsonIOException wrapping {@code IOException}s thrown by {@link #write(JsonWriter, Object)} @param value the Java object to convert. May be {@code null}. @since 2.2","code":"public final String toJson(T value) {\n StringBuilder stringBuilder = new StringBuilder();\n try {\n toJson(Streams.writerForAppendable(stringBuilder), value);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n return stringBuilder.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":179,"symbol":"toJsonTree","kind":"method","lang":"java","doc":"@param value the Java object to convert. May be {@code null}. @return the converted JSON tree. May be {@link JsonNull}. @throws JsonIOException wrapping {@code IOException}s thrown by {@link #write(JsonWriter, Object)} @since 2.2","code":"public final JsonElement toJsonTree(T value) {\n try {\n JsonTreeWriter jsonWriter = new JsonTreeWriter();\n write(jsonWriter, value);\n return jsonWriter.get();\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":195,"symbol":"read","kind":"method","lang":"java","doc":"Reads one JSON value (an array, object, string, number, boolean or null) and converts it to a Java object. Returns the converted object. @return the converted Java object. May be {@code null}.","code":"public abstract T read(JsonReader in) throws IOException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":211,"symbol":"fromJson","kind":"method","lang":"java","doc":"

    No exception is thrown if the JSON data has multiple top-level JSON elements, or if there is trailing data. @return the converted Java object. May be {@code null}. @since 2.2","code":"public final T fromJson(Reader in) throws IOException {\n JsonReader reader = new JsonReader(in);\n return read(reader);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":230,"symbol":"fromJson","kind":"method","lang":"java","doc":"

    No exception is thrown if the JSON data has multiple top-level JSON elements, or if there is trailing data. @return the converted Java object. May be {@code null}. @since 2.2","code":"public final T fromJson(String json) throws IOException {\n return fromJson(new StringReader(json));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":242,"symbol":"fromJsonTree","kind":"method","lang":"java","doc":"@param jsonTree the JSON element to convert. May be {@link JsonNull}. @return the converted Java object. May be {@code null}. @throws JsonIOException wrapping {@code IOException}s thrown by {@link #read(JsonReader)} @since 2.2","code":"public final T fromJsonTree(JsonElement jsonTree) {\n try {\n JsonReader jsonReader = new JsonTreeReader(jsonTree);\n return read(jsonReader);\n } catch (IOException e) {\n throw new JsonIOException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":292,"symbol":"nullSafe","kind":"method","lang":"java","doc":"} }.nullSafe()).create(); } Note that we didn't need to check for nulls in our type adapter after we used nullSafe.","code":"public final TypeAdapter nullSafe() {\n if (!(this instanceof TypeAdapter.NullSafeTypeAdapter)) {\n return new NullSafeTypeAdapter();\n }\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":299,"symbol":"NullSafeTypeAdapter","kind":"class","lang":"java","code":"private final class NullSafeTypeAdapter extends TypeAdapter {\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n if (value == null) {\n out.nullValue();\n } else {\n TypeAdapter.this.write(out, value);\n }\n }\n\n @Override\n public T read(JsonReader reader) throws IOException {\n if (reader.peek() == JsonToken.NULL) {\n reader.nextNull();\n return null;\n }\n return TypeAdapter.this.read(reader);\n }\n\n @Override\n public String toString() {\n return \"NullSafeTypeAdapter[\" + TypeAdapter.this + \"]\";\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":300,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n if (value == null) {\n out.nullValue();\n } else {\n TypeAdapter.this.write(out, value);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":309,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader reader) throws IOException {\n if (reader.peek() == JsonToken.NULL) {\n reader.nextNull();\n return null;\n }\n return TypeAdapter.this.read(reader);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapter.java","line":318,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"NullSafeTypeAdapter[\" + TypeAdapter.this + \"]\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapterFactory.java","line":165,"symbol":"TypeAdapterFactory","kind":"interface","lang":"java","doc":"delegate type adapter in the {@code create()} method; this ensures potentially-expensive type adapter creation happens only once. @see GsonBuilder#registerTypeAdapterFactory(TypeAdapterFactory) @since 2.1","code":"public interface TypeAdapterFactory {\n\n /**\n * Returns a type adapter for {@code type}, or null if this factory doesn't support {@code type}.\n */\n TypeAdapter create(Gson gson, TypeToken type);\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/TypeAdapterFactory.java","line":170,"symbol":"create","kind":"method","lang":"java","doc":"Returns a type adapter for {@code type}, or null if this factory doesn't support {@code type}.","code":" TypeAdapter create(Gson gson, TypeToken type);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":45,"symbol":"ConstructorConstructor","kind":"class","lang":"java","doc":"Returns a function that can construct an instance of a requested type.","code":"public final class ConstructorConstructor {\n private final Map> instanceCreators;\n private final boolean useJdkUnsafe;\n private final List reflectionFilters;\n\n public ConstructorConstructor(\n Map> instanceCreators,\n boolean useJdkUnsafe,\n List reflectionFilters) {\n this.instanceCreators = instanceCreators;\n this.useJdkUnsafe = useJdkUnsafe;\n this.reflectionFilters = reflectionFilters;\n }\n\n /**\n * Check if the class can be instantiated by Unsafe allocator. If the instance has interface or\n * abstract modifiers return an exception message.\n *\n * @param c instance of the class to be checked\n * @return if instantiable {@code null}, else a non-{@code null} exception message\n */\n static String checkInstantiable(Class c) {\n int modifiers = c.getModifiers();\n if (Modifier.isInterface(modifiers)) {\n return \"Interfaces can't be instantiated! Register an InstanceCreator\"\n + \" or a TypeAdapter for this type. Interface name: \"\n + c.getName();\n }\n if (Modifier.isAbstract(modifiers)) {\n // R8 performs aggressive opt"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":50,"symbol":"ConstructorConstructor","kind":"constructor","lang":"java","code":"public ConstructorConstructor(\n Map> instanceCreators,\n boolean useJdkUnsafe,\n List reflectionFilters) {\n this.instanceCreators = instanceCreators;\n this.useJdkUnsafe = useJdkUnsafe;\n this.reflectionFilters = reflectionFilters;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":66,"symbol":"checkInstantiable","kind":"method","lang":"java","doc":"Check if the class can be instantiated by Unsafe allocator. If the instance has interface or abstract modifiers return an exception message. @param c instance of the class to be checked @return if instantiable {@code null}, else a non-{@code null} exception message","code":"static String checkInstantiable(Class c) {\n int modifiers = c.getModifiers();\n if (Modifier.isInterface(modifiers)) {\n return \"Interfaces can't be instantiated! Register an InstanceCreator\"\n + \" or a TypeAdapter for this type. Interface name: \"\n + c.getName();\n }\n if (Modifier.isAbstract(modifiers)) {\n // R8 performs aggressive optimizations where it removes the default constructor of a class\n // and makes the class `abstract`; check for that here explicitly\n /*\n * Note: Ideally should only show this R8-specific message when it is clear that R8 was\n * used (e.g. when `c.getDeclaredConstructors().length == 0`), but on Android where this\n * issue with R8 occurs most, R8 seems to keep some constructors for some reason while\n * still making the class abstract\n */\n return \"Abstract classes can't be instantiated! Adjust the R8 configuration or register\"\n + \" an InstanceCreator or a TypeAdapter for this type. Class name: \"\n + c.getName()\n + \"\\nSee \"\n + TroubleshootingGuide.createUrl(\"r8-abstract-class\");\n }\n return null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":92,"symbol":"get","kind":"method","lang":"java","doc":"Calls {@link #get(TypeToken, boolean)}, and allows usage of JDK Unsafe.","code":"public ObjectConstructor get(TypeToken typeToken) {\n return get(typeToken, true);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":103,"symbol":"get","kind":"method","lang":"java","doc":"Retrieves an object constructor for the given type. @param typeToken type for which a constructor should be retrieved @param allowUnsafe whether to allow usage of JDK Unsafe; has no effect if {@link #useJdkUnsafe} is false","code":"public ObjectConstructor get(TypeToken typeToken, boolean allowUnsafe) {\n Type type = typeToken.getType();\n Class rawType = typeToken.getRawType();\n\n // first try an instance creator\n\n @SuppressWarnings(\"unchecked\") // types must agree\n InstanceCreator typeCreator = (InstanceCreator) instanceCreators.get(type);\n if (typeCreator != null) {\n return new InstanceCreatorConstructor<>(typeCreator, type);\n }\n\n // Next try raw type match for instance creators\n @SuppressWarnings(\"unchecked\") // types must agree\n InstanceCreator rawTypeCreator = (InstanceCreator) instanceCreators.get(rawType);\n if (rawTypeCreator != null) {\n return new InstanceCreatorConstructor<>(rawTypeCreator, type);\n }\n\n // First consider special constructors before checking for no-args constructors\n // below to avoid matching internal no-args constructors which might be added in\n // future JDK versions\n ObjectConstructor specialConstructor = newSpecialCollectionConstructor(type, rawType);\n if (specialConstructor != null) {\n return specialConstructor;\n }\n\n FilterResult filterResult =\n ReflectionAccessFilterH"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":177,"symbol":"newSpecialCollectionConstructor","kind":"method","lang":"java","doc":"Creates constructors for special JDK collection types which do not have a public no-args constructor.","code":"private static ObjectConstructor newSpecialCollectionConstructor(\n Type type, Class rawType) {\n if (EnumSet.class.isAssignableFrom(rawType)) {\n return () -> {\n if (type instanceof ParameterizedType) {\n Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];\n if (elementType instanceof Class) {\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n T set = (T) EnumSet.noneOf((Class) elementType);\n return set;\n } else {\n throw new JsonIOException(\"Invalid EnumSet type: \" + type);\n }\n } else {\n throw new JsonIOException(\"Invalid EnumSet type: \" + type);\n }\n };\n }\n // Only support creation of EnumMap, but not of custom subtypes; for them type parameters\n // and constructor parameter might have completely different meaning\n else if (rawType == EnumMap.class) {\n return () -> {\n if (type instanceof ParameterizedType) {\n Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];\n if (elementType instanceof Class) {\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":217,"symbol":"newDefaultConstructor","kind":"method","lang":"java","code":"private static ObjectConstructor newDefaultConstructor(\n Class rawType, FilterResult filterResult) {\n // Cannot invoke constructor of abstract class\n if (Modifier.isAbstract(rawType.getModifiers())) {\n return null;\n }\n\n Constructor constructor;\n try {\n constructor = rawType.getDeclaredConstructor();\n } catch (NoSuchMethodException e) {\n return null;\n }\n\n boolean canAccess =\n filterResult == FilterResult.ALLOW\n || (ReflectionAccessFilterHelper.canAccess(constructor, null)\n // Be a bit more lenient here for BLOCK_ALL; if constructor is accessible and public\n // then allow calling it\n && (filterResult != FilterResult.BLOCK_ALL\n || Modifier.isPublic(constructor.getModifiers())));\n\n if (!canAccess) {\n String message =\n \"Unable to invoke no-args constructor of \"\n + rawType\n + \";\"\n + \" constructor is not accessible and ReflectionAccessFilter does not permit making\"\n + \" it accessible. Register an InstanceCreator or a TypeAdapter for this type, change\"\n + \""} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":288,"symbol":"newDefaultImplementationConstructor","kind":"method","lang":"java","doc":"Constructors for common interface types like Map and List and their subtypes.","code":"private static ObjectConstructor newDefaultImplementationConstructor(\n Class rawType) {\n\n /*\n * IMPORTANT: Must only create instances for classes with public no-args constructor.\n * For classes with special constructors / factory methods (e.g. EnumSet)\n * `newSpecialCollectionConstructor` defined above must be used, to avoid no-args\n * constructor check (which is called before this method) detecting internal no-args\n * constructors which might be added in a future JDK version\n */\n\n if (Collection.class.isAssignableFrom(rawType)) {\n @SuppressWarnings(\"unchecked\")\n ObjectConstructor constructor = (ObjectConstructor) newCollectionConstructor(rawType);\n return constructor;\n }\n\n if (Map.class.isAssignableFrom(rawType)) {\n @SuppressWarnings(\"unchecked\")\n ObjectConstructor constructor = (ObjectConstructor) newMapConstructor(rawType);\n return constructor;\n }\n\n // Unsupported type; try other means of creating constructor\n return null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":315,"symbol":"newCollectionConstructor","kind":"method","lang":"java","code":"private static ObjectConstructor> newCollectionConstructor(\n Class rawType) {\n\n // First try List implementation\n if (rawType.isAssignableFrom(ArrayList.class)) {\n return ArrayList::new;\n }\n // Then try Set implementation\n else if (rawType.isAssignableFrom(LinkedHashSet.class)) {\n return LinkedHashSet::new;\n }\n // Then try SortedSet / NavigableSet implementation\n else if (rawType.isAssignableFrom(TreeSet.class)) {\n return TreeSet::new;\n }\n // Then try Queue implementation\n else if (rawType.isAssignableFrom(ArrayDeque.class)) {\n return ArrayDeque::new;\n }\n\n // Was unable to create matching Collection constructor\n return null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":339,"symbol":"newMapConstructor","kind":"method","lang":"java","code":"private static ObjectConstructor> newMapConstructor(Class rawType) {\n // First try Map implementation\n if (rawType.isAssignableFrom(LinkedHashMap.class)) {\n return LinkedHashMap::new;\n }\n // Then try SortedMap / NavigableMap implementation\n else if (rawType.isAssignableFrom(TreeMap.class)) {\n return TreeMap::new;\n }\n // Then try ConcurrentMap implementation\n else if (rawType.isAssignableFrom(ConcurrentHashMap.class)) {\n return ConcurrentHashMap::new;\n }\n // Then try ConcurrentNavigableMap implementation\n else if (rawType.isAssignableFrom(ConcurrentSkipListMap.class)) {\n return ConcurrentSkipListMap::new;\n }\n\n // Was unable to create matching Map constructor\n return null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":361,"symbol":"newUnsafeAllocator","kind":"method","lang":"java","code":"private ObjectConstructor newUnsafeAllocator(Class rawType) {\n if (useJdkUnsafe) {\n return () -> {\n try {\n @SuppressWarnings(\"unchecked\")\n T newInstance = (T) UnsafeAllocator.INSTANCE.newInstance(rawType);\n return newInstance;\n } catch (Exception e) {\n throw new RuntimeException(\n (\"Unable to create instance of \"\n + rawType\n + \". Registering an InstanceCreator or a TypeAdapter for this type, or adding a\"\n + \" no-args constructor may fix this problem.\"),\n e);\n }\n };\n } else {\n String exceptionMessage =\n \"Unable to create instance of \"\n + rawType\n + \"; usage of JDK Unsafe is disabled. Registering an InstanceCreator or a TypeAdapter\"\n + \" for this type, adding a no-args constructor, or enabling usage of JDK Unsafe may\"\n + \" fix this problem.\";\n\n // Check if R8 removed all constructors\n if (rawType.getDeclaredConstructors().length == 0) {\n // R8 with Unsafe disabled might not be common enough to warrant a separate Troubleshooting\n /"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":397,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return instanceCreators.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":411,"symbol":"ThrowingObjectConstructor","kind":"class","lang":"java","doc":"

    This keeps backward compatibility, compared to using a {@code null} {@code ObjectConstructor}, which would then choose another way of creating the object. And it supports types which are only serialized but not deserialized (compared to directly throwing an exception when the {@code ObjectConstructor} is requested), e.g. when the runtime type of an object is inaccessible, but the compile-time type is accessible.","code":"private static final class ThrowingObjectConstructor implements ObjectConstructor {\n private final String exceptionMessage;\n\n ThrowingObjectConstructor(String exceptionMessage) {\n this.exceptionMessage = exceptionMessage;\n }\n\n @Override\n public T construct() {\n // New exception is created every time to avoid keeping a reference to an exception with\n // potentially long stack trace, causing a memory leak\n // (which would happen if the exception was already created when the\n // `ThrowingObjectConstructor` is created)\n throw new JsonIOException(exceptionMessage);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":414,"symbol":"ThrowingObjectConstructor","kind":"constructor","lang":"java","code":"ThrowingObjectConstructor(String exceptionMessage) {\n this.exceptionMessage = exceptionMessage;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":418,"symbol":"construct","kind":"method","lang":"java","code":"@Override\n public T construct() {\n // New exception is created every time to avoid keeping a reference to an exception with\n // potentially long stack trace, causing a memory leak\n // (which would happen if the exception was already created when the\n // `ThrowingObjectConstructor` is created)\n throw new JsonIOException(exceptionMessage);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":428,"symbol":"InstanceCreatorConstructor","kind":"class","lang":"java","code":"private static final class InstanceCreatorConstructor implements ObjectConstructor {\n private final InstanceCreator instanceCreator;\n private final Type type;\n\n InstanceCreatorConstructor(InstanceCreator instanceCreator, Type type) {\n this.instanceCreator = instanceCreator;\n this.type = type;\n }\n\n @Override\n public T construct() {\n return instanceCreator.createInstance(type);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":432,"symbol":"InstanceCreatorConstructor","kind":"constructor","lang":"java","code":"InstanceCreatorConstructor(InstanceCreator instanceCreator, Type type) {\n this.instanceCreator = instanceCreator;\n this.type = type;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java","line":437,"symbol":"construct","kind":"method","lang":"java","code":"@Override\n public T construct() {\n return instanceCreator.createInstance(type);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":49,"symbol":"Excluder","kind":"class","lang":"java","doc":"

    This class is a type adapter factory; types that are excluded will be adapted to null. It may delegate to another type adapter if only one direction is excluded. @author Joel Leitch @author Jesse Wilson","code":"public final class Excluder implements TypeAdapterFactory, Cloneable {\n private static final double IGNORE_VERSIONS = -1.0d;\n public static final Excluder DEFAULT = new Excluder();\n\n private double version = IGNORE_VERSIONS;\n private int modifiers = Modifier.TRANSIENT | Modifier.STATIC;\n private boolean serializeInnerClasses = true;\n private boolean requireExpose;\n private List serializationStrategies = Collections.emptyList();\n private List deserializationStrategies = Collections.emptyList();\n\n @Override\n protected Excluder clone() {\n try {\n return (Excluder) super.clone();\n } catch (CloneNotSupportedException e) {\n throw new AssertionError(e);\n }\n }\n\n public Excluder withVersion(double ignoreVersionsAfter) {\n Excluder result = clone();\n result.version = ignoreVersionsAfter;\n return result;\n }\n\n public Excluder withModifiers(int... modifiers) {\n Excluder result = clone();\n result.modifiers = 0;\n for (int modifier : modifiers) {\n result.modifiers |= modifier;\n }\n return result;\n }\n\n public Excluder disableInnerClassSerialization() {\n Excluder result = clone();\n result.seriali"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":60,"symbol":"clone","kind":"method","lang":"java","code":"@Override\n protected Excluder clone() {\n try {\n return (Excluder) super.clone();\n } catch (CloneNotSupportedException e) {\n throw new AssertionError(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":69,"symbol":"withVersion","kind":"method","lang":"java","code":"public Excluder withVersion(double ignoreVersionsAfter) {\n Excluder result = clone();\n result.version = ignoreVersionsAfter;\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":75,"symbol":"withModifiers","kind":"method","lang":"java","code":"public Excluder withModifiers(int... modifiers) {\n Excluder result = clone();\n result.modifiers = 0;\n for (int modifier : modifiers) {\n result.modifiers |= modifier;\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":84,"symbol":"disableInnerClassSerialization","kind":"method","lang":"java","code":"public Excluder disableInnerClassSerialization() {\n Excluder result = clone();\n result.serializeInnerClasses = false;\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":90,"symbol":"excludeFieldsWithoutExposeAnnotation","kind":"method","lang":"java","code":"public Excluder excludeFieldsWithoutExposeAnnotation() {\n Excluder result = clone();\n result.requireExpose = true;\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":96,"symbol":"withExclusionStrategy","kind":"method","lang":"java","code":"public Excluder withExclusionStrategy(\n ExclusionStrategy exclusionStrategy, boolean serialization, boolean deserialization) {\n Excluder result = clone();\n if (serialization) {\n result.serializationStrategies = new ArrayList<>(serializationStrategies);\n result.serializationStrategies.add(exclusionStrategy);\n }\n if (deserialization) {\n result.deserializationStrategies = new ArrayList<>(deserializationStrategies);\n result.deserializationStrategies.add(exclusionStrategy);\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":110,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n Class rawType = type.getRawType();\n\n boolean skipSerialize = excludeClass(rawType, true);\n boolean skipDeserialize = excludeClass(rawType, false);\n\n if (!skipSerialize && !skipDeserialize) {\n return null;\n }\n\n return new TypeAdapter() {\n /**\n * The delegate is lazily created because it may not be needed, and creating it may fail.\n * Field has to be {@code volatile} because {@link Gson} guarantees to be thread-safe.\n */\n private volatile TypeAdapter delegate;\n\n @Override\n public T read(JsonReader in) throws IOException {\n if (skipDeserialize) {\n in.skipValue();\n return null;\n }\n return delegate().read(in);\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n if (skipSerialize) {\n out.nullValue();\n return;\n }\n delegate().write(out, value);\n }\n\n private TypeAdapter delegate() {\n // A race might lead to `delegate` being assigned by multiple threads but the last\n // assignment will stick\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":128,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n if (skipDeserialize) {\n in.skipValue();\n return null;\n }\n return delegate().read(in);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":137,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n if (skipSerialize) {\n out.nullValue();\n return;\n }\n delegate().write(out, value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":146,"symbol":"delegate","kind":"method","lang":"java","code":"private TypeAdapter delegate() {\n // A race might lead to `delegate` being assigned by multiple threads but the last\n // assignment will stick\n TypeAdapter d = delegate;\n if (d == null) {\n d = delegate = gson.getDelegateAdapter(Excluder.this, type);\n }\n return d;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":158,"symbol":"excludeField","kind":"method","lang":"java","code":"public boolean excludeField(Field field, boolean serialize) {\n return isExcludedByModifier(field)\n || isExcludedByVersion(field)\n || field.isSynthetic()\n || isExcludedByExposeAnnotation(field, serialize)\n || excludeClass(field.getType(), serialize)\n || isExcludedByStrategy(field, serialize);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":167,"symbol":"isExcludedByModifier","kind":"method","lang":"java","code":"private boolean isExcludedByModifier(Field field) {\n return (modifiers & field.getModifiers()) != 0;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":171,"symbol":"isExcludedByVersion","kind":"method","lang":"java","code":"private boolean isExcludedByVersion(Field field) {\n return version != Excluder.IGNORE_VERSIONS\n && !isValidVersion(field.getAnnotation(Since.class), field.getAnnotation(Until.class));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":176,"symbol":"isExcludedByExposeAnnotation","kind":"method","lang":"java","code":"private boolean isExcludedByExposeAnnotation(Field field, boolean serialize) {\n if (!requireExpose) {\n return false;\n }\n Expose annotation = field.getAnnotation(Expose.class);\n return annotation == null || (serialize ? !annotation.serialize() : !annotation.deserialize());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":184,"symbol":"isExcludedByStrategy","kind":"method","lang":"java","code":"private boolean isExcludedByStrategy(Field field, boolean serialize) {\n List list = serialize ? serializationStrategies : deserializationStrategies;\n if (list.isEmpty()) {\n return false;\n }\n FieldAttributes fieldAttributes = new FieldAttributes(field);\n for (ExclusionStrategy exclusionStrategy : list) {\n if (exclusionStrategy.shouldSkipField(fieldAttributes)) {\n return true;\n }\n }\n return false;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":199,"symbol":"excludeClass","kind":"method","lang":"java","doc":"public for unit tests; can otherwise be private","code":"public boolean excludeClass(Class clazz, boolean serialize) {\n if (version != Excluder.IGNORE_VERSIONS\n && !isValidVersion(clazz.getAnnotation(Since.class), clazz.getAnnotation(Until.class))) {\n return true;\n }\n\n if (!serializeInnerClasses && isInnerClass(clazz)) {\n return true;\n }\n\n /*\n * Exclude anonymous and local classes because they can have synthetic fields capturing enclosing\n * values which makes serialization and deserialization unreliable.\n * Don't exclude anonymous enum subclasses because enum types have a built-in adapter.\n *\n * Exclude only for deserialization; for serialization allow because custom adapter might be\n * used; if no custom adapter exists reflection-based adapter otherwise excludes value.\n *\n * Cannot allow deserialization reliably here because some custom adapters like Collection adapter\n * fall back to creating instances using Unsafe, which would likely lead to runtime exceptions\n * for anonymous and local classes if they capture values.\n */\n if (!serialize\n && !Enum.class.isAssignableFrom(clazz)\n && ReflectionHelper.isAnonymousOrNonStaticLocal(clazz)) {\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":236,"symbol":"isInnerClass","kind":"method","lang":"java","code":"private static boolean isInnerClass(Class clazz) {\n return clazz.isMemberClass() && !ReflectionHelper.isStatic(clazz);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":240,"symbol":"isValidVersion","kind":"method","lang":"java","code":"private boolean isValidVersion(Since since, Until until) {\n return isValidSince(since) && isValidUntil(until);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":244,"symbol":"isValidSince","kind":"method","lang":"java","code":"private boolean isValidSince(Since annotation) {\n if (annotation != null) {\n double annotationVersion = annotation.value();\n return version >= annotationVersion;\n }\n return true;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Excluder.java","line":252,"symbol":"isValidUntil","kind":"method","lang":"java","code":"private boolean isValidUntil(Until annotation) {\n if (annotation != null) {\n double annotationVersion = annotation.value();\n return version < annotationVersion;\n }\n return true;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":43,"symbol":"GsonTypes","kind":"class","lang":"java","doc":"Static methods for working with types. @author Bob Lee @author Jesse Wilson","code":"public final class GsonTypes {\n static final Type[] EMPTY_TYPE_ARRAY = new Type[] {};\n\n private GsonTypes() {\n throw new UnsupportedOperationException();\n }\n\n /**\n * Returns a new parameterized type, applying {@code typeArguments} to {@code rawType} and\n * enclosed by {@code ownerType}.\n *\n * @return a parameterized type.\n */\n public static ParameterizedType newParameterizedTypeWithOwner(\n Type ownerType, Class rawType, Type... typeArguments) {\n return new ParameterizedTypeImpl(ownerType, rawType, typeArguments);\n }\n\n /**\n * Returns an array type whose elements are all instances of {@code componentType}.\n *\n * @return a generic array type.\n */\n public static GenericArrayType arrayOf(Type componentType) {\n return new GenericArrayTypeImpl(componentType);\n }\n\n /**\n * Returns a type that represents an unknown type that extends {@code bound}. For example, if\n * {@code bound} is {@code CharSequence.class}, this returns {@code ? extends CharSequence}. If\n * {@code bound} is {@code Object.class}, this returns {@code ?}, which is shorthand for {@code ?\n * extends Object}.\n */\n public static WildcardType subtypeOf(Type bound) {\n Type"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":46,"symbol":"GsonTypes","kind":"constructor","lang":"java","code":"private GsonTypes() {\n throw new UnsupportedOperationException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":56,"symbol":"newParameterizedTypeWithOwner","kind":"method","lang":"java","doc":"Returns a new parameterized type, applying {@code typeArguments} to {@code rawType} and enclosed by {@code ownerType}. @return a parameterized type.","code":"public static ParameterizedType newParameterizedTypeWithOwner(\n Type ownerType, Class rawType, Type... typeArguments) {\n return new ParameterizedTypeImpl(ownerType, rawType, typeArguments);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":66,"symbol":"arrayOf","kind":"method","lang":"java","doc":"Returns an array type whose elements are all instances of {@code componentType}. @return a generic array type.","code":"public static GenericArrayType arrayOf(Type componentType) {\n return new GenericArrayTypeImpl(componentType);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":76,"symbol":"subtypeOf","kind":"method","lang":"java","doc":"Returns a type that represents an unknown type that extends {@code bound}. For example, if {@code bound} is {@code CharSequence.class}, this returns {@code ? extends CharSequence}. If {@code bound} is {@code Object.class}, this returns {@code ?}, which is shorthand for {@code ? extends Object}.","code":"public static WildcardType subtypeOf(Type bound) {\n Type[] upperBounds;\n if (bound instanceof WildcardType) {\n upperBounds = ((WildcardType) bound).getUpperBounds();\n } else {\n upperBounds = new Type[] {bound};\n }\n return new WildcardTypeImpl(upperBounds, EMPTY_TYPE_ARRAY);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":90,"symbol":"supertypeOf","kind":"method","lang":"java","doc":"Returns a type that represents an unknown supertype of {@code bound}. For example, if {@code bound} is {@code String.class}, this returns {@code ? super String}.","code":"public static WildcardType supertypeOf(Type bound) {\n Type[] lowerBounds;\n if (bound instanceof WildcardType) {\n lowerBounds = ((WildcardType) bound).getLowerBounds();\n } else {\n lowerBounds = new Type[] {bound};\n }\n return new WildcardTypeImpl(new Type[] {Object.class}, lowerBounds);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":104,"symbol":"canonicalize","kind":"method","lang":"java","doc":"Returns a type that is functionally equal but not necessarily equal according to {@link Object#equals(Object) Object.equals()}.","code":"public static Type canonicalize(Type type) {\n if (type instanceof Class) {\n Class c = (Class) type;\n return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;\n\n } else if (type instanceof ParameterizedType) {\n ParameterizedType p = (ParameterizedType) type;\n return new ParameterizedTypeImpl(\n p.getOwnerType(), (Class) p.getRawType(), p.getActualTypeArguments());\n\n } else if (type instanceof GenericArrayType) {\n GenericArrayType g = (GenericArrayType) type;\n return new GenericArrayTypeImpl(g.getGenericComponentType());\n\n } else if (type instanceof WildcardType) {\n WildcardType w = (WildcardType) type;\n return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());\n\n } else {\n // unsupported type, return as is\n return type;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":128,"symbol":"getRawType","kind":"method","lang":"java","code":"public static Class getRawType(Type type) {\n if (type instanceof Class) {\n // type is a normal class.\n return (Class) type;\n\n } else if (type instanceof ParameterizedType) {\n ParameterizedType parameterizedType = (ParameterizedType) type;\n\n // getRawType() returns Type instead of Class; that seems to be an API mistake,\n // see https://bugs.openjdk.org/browse/JDK-8250659\n Type rawType = parameterizedType.getRawType();\n return (Class) rawType;\n\n } else if (type instanceof GenericArrayType) {\n Type componentType = ((GenericArrayType) type).getGenericComponentType();\n return Array.newInstance(getRawType(componentType), 0).getClass();\n\n } else if (type instanceof TypeVariable) {\n // we could use the variable's bounds, but that won't work if there are multiple.\n // having a raw type that's more general than necessary is okay\n return Object.class;\n\n } else if (type instanceof WildcardType) {\n Type[] bounds = ((WildcardType) type).getUpperBounds();\n // Currently the JLS only permits one bound for wildcards so using first bound is safe\n assert bounds.length == 1;\n return getRawType(bou"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":166,"symbol":"equal","kind":"method","lang":"java","code":"private static boolean equal(Object a, Object b) {\n return Objects.equals(a, b);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":171,"symbol":"equals","kind":"method","lang":"java","doc":"Returns true if {@code a} and {@code b} are equal.","code":"public static boolean equals(Type a, Type b) {\n @SuppressWarnings(\"ReferenceEquality\")\n boolean areSame = a == b;\n if (areSame) {\n // also handles (a == null && b == null)\n return true;\n\n } else if (a instanceof Class) {\n // Class already specifies equals().\n return a.equals(b);\n\n } else if (a instanceof ParameterizedType) {\n if (!(b instanceof ParameterizedType)) {\n return false;\n }\n\n // TODO: save a .clone() call\n ParameterizedType pa = (ParameterizedType) a;\n ParameterizedType pb = (ParameterizedType) b;\n return equal(pa.getOwnerType(), pb.getOwnerType())\n && pa.getRawType().equals(pb.getRawType())\n && Arrays.equals(pa.getActualTypeArguments(), pb.getActualTypeArguments());\n\n } else if (a instanceof GenericArrayType) {\n if (!(b instanceof GenericArrayType)) {\n return false;\n }\n\n GenericArrayType ga = (GenericArrayType) a;\n GenericArrayType gb = (GenericArrayType) b;\n return equals(ga.getGenericComponentType(), gb.getGenericComponentType());\n\n } else if (a instanceof WildcardType) {\n if (!(b instanceof WildcardType)) {\n return false;\n }\n"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":228,"symbol":"typeToString","kind":"method","lang":"java","code":"public static String typeToString(Type type) {\n return type instanceof Class ? ((Class) type).getName() : type.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":237,"symbol":"getGenericSupertype","kind":"method","lang":"java","doc":"Returns the generic supertype for {@code supertype}. For example, given a class {@code IntegerSet}, the result for when supertype is {@code Set.class} is {@code Set} and the result when the supertype is {@code Collection.class} is {@code Collection}.","code":"private static Type getGenericSupertype(Type context, Class rawType, Class supertype) {\n if (supertype == rawType) {\n return context;\n }\n\n // we skip searching through interfaces if unknown is an interface\n if (supertype.isInterface()) {\n Class[] interfaces = rawType.getInterfaces();\n for (int i = 0, length = interfaces.length; i < length; i++) {\n if (interfaces[i] == supertype) {\n return rawType.getGenericInterfaces()[i];\n } else if (supertype.isAssignableFrom(interfaces[i])) {\n return getGenericSupertype(rawType.getGenericInterfaces()[i], interfaces[i], supertype);\n }\n }\n }\n\n // check our supertypes\n if (!rawType.isInterface()) {\n while (rawType != Object.class) {\n Class rawSupertype = rawType.getSuperclass();\n if (rawSupertype == supertype) {\n return rawType.getGenericSuperclass();\n } else if (supertype.isAssignableFrom(rawSupertype)) {\n return getGenericSupertype(rawType.getGenericSuperclass(), rawSupertype, supertype);\n }\n rawType = rawSupertype;\n }\n }\n\n // we can't resolve this further\n return supertype;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":278,"symbol":"getSupertype","kind":"method","lang":"java","doc":"Returns the generic form of {@code supertype}. For example, if this is {@code ArrayList}, this returns {@code Iterable} given the input {@code Iterable.class}. @param supertype a superclass of, or interface implemented by, this.","code":"private static Type getSupertype(Type context, Class contextRawType, Class supertype) {\n if (context instanceof WildcardType) {\n // Wildcards are useless for resolving supertypes. As the upper bound has the same raw type,\n // use it instead\n Type[] bounds = ((WildcardType) context).getUpperBounds();\n // Currently the JLS only permits one bound for wildcards so using first bound is safe\n assert bounds.length == 1;\n context = bounds[0];\n }\n if (!supertype.isAssignableFrom(contextRawType)) {\n throw new IllegalArgumentException(\n contextRawType + \" is not the same as or a subtype of \" + supertype);\n }\n return resolve(\n context, contextRawType, GsonTypes.getGenericSupertype(context, contextRawType, supertype));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":300,"symbol":"getArrayComponentType","kind":"method","lang":"java","doc":"Returns the component type of this array type. @throws ClassCastException if this type is not an array.","code":"public static Type getArrayComponentType(Type array) {\n return array instanceof GenericArrayType\n ? ((GenericArrayType) array).getGenericComponentType()\n : ((Class) array).getComponentType();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":311,"symbol":"getCollectionElementType","kind":"method","lang":"java","doc":"Returns the element type of this collection type. @throws IllegalArgumentException if this type is not a collection.","code":"public static Type getCollectionElementType(Type context, Class contextRawType) {\n Type collectionType = getSupertype(context, contextRawType, Collection.class);\n\n if (collectionType instanceof ParameterizedType) {\n return ((ParameterizedType) collectionType).getActualTypeArguments()[0];\n }\n return Object.class;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":324,"symbol":"getMapKeyAndValueTypes","kind":"method","lang":"java","doc":"Returns a two element array containing this map's key and value types in positions 0 and 1 respectively.","code":"public static Type[] getMapKeyAndValueTypes(Type context, Class contextRawType) {\n /*\n * Work around a problem with the declaration of java.util.Properties. That\n * class should extend Hashtable, but it's declared to\n * extend Hashtable.\n */\n if (Properties.class.isAssignableFrom(contextRawType)) {\n return new Type[] {String.class, String.class};\n }\n\n Type mapType = getSupertype(context, contextRawType, Map.class);\n // TODO: strip wildcards?\n if (mapType instanceof ParameterizedType) {\n ParameterizedType mapParameterizedType = (ParameterizedType) mapType;\n return mapParameterizedType.getActualTypeArguments();\n }\n return new Type[] {Object.class, Object.class};\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":343,"symbol":"resolve","kind":"method","lang":"java","code":"public static Type resolve(Type context, Class contextRawType, Type toResolve) {\n\n return resolve(context, contextRawType, toResolve, new HashMap, Type>());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":348,"symbol":"resolve","kind":"method","lang":"java","code":"private static Type resolve(\n Type context,\n Class contextRawType,\n Type toResolve,\n Map, Type> visitedTypeVariables) {\n // this implementation is made a little more complicated in an attempt to avoid object-creation\n TypeVariable resolving = null;\n while (true) {\n if (toResolve instanceof TypeVariable) {\n TypeVariable typeVariable = (TypeVariable) toResolve;\n Type previouslyResolved = visitedTypeVariables.get(typeVariable);\n if (previouslyResolved != null) {\n // cannot reduce due to infinite recursion\n return (previouslyResolved == Void.TYPE) ? toResolve : previouslyResolved;\n }\n\n // Insert a placeholder to mark the fact that we are in the process of resolving this type\n visitedTypeVariables.put(typeVariable, Void.TYPE);\n if (resolving == null) {\n resolving = typeVariable;\n }\n\n toResolve = resolveTypeVariable(context, contextRawType, typeVariable);\n @SuppressWarnings(\"ReferenceEquality\")\n boolean areSame = toResolve == typeVariable;\n if (areSame) {\n break;\n }\n\n } else if (toResolve instance"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":454,"symbol":"resolveTypeVariable","kind":"method","lang":"java","code":"private static Type resolveTypeVariable(\n Type context, Class contextRawType, TypeVariable unknown) {\n Class declaredByRaw = declaringClassOf(unknown);\n\n // we can't reduce this further\n if (declaredByRaw == null) {\n return unknown;\n }\n\n Type declaredBy = getGenericSupertype(context, contextRawType, declaredByRaw);\n if (declaredBy instanceof ParameterizedType) {\n int index = indexOf(declaredByRaw.getTypeParameters(), unknown);\n return ((ParameterizedType) declaredBy).getActualTypeArguments()[index];\n }\n\n return unknown;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":472,"symbol":"indexOf","kind":"method","lang":"java","code":"private static int indexOf(Object[] array, Object toFind) {\n for (int i = 0, length = array.length; i < length; i++) {\n if (toFind.equals(array[i])) {\n return i;\n }\n }\n throw new NoSuchElementException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":485,"symbol":"declaringClassOf","kind":"method","lang":"java","doc":"Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by a class.","code":"private static Class declaringClassOf(TypeVariable typeVariable) {\n GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();\n return genericDeclaration instanceof Class ? (Class) genericDeclaration : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":490,"symbol":"checkNotPrimitive","kind":"method","lang":"java","code":"static void checkNotPrimitive(Type type) {\n if (type instanceof Class && ((Class) type).isPrimitive()) {\n throw new IllegalArgumentException(\"Primitive type is not allowed\");\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":503,"symbol":"requiresOwnerType","kind":"method","lang":"java","doc":"Whether an {@linkplain ParameterizedType#getOwnerType() owner type} must be specified when constructing a {@link ParameterizedType} for {@code rawType}.

    Note that this method might not require an owner type for all cases where Java reflection would create parameterized types with owner type.","code":"public static boolean requiresOwnerType(Type rawType) {\n if (rawType instanceof Class) {\n Class rawTypeAsClass = (Class) rawType;\n return !Modifier.isStatic(rawTypeAsClass.getModifiers())\n && rawTypeAsClass.getDeclaringClass() != null;\n }\n return false;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":512,"symbol":"ParameterizedTypeImpl","kind":"class","lang":"java","code":"private static final class ParameterizedTypeImpl implements ParameterizedType {\n private final Type ownerType;\n\n private final Type rawType;\n\n private final Type[] typeArguments;\n\n ParameterizedTypeImpl(Type ownerType, Class rawType, Type... typeArguments) {\n requireNonNull(rawType);\n\n if (ownerType == null && requiresOwnerType(rawType)) {\n throw new IllegalArgumentException(\"Must specify owner type for \" + rawType);\n }\n\n this.ownerType = ownerType == null ? null : canonicalize(ownerType);\n this.rawType = canonicalize(rawType);\n this.typeArguments = typeArguments.clone();\n for (int t = 0, length = this.typeArguments.length; t < length; t++) {\n requireNonNull(this.typeArguments[t]);\n checkNotPrimitive(this.typeArguments[t]);\n this.typeArguments[t] = canonicalize(this.typeArguments[t]);\n }\n }\n\n @Override\n public Type[] getActualTypeArguments() {\n return typeArguments.clone();\n }\n\n @Override\n public Type getRawType() {\n return rawType;\n }\n\n @Override\n public Type getOwnerType() {\n return ownerType;\n }\n\n @Override\n public boolean equals(Object other) {\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":519,"symbol":"ParameterizedTypeImpl","kind":"constructor","lang":"java","code":"ParameterizedTypeImpl(Type ownerType, Class rawType, Type... typeArguments) {\n requireNonNull(rawType);\n\n if (ownerType == null && requiresOwnerType(rawType)) {\n throw new IllegalArgumentException(\"Must specify owner type for \" + rawType);\n }\n\n this.ownerType = ownerType == null ? null : canonicalize(ownerType);\n this.rawType = canonicalize(rawType);\n this.typeArguments = typeArguments.clone();\n for (int t = 0, length = this.typeArguments.length; t < length; t++) {\n requireNonNull(this.typeArguments[t]);\n checkNotPrimitive(this.typeArguments[t]);\n this.typeArguments[t] = canonicalize(this.typeArguments[t]);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":536,"symbol":"getActualTypeArguments","kind":"method","lang":"java","code":"@Override\n public Type[] getActualTypeArguments() {\n return typeArguments.clone();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":541,"symbol":"getRawType","kind":"method","lang":"java","code":"@Override\n public Type getRawType() {\n return rawType;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":546,"symbol":"getOwnerType","kind":"method","lang":"java","code":"@Override\n public Type getOwnerType() {\n return ownerType;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":551,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object other) {\n return other instanceof ParameterizedType\n && GsonTypes.equals(this, (ParameterizedType) other);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":557,"symbol":"hashCodeOrZero","kind":"method","lang":"java","code":"private static int hashCodeOrZero(Object o) {\n return o != null ? o.hashCode() : 0;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":561,"symbol":"hashCode","kind":"method","lang":"java","code":"@Override\n public int hashCode() {\n return Arrays.hashCode(typeArguments) ^ rawType.hashCode() ^ hashCodeOrZero(ownerType);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":566,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n int length = typeArguments.length;\n if (length == 0) {\n return typeToString(rawType);\n }\n\n StringBuilder stringBuilder = new StringBuilder(30 * (length + 1));\n stringBuilder\n .append(typeToString(rawType))\n .append(\"<\")\n .append(typeToString(typeArguments[0]));\n for (int i = 1; i < length; i++) {\n stringBuilder.append(\", \").append(typeToString(typeArguments[i]));\n }\n return stringBuilder.append(\">\").toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":585,"symbol":"GenericArrayTypeImpl","kind":"class","lang":"java","code":"private static final class GenericArrayTypeImpl implements GenericArrayType {\n private final Type componentType;\n\n GenericArrayTypeImpl(Type componentType) {\n requireNonNull(componentType);\n this.componentType = canonicalize(componentType);\n }\n\n @Override\n public Type getGenericComponentType() {\n return componentType;\n }\n\n @Override\n public boolean equals(Object o) {\n return o instanceof GenericArrayType && GsonTypes.equals(this, (GenericArrayType) o);\n }\n\n @Override\n public int hashCode() {\n return componentType.hashCode();\n }\n\n @Override\n public String toString() {\n return typeToString(componentType) + \"[]\";\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":588,"symbol":"GenericArrayTypeImpl","kind":"constructor","lang":"java","code":"GenericArrayTypeImpl(Type componentType) {\n requireNonNull(componentType);\n this.componentType = canonicalize(componentType);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":593,"symbol":"getGenericComponentType","kind":"method","lang":"java","code":"@Override\n public Type getGenericComponentType() {\n return componentType;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":598,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object o) {\n return o instanceof GenericArrayType && GsonTypes.equals(this, (GenericArrayType) o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":603,"symbol":"hashCode","kind":"method","lang":"java","code":"@Override\n public int hashCode() {\n return componentType.hashCode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":608,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return typeToString(componentType) + \"[]\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":620,"symbol":"WildcardTypeImpl","kind":"class","lang":"java","doc":"The WildcardType interface supports multiple upper bounds and multiple lower bounds. We only support what the target Java version supports - at most one bound, see also https://bugs.openjdk.java.net/browse/JDK-8250660. If a lower bound is set, the upper bound must be Object.class.","code":"private static final class WildcardTypeImpl implements WildcardType {\n private final Type upperBound;\n\n private final Type lowerBound;\n\n WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {\n if (lowerBounds.length > 1) {\n throw new IllegalArgumentException(\"At most one lower bound is supported\");\n }\n if (upperBounds.length != 1) {\n throw new IllegalArgumentException(\"Exactly one upper bound must be specified\");\n }\n\n if (lowerBounds.length == 1) {\n requireNonNull(lowerBounds[0]);\n checkNotPrimitive(lowerBounds[0]);\n if (upperBounds[0] != Object.class) {\n throw new IllegalArgumentException(\n \"When lower bound is specified, upper bound must be Object\");\n }\n this.lowerBound = canonicalize(lowerBounds[0]);\n this.upperBound = Object.class;\n\n } else {\n requireNonNull(upperBounds[0]);\n checkNotPrimitive(upperBounds[0]);\n this.lowerBound = null;\n this.upperBound = canonicalize(upperBounds[0]);\n }\n }\n\n @Override\n public Type[] getUpperBounds() {\n return new Type[] {upperBound};\n }\n\n @Override\n public Type[] getLower"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":625,"symbol":"WildcardTypeImpl","kind":"constructor","lang":"java","code":"WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {\n if (lowerBounds.length > 1) {\n throw new IllegalArgumentException(\"At most one lower bound is supported\");\n }\n if (upperBounds.length != 1) {\n throw new IllegalArgumentException(\"Exactly one upper bound must be specified\");\n }\n\n if (lowerBounds.length == 1) {\n requireNonNull(lowerBounds[0]);\n checkNotPrimitive(lowerBounds[0]);\n if (upperBounds[0] != Object.class) {\n throw new IllegalArgumentException(\n \"When lower bound is specified, upper bound must be Object\");\n }\n this.lowerBound = canonicalize(lowerBounds[0]);\n this.upperBound = Object.class;\n\n } else {\n requireNonNull(upperBounds[0]);\n checkNotPrimitive(upperBounds[0]);\n this.lowerBound = null;\n this.upperBound = canonicalize(upperBounds[0]);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":651,"symbol":"getUpperBounds","kind":"method","lang":"java","code":"@Override\n public Type[] getUpperBounds() {\n return new Type[] {upperBound};\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":656,"symbol":"getLowerBounds","kind":"method","lang":"java","code":"@Override\n public Type[] getLowerBounds() {\n return lowerBound != null ? new Type[] {lowerBound} : EMPTY_TYPE_ARRAY;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":661,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object other) {\n return other instanceof WildcardType && GsonTypes.equals(this, (WildcardType) other);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":666,"symbol":"hashCode","kind":"method","lang":"java","code":"@Override\n public int hashCode() {\n // this equals Arrays.hashCode(getLowerBounds()) ^ Arrays.hashCode(getUpperBounds());\n return (lowerBound != null ? 31 + lowerBound.hashCode() : 1) ^ (31 + upperBound.hashCode());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/GsonTypes.java","line":672,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n if (lowerBound != null) {\n return \"? super \" + typeToString(lowerBound);\n } else if (upperBound == Object.class) {\n return \"?\";\n } else {\n return \"? extends \" + typeToString(upperBound);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":20,"symbol":"JavaVersion","kind":"class","lang":"java","doc":"Utility to check the major Java version of the current JVM.","code":"public final class JavaVersion {\n // Oracle defines naming conventions at\n // http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html\n // However, many alternate implementations differ. For example, Debian used 9-debian as the\n // version string\n\n private static final int majorJavaVersion = determineMajorJavaVersion();\n\n private static int determineMajorJavaVersion() {\n String javaVersion = System.getProperty(\"java.version\");\n return parseMajorJavaVersion(javaVersion);\n }\n\n // Visible for testing only\n static int parseMajorJavaVersion(String javaVersion) {\n int version = parseDotted(javaVersion);\n if (version == -1) {\n version = extractBeginningInt(javaVersion);\n }\n if (version == -1) {\n return 6; // Choose minimum supported JDK version as default\n }\n return version;\n }\n\n // Parses both legacy 1.8 style and newer 9.0.4 style\n private static int parseDotted(String javaVersion) {\n try {\n String[] parts = javaVersion.split(\"[._]\", 3);\n int firstVer = Integer.parseInt(parts[0]);\n if (firstVer == 1 && parts.length > 1) {\n return Integer.parseInt(parts[1]);\n } else {\n return firstVer;\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":28,"symbol":"determineMajorJavaVersion","kind":"method","lang":"java","code":"private static int determineMajorJavaVersion() {\n String javaVersion = System.getProperty(\"java.version\");\n return parseMajorJavaVersion(javaVersion);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":34,"symbol":"parseMajorJavaVersion","kind":"method","lang":"java","doc":"Visible for testing only","code":"static int parseMajorJavaVersion(String javaVersion) {\n int version = parseDotted(javaVersion);\n if (version == -1) {\n version = extractBeginningInt(javaVersion);\n }\n if (version == -1) {\n return 6; // Choose minimum supported JDK version as default\n }\n return version;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":46,"symbol":"parseDotted","kind":"method","lang":"java","doc":"Parses both legacy 1.8 style and newer 9.0.4 style","code":"private static int parseDotted(String javaVersion) {\n try {\n String[] parts = javaVersion.split(\"[._]\", 3);\n int firstVer = Integer.parseInt(parts[0]);\n if (firstVer == 1 && parts.length > 1) {\n return Integer.parseInt(parts[1]);\n } else {\n return firstVer;\n }\n } catch (NumberFormatException e) {\n return -1;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":60,"symbol":"extractBeginningInt","kind":"method","lang":"java","code":"private static int extractBeginningInt(String javaVersion) {\n try {\n StringBuilder num = new StringBuilder();\n for (int i = 0; i < javaVersion.length(); ++i) {\n char c = javaVersion.charAt(i);\n if (Character.isDigit(c)) {\n num.append(c);\n } else {\n break;\n }\n }\n return Integer.parseInt(num.toString());\n } catch (NumberFormatException e) {\n return -1;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":82,"symbol":"getMajorJavaVersion","kind":"method","lang":"java","doc":"Gets the major Java version @return the major Java version, i.e. '8' for Java 1.8, '9' for Java 9 etc.","code":"public static int getMajorJavaVersion() {\n return majorJavaVersion;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":92,"symbol":"isJava9OrLater","kind":"method","lang":"java","doc":"Gets a boolean value depending if the application is running on Java 9 or later @return {@code true} if the application is running on Java 9 or later; and {@code false} otherwise.","code":"public static boolean isJava9OrLater() {\n return majorJavaVersion >= 9;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JavaVersion.java","line":96,"symbol":"JavaVersion","kind":"constructor","lang":"java","code":"private JavaVersion() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java","line":23,"symbol":"JsonReaderInternalAccess","kind":"class","lang":"java","doc":"Internal-only APIs of JsonReader available only to other classes in Gson.","code":"public abstract class JsonReaderInternalAccess {\n // Suppress warnings because field is initialized by `JsonReader` class during class loading\n // (and therefore should be thread-safe), and any usage appears after `JsonReader` was loaded\n @SuppressWarnings({\"ConstantField\", \"NonFinalStaticField\"})\n public static volatile JsonReaderInternalAccess INSTANCE;\n\n /** Changes the type of the current property name token to a string value. */\n public abstract void promoteNameToValue(JsonReader reader) throws IOException;\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java","line":30,"symbol":"promoteNameToValue","kind":"method","lang":"java","doc":"Changes the type of the current property name token to a string value.","code":"public abstract void promoteNameToValue(JsonReader reader) throws IOException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":28,"symbol":"LazilyParsedNumber","kind":"class","lang":"java","doc":"This class holds a number value that is lazily converted to a specific number type @author Inderjeet Singh","code":"@SuppressWarnings(\"serial\") // ignore warning about missing serialVersionUID\npublic final class LazilyParsedNumber extends Number implements Comparable {\n private final String value;\n\n /**\n * @param value must not be null\n */\n public LazilyParsedNumber(String value) {\n this.value = value;\n }\n\n private BigDecimal asBigDecimal() {\n return NumberLimits.parseBigDecimal(value);\n }\n\n @Override\n public int intValue() {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n try {\n return (int) Long.parseLong(value);\n } catch (NumberFormatException nfe) {\n return asBigDecimal().intValue();\n }\n }\n }\n\n @Override\n public long longValue() {\n try {\n return Long.parseLong(value);\n } catch (NumberFormatException e) {\n return asBigDecimal().longValue();\n }\n }\n\n @Override\n public float floatValue() {\n return Float.parseFloat(value);\n }\n\n @Override\n public double doubleValue() {\n return Double.parseDouble(value);\n }\n\n @Override\n public String toString() {\n return value;\n }\n\n /**\n * If somebody is unlucky enough to have to serialize one of these, serialize"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":35,"symbol":"LazilyParsedNumber","kind":"constructor","lang":"java","doc":"@param value must not be null","code":"public LazilyParsedNumber(String value) {\n this.value = value;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":39,"symbol":"asBigDecimal","kind":"method","lang":"java","code":"private BigDecimal asBigDecimal() {\n return NumberLimits.parseBigDecimal(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":43,"symbol":"intValue","kind":"method","lang":"java","code":"@Override\n public int intValue() {\n try {\n return Integer.parseInt(value);\n } catch (NumberFormatException e) {\n try {\n return (int) Long.parseLong(value);\n } catch (NumberFormatException nfe) {\n return asBigDecimal().intValue();\n }\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":56,"symbol":"longValue","kind":"method","lang":"java","code":"@Override\n public long longValue() {\n try {\n return Long.parseLong(value);\n } catch (NumberFormatException e) {\n return asBigDecimal().longValue();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":65,"symbol":"floatValue","kind":"method","lang":"java","code":"@Override\n public float floatValue() {\n return Float.parseFloat(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":70,"symbol":"doubleValue","kind":"method","lang":"java","code":"@Override\n public double doubleValue() {\n return Double.parseDouble(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":75,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return value;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":84,"symbol":"writeReplace","kind":"method","lang":"java","doc":"If somebody is unlucky enough to have to serialize one of these, serialize it as a BigDecimal so that they won't need Gson on the other side to deserialize it.","code":"private Object writeReplace() {\n return asBigDecimal();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":88,"symbol":"readObject","kind":"method","lang":"java","code":"private void readObject(ObjectInputStream in) throws IOException {\n // Don't permit directly deserializing this class; writeReplace() should have written a\n // replacement\n throw new InvalidObjectException(\"Deserialization is unsupported\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":100,"symbol":"compareTo","kind":"method","lang":"java","doc":"Compares this LazilyParsedNumber with the specified LazilyParsedNumber. The comparison is lexicographical, based on the string values of the two numbers, so it does not in general correspond to numeric comparison. For numeric comparison, call {@link #asBigDecimal()} on both numbers and compare the results.","code":"@Override\n public int compareTo(LazilyParsedNumber other) {\n return value.compareTo(other.value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":105,"symbol":"hashCode","kind":"method","lang":"java","code":"@Override\n public int hashCode() {\n return value.hashCode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java","line":110,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object obj) {\n if (this == obj) {\n return true;\n }\n if (obj instanceof LazilyParsedNumber) {\n LazilyParsedNumber other = (LazilyParsedNumber) obj;\n return value.equals(other.value);\n }\n return false;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":43,"symbol":"LinkedTreeMap","kind":"class","lang":"java","doc":"A map of comparable keys to values. Unlike {@code TreeMap}, this class uses insertion order for iteration order. Comparison order is only used as an optimization for efficient insertion and removal.

    This implementation was derived from Android 4.1's TreeMap class.","code":"@SuppressWarnings(\"serial\") // ignore warning about missing serialVersionUID\npublic final class LinkedTreeMap extends AbstractMap implements Serializable {\n /** Comparator for comparing keys; {@code null} if 'natural order' should be used. */\n // Uses null for 'natural order' instead of `java.util.Comparator#naturalOrder()` as potential\n // performance optimization by directly calling `compareTo` on the key objects\n private final Comparator comparator;\n\n private final boolean allowNullValues;\n Node root;\n int size = 0;\n int modCount = 0;\n\n // Used to preserve iteration order\n final Node header;\n\n /**\n * Create a natural order, empty tree map whose keys must be mutually comparable and non-null, and\n * whose values can be {@code null}.\n */\n public LinkedTreeMap() {\n this(null, true);\n }\n\n /**\n * Create a natural order, empty tree map whose keys must be mutually comparable and non-null.\n *\n * @param allowNullValues whether {@code null} is allowed as entry value\n */\n public LinkedTreeMap(boolean allowNullValues) {\n this(null, allowNullValues);\n }\n\n /**\n * Create a tree map ordered by {@code comparator}. This map'"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":62,"symbol":"LinkedTreeMap","kind":"constructor","lang":"java","doc":"Create a natural order, empty tree map whose keys must be mutually comparable and non-null, and whose values can be {@code null}.","code":"public LinkedTreeMap() {\n this(null, true);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":71,"symbol":"LinkedTreeMap","kind":"constructor","lang":"java","doc":"Create a natural order, empty tree map whose keys must be mutually comparable and non-null. @param allowNullValues whether {@code null} is allowed as entry value","code":"public LinkedTreeMap(boolean allowNullValues) {\n this(null, allowNullValues);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":83,"symbol":"LinkedTreeMap","kind":"constructor","lang":"java","doc":"comparator} permits. @param comparator the comparator to order elements with, or {@code null} to use the natural ordering. @param allowNullValues whether {@code null} is allowed as entry value","code":"public LinkedTreeMap(Comparator comparator, boolean allowNullValues) {\n this.comparator = comparator;\n this.allowNullValues = allowNullValues;\n this.header = new Node<>(allowNullValues);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":89,"symbol":"size","kind":"method","lang":"java","code":"@Override\n public int size() {\n return size;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":94,"symbol":"get","kind":"method","lang":"java","code":"@Override\n public V get(Object key) {\n Node node = findByObject(key);\n return node != null ? node.value : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":100,"symbol":"containsKey","kind":"method","lang":"java","code":"@Override\n public boolean containsKey(Object key) {\n return findByObject(key) != null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":105,"symbol":"put","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public V put(K key, V value) {\n if (key == null) {\n throw new NullPointerException(\"key == null\");\n }\n if (value == null && !allowNullValues) {\n throw new NullPointerException(\"value == null\");\n }\n Node created = find(key, true);\n V result = created.value;\n created.value = value;\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":120,"symbol":"clear","kind":"method","lang":"java","code":"@Override\n public void clear() {\n root = null;\n size = 0;\n modCount++;\n\n // Clear iteration order\n Node header = this.header;\n header.next = header.prev = header;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":131,"symbol":"remove","kind":"method","lang":"java","code":"@Override\n public V remove(Object key) {\n Node node = removeInternalByKey(key);\n return node != null ? node.value : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":142,"symbol":"find","kind":"method","lang":"java","doc":"Returns the node at or adjacent to the given key, creating it if requested. @throws ClassCastException if {@code key} and the tree's keys aren't mutually comparable.","code":"Node find(K key, boolean create) {\n Comparator comparator = this.comparator;\n Node nearest = root;\n int comparison = 0;\n\n if (nearest != null) {\n // Micro-optimization: avoid polymorphic calls to Comparator.compare().\n @SuppressWarnings(\"unchecked\") // Throws a ClassCastException below if there's trouble.\n Comparable comparableKey = comparator == null ? (Comparable) key : null;\n\n while (true) {\n comparison =\n (comparableKey != null)\n ? comparableKey.compareTo(nearest.key)\n : comparator.compare(key, nearest.key);\n\n // We found the requested key.\n if (comparison == 0) {\n return nearest;\n }\n\n // If it exists, the key is in a subtree. Go deeper.\n Node child = (comparison < 0) ? nearest.left : nearest.right;\n if (child == null) {\n break;\n }\n\n nearest = child;\n }\n }\n\n // The key doesn't exist in this tree.\n if (!create) {\n return null;\n }\n\n // Create the node and add it to the tree or the table.\n Node header = this.header;\n Node created;\n if (near"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":203,"symbol":"findByObject","kind":"method","lang":"java","code":"@SuppressWarnings(\"unchecked\")\n Node findByObject(Object key) {\n try {\n return key != null ? find((K) key, false) : null;\n } catch (ClassCastException e) {\n return null;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":220,"symbol":"findByEntry","kind":"method","lang":"java","doc":"has no such entry.

    This method uses the comparator for key equality rather than {@code equals}. If this map's comparator isn't consistent with equals (such as {@code String.CASE_INSENSITIVE_ORDER}), then {@code remove()} and {@code contains()} will violate the collections API.","code":"Node findByEntry(Entry entry) {\n Node mine = findByObject(entry.getKey());\n boolean valuesEqual = mine != null && equal(mine.value, entry.getValue());\n return valuesEqual ? mine : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":226,"symbol":"equal","kind":"method","lang":"java","code":"private static boolean equal(Object a, Object b) {\n return Objects.equals(a, b);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":235,"symbol":"removeInternal","kind":"method","lang":"java","doc":"Removes {@code node} from this tree, rearranging the tree's structure as necessary. @param unlink true to also unlink this node from the iteration linked list.","code":"void removeInternal(Node node, boolean unlink) {\n if (unlink) {\n node.prev.next = node.next;\n node.next.prev = node.prev;\n }\n\n Node left = node.left;\n Node right = node.right;\n Node originalParent = node.parent;\n if (left != null && right != null) {\n\n /*\n * To remove a node with both left and right subtrees, move an\n * adjacent node from one of those subtrees into this node's place.\n *\n * Removing the adjacent node may change this node's subtrees. This\n * node may no longer have two subtrees once the adjacent node is\n * gone!\n */\n\n Node adjacent = (left.height > right.height) ? left.last() : right.first();\n removeInternal(adjacent, false); // takes care of rebalance and size--\n\n int leftHeight = 0;\n left = node.left;\n if (left != null) {\n leftHeight = left.height;\n adjacent.left = left;\n left.parent = adjacent;\n node.left = null;\n }\n\n int rightHeight = 0;\n right = node.right;\n if (right != null) {\n rightHeight = right.height;\n adjacent.right = right;\n right.parent = adjacent;\n no"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":294,"symbol":"removeInternalByKey","kind":"method","lang":"java","code":"Node removeInternalByKey(Object key) {\n Node node = findByObject(key);\n if (node != null) {\n removeInternal(node, true);\n }\n return node;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":302,"symbol":"replaceInParent","kind":"method","lang":"java","code":"@SuppressWarnings(\"ReferenceEquality\")\n private void replaceInParent(Node node, Node replacement) {\n Node parent = node.parent;\n node.parent = null;\n if (replacement != null) {\n replacement.parent = parent;\n }\n\n if (parent != null) {\n if (parent.left == node) {\n parent.left = replacement;\n } else {\n assert parent.right == node;\n parent.right = replacement;\n }\n } else {\n root = replacement;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":328,"symbol":"rebalance","kind":"method","lang":"java","doc":"Rebalances the tree by making any AVL rotations necessary between the newly-unbalanced node and the tree's root. @param insert true if the node was unbalanced by an insert; false if it was by a removal.","code":"private void rebalance(Node unbalanced, boolean insert) {\n for (Node node = unbalanced; node != null; node = node.parent) {\n Node left = node.left;\n Node right = node.right;\n int leftHeight = left != null ? left.height : 0;\n int rightHeight = right != null ? right.height : 0;\n\n int delta = leftHeight - rightHeight;\n if (delta == -2) {\n Node rightLeft = right.left;\n Node rightRight = right.right;\n int rightRightHeight = rightRight != null ? rightRight.height : 0;\n int rightLeftHeight = rightLeft != null ? rightLeft.height : 0;\n\n int rightDelta = rightLeftHeight - rightRightHeight;\n if (rightDelta == -1 || (rightDelta == 0 && !insert)) {\n rotateLeft(node); // AVL right right\n } else {\n assert (rightDelta == 1);\n rotateRight(right); // AVL right left\n rotateLeft(node);\n }\n if (insert) {\n break; // no further rotations will be necessary\n }\n\n } else if (delta == 2) {\n Node leftLeft = left.left;\n Node leftRight = left.right;\n int leftRightHeight = leftRight != null ? le"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":389,"symbol":"rotateLeft","kind":"method","lang":"java","doc":"Rotates the subtree so that its root's right child is the new root.","code":"private void rotateLeft(Node root) {\n Node left = root.left;\n Node pivot = root.right;\n Node pivotLeft = pivot.left;\n Node pivotRight = pivot.right;\n\n // move the pivot's left child to the root's right\n root.right = pivotLeft;\n if (pivotLeft != null) {\n pivotLeft.parent = root;\n }\n\n replaceInParent(root, pivot);\n\n // move the root to the pivot's left\n pivot.left = root;\n root.parent = pivot;\n\n // fix heights\n root.height =\n Math.max(left != null ? left.height : 0, pivotLeft != null ? pivotLeft.height : 0) + 1;\n pivot.height = Math.max(root.height, pivotRight != null ? pivotRight.height : 0) + 1;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":414,"symbol":"rotateRight","kind":"method","lang":"java","doc":"Rotates the subtree so that its root's left child is the new root.","code":"private void rotateRight(Node root) {\n Node pivot = root.left;\n Node right = root.right;\n Node pivotLeft = pivot.left;\n Node pivotRight = pivot.right;\n\n // move the pivot's right child to the root's left\n root.left = pivotRight;\n if (pivotRight != null) {\n pivotRight.parent = root;\n }\n\n replaceInParent(root, pivot);\n\n // move the root to the pivot's right\n pivot.right = root;\n root.parent = pivot;\n\n // fixup heights\n root.height =\n Math.max(right != null ? right.height : 0, pivotRight != null ? pivotRight.height : 0) + 1;\n pivot.height = Math.max(root.height, pivotLeft != null ? pivotLeft.height : 0) + 1;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":441,"symbol":"entrySet","kind":"method","lang":"java","code":"@Override\n public Set> entrySet() {\n EntrySet result = entrySet;\n if (result == null) {\n result = entrySet = new EntrySet();\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":450,"symbol":"keySet","kind":"method","lang":"java","code":"@Override\n public Set keySet() {\n KeySet result = keySet;\n if (result == null) {\n result = keySet = new KeySet();\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":459,"symbol":"Node","kind":"class","lang":"java","code":"static final class Node implements Entry {\n Node parent;\n Node left;\n Node right;\n Node next;\n Node prev;\n final K key;\n final boolean allowNullValue;\n V value;\n int height;\n\n /** Create the header entry */\n Node(boolean allowNullValue) {\n key = null;\n this.allowNullValue = allowNullValue;\n next = prev = this;\n }\n\n /** Create a regular entry */\n Node(boolean allowNullValue, Node parent, K key, Node next, Node prev) {\n this.parent = parent;\n this.key = key;\n this.allowNullValue = allowNullValue;\n this.height = 1;\n this.next = next;\n this.prev = prev;\n prev.next = this;\n next.prev = this;\n }\n\n @Override\n public K getKey() {\n return key;\n }\n\n @Override\n public V getValue() {\n return value;\n }\n\n @Override\n public V setValue(V value) {\n if (value == null && !allowNullValue) {\n throw new NullPointerException(\"value == null\");\n }\n V oldValue = this.value;\n this.value = value;\n return oldValue;\n }\n\n @Override\n public boolean equals(Object o) {\n if (o ins"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":471,"symbol":"Node","kind":"constructor","lang":"java","doc":"Create the header entry","code":"Node(boolean allowNullValue) {\n key = null;\n this.allowNullValue = allowNullValue;\n next = prev = this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":478,"symbol":"Node","kind":"constructor","lang":"java","doc":"Create a regular entry","code":"Node(boolean allowNullValue, Node parent, K key, Node next, Node prev) {\n this.parent = parent;\n this.key = key;\n this.allowNullValue = allowNullValue;\n this.height = 1;\n this.next = next;\n this.prev = prev;\n prev.next = this;\n next.prev = this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":489,"symbol":"getKey","kind":"method","lang":"java","code":"@Override\n public K getKey() {\n return key;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":494,"symbol":"getValue","kind":"method","lang":"java","code":"@Override\n public V getValue() {\n return value;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":499,"symbol":"setValue","kind":"method","lang":"java","code":"@Override\n public V setValue(V value) {\n if (value == null && !allowNullValue) {\n throw new NullPointerException(\"value == null\");\n }\n V oldValue = this.value;\n this.value = value;\n return oldValue;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":509,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object o) {\n if (o instanceof Entry) {\n Entry other = (Entry) o;\n return (key == null ? other.getKey() == null : key.equals(other.getKey()))\n && (value == null ? other.getValue() == null : value.equals(other.getValue()));\n }\n return false;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":519,"symbol":"hashCode","kind":"method","lang":"java","code":"@Override\n public int hashCode() {\n return (key == null ? 0 : key.hashCode()) ^ (value == null ? 0 : value.hashCode());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":524,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return key + \"=\" + value;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":530,"symbol":"first","kind":"method","lang":"java","doc":"Returns the first node in this subtree.","code":"public Node first() {\n Node node = this;\n Node child = node.left;\n while (child != null) {\n node = child;\n child = node.left;\n }\n return node;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":541,"symbol":"last","kind":"method","lang":"java","doc":"Returns the last node in this subtree.","code":"public Node last() {\n Node node = this;\n Node child = node.right;\n while (child != null) {\n node = child;\n child = node.right;\n }\n return node;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":552,"symbol":"LinkedTreeMapIterator","kind":"class","lang":"java","code":"private abstract class LinkedTreeMapIterator implements Iterator {\n Node next = header.next;\n Node lastReturned = null;\n int expectedModCount = modCount;\n\n LinkedTreeMapIterator() {}\n\n @Override\n @SuppressWarnings(\"ReferenceEquality\")\n public final boolean hasNext() {\n return next != header;\n }\n\n @SuppressWarnings(\"ReferenceEquality\")\n final Node nextNode() {\n Node e = next;\n if (e == header) {\n throw new NoSuchElementException();\n }\n if (modCount != expectedModCount) {\n throw new ConcurrentModificationException();\n }\n next = e.next;\n lastReturned = e;\n return e;\n }\n\n @Override\n public final void remove() {\n if (lastReturned == null) {\n throw new IllegalStateException();\n }\n removeInternal(lastReturned, true);\n lastReturned = null;\n expectedModCount = modCount;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":557,"symbol":"LinkedTreeMapIterator","kind":"constructor","lang":"java","code":"LinkedTreeMapIterator() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":559,"symbol":"hasNext","kind":"method","lang":"java","code":"@Override\n @SuppressWarnings(\"ReferenceEquality\")\n public final boolean hasNext() {\n return next != header;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":565,"symbol":"nextNode","kind":"method","lang":"java","code":"@SuppressWarnings(\"ReferenceEquality\")\n final Node nextNode() {\n Node e = next;\n if (e == header) {\n throw new NoSuchElementException();\n }\n if (modCount != expectedModCount) {\n throw new ConcurrentModificationException();\n }\n next = e.next;\n lastReturned = e;\n return e;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":579,"symbol":"remove","kind":"method","lang":"java","code":"@Override\n public final void remove() {\n if (lastReturned == null) {\n throw new IllegalStateException();\n }\n removeInternal(lastReturned, true);\n lastReturned = null;\n expectedModCount = modCount;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":590,"symbol":"EntrySet","kind":"class","lang":"java","code":"class EntrySet extends AbstractSet> {\n @Override\n public int size() {\n return size;\n }\n\n @Override\n public Iterator> iterator() {\n return new LinkedTreeMapIterator>() {\n @Override\n public Entry next() {\n return nextNode();\n }\n };\n }\n\n @Override\n public boolean contains(Object o) {\n return o instanceof Entry && findByEntry((Entry) o) != null;\n }\n\n @Override\n public boolean remove(Object o) {\n if (!(o instanceof Entry)) {\n return false;\n }\n\n Node node = findByEntry((Entry) o);\n if (node == null) {\n return false;\n }\n removeInternal(node, true);\n return true;\n }\n\n @Override\n public void clear() {\n LinkedTreeMap.this.clear();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":591,"symbol":"size","kind":"method","lang":"java","code":"@Override\n public int size() {\n return size;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":596,"symbol":"iterator","kind":"method","lang":"java","code":"@Override\n public Iterator> iterator() {\n return new LinkedTreeMapIterator>() {\n @Override\n public Entry next() {\n return nextNode();\n }\n };\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":599,"symbol":"next","kind":"method","lang":"java","code":"@Override\n public Entry next() {\n return nextNode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":606,"symbol":"contains","kind":"method","lang":"java","code":"@Override\n public boolean contains(Object o) {\n return o instanceof Entry && findByEntry((Entry) o) != null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":611,"symbol":"remove","kind":"method","lang":"java","code":"@Override\n public boolean remove(Object o) {\n if (!(o instanceof Entry)) {\n return false;\n }\n\n Node node = findByEntry((Entry) o);\n if (node == null) {\n return false;\n }\n removeInternal(node, true);\n return true;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":625,"symbol":"clear","kind":"method","lang":"java","code":"@Override\n public void clear() {\n LinkedTreeMap.this.clear();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":631,"symbol":"KeySet","kind":"class","lang":"java","code":"final class KeySet extends AbstractSet {\n @Override\n public int size() {\n return size;\n }\n\n @Override\n public Iterator iterator() {\n return new LinkedTreeMapIterator() {\n @Override\n public K next() {\n return nextNode().key;\n }\n };\n }\n\n @Override\n public boolean contains(Object o) {\n return containsKey(o);\n }\n\n @Override\n public boolean remove(Object key) {\n return removeInternalByKey(key) != null;\n }\n\n @Override\n public void clear() {\n LinkedTreeMap.this.clear();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":632,"symbol":"size","kind":"method","lang":"java","code":"@Override\n public int size() {\n return size;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":637,"symbol":"iterator","kind":"method","lang":"java","code":"@Override\n public Iterator iterator() {\n return new LinkedTreeMapIterator() {\n @Override\n public K next() {\n return nextNode().key;\n }\n };\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":640,"symbol":"next","kind":"method","lang":"java","code":"@Override\n public K next() {\n return nextNode().key;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":647,"symbol":"contains","kind":"method","lang":"java","code":"@Override\n public boolean contains(Object o) {\n return containsKey(o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":652,"symbol":"remove","kind":"method","lang":"java","code":"@Override\n public boolean remove(Object key) {\n return removeInternalByKey(key) != null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":657,"symbol":"clear","kind":"method","lang":"java","code":"@Override\n public void clear() {\n LinkedTreeMap.this.clear();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":668,"symbol":"writeReplace","kind":"method","lang":"java","doc":"If somebody is unlucky enough to have to serialize one of these, serialize it as a LinkedHashMap so that they won't need Gson on the other side to deserialize it. Using serialization defeats our DoS defense, so most apps shouldn't use it.","code":"private Object writeReplace() throws ObjectStreamException {\n return new LinkedHashMap<>(this);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java","line":672,"symbol":"readObject","kind":"method","lang":"java","code":"private void readObject(ObjectInputStream in) throws IOException {\n // Don't permit directly deserializing this class; writeReplace() should have written a\n // replacement\n throw new InvalidObjectException(\"Deserialization is unsupported\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":34,"symbol":"NonNullElementWrapperList","kind":"class","lang":"java","doc":"{@link List} which wraps another {@code List} but prevents insertion of {@code null} elements. Methods which only perform checks with the element argument (e.g. {@link #contains(Object)}) do not throw exceptions for {@code null} arguments.","code":"public class NonNullElementWrapperList extends AbstractList implements RandomAccess {\n // Explicitly specify ArrayList as type to guarantee that delegate implements RandomAccess\n private final ArrayList delegate;\n\n @SuppressWarnings(\"NonApiType\")\n public NonNullElementWrapperList(ArrayList delegate) {\n this.delegate = Objects.requireNonNull(delegate);\n }\n\n @Override\n public E get(int index) {\n return delegate.get(index);\n }\n\n @Override\n public int size() {\n return delegate.size();\n }\n\n private E nonNull(E element) {\n if (element == null) {\n throw new NullPointerException(\"Element must be non-null\");\n }\n return element;\n }\n\n @Override\n public E set(int index, E element) {\n return delegate.set(index, nonNull(element));\n }\n\n @Override\n public void add(int index, E element) {\n delegate.add(index, nonNull(element));\n }\n\n @Override\n public E remove(int index) {\n return delegate.remove(index);\n }\n\n /* The following methods are overridden because their default implementation is inefficient */\n\n @Override\n public void clear() {\n delegate.clear();\n }\n\n @SuppressWarnings(\"UngroupedOverloads\") // this is intentionally un"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":38,"symbol":"NonNullElementWrapperList","kind":"constructor","lang":"java","code":"@SuppressWarnings(\"NonApiType\")\n public NonNullElementWrapperList(ArrayList delegate) {\n this.delegate = Objects.requireNonNull(delegate);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":43,"symbol":"get","kind":"method","lang":"java","code":"@Override\n public E get(int index) {\n return delegate.get(index);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":48,"symbol":"size","kind":"method","lang":"java","code":"@Override\n public int size() {\n return delegate.size();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":53,"symbol":"nonNull","kind":"method","lang":"java","code":"private E nonNull(E element) {\n if (element == null) {\n throw new NullPointerException(\"Element must be non-null\");\n }\n return element;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":60,"symbol":"set","kind":"method","lang":"java","code":"@Override\n public E set(int index, E element) {\n return delegate.set(index, nonNull(element));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":65,"symbol":"add","kind":"method","lang":"java","code":"@Override\n public void add(int index, E element) {\n delegate.add(index, nonNull(element));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":70,"symbol":"remove","kind":"method","lang":"java","code":"@Override\n public E remove(int index) {\n return delegate.remove(index);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":77,"symbol":"clear","kind":"method","lang":"java","code":"@Override\n public void clear() {\n delegate.clear();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":82,"symbol":"remove","kind":"method","lang":"java","code":"@SuppressWarnings(\"UngroupedOverloads\") // this is intentionally ungrouped, see comment above\n @Override\n public boolean remove(Object o) {\n return delegate.remove(o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":88,"symbol":"removeAll","kind":"method","lang":"java","code":"@Override\n public boolean removeAll(Collection c) {\n return delegate.removeAll(c);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":93,"symbol":"retainAll","kind":"method","lang":"java","code":"@Override\n public boolean retainAll(Collection c) {\n return delegate.retainAll(c);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":98,"symbol":"removeIf","kind":"method","lang":"java","code":"@Override\n public boolean removeIf(Predicate filter) {\n return delegate.removeIf(filter);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":103,"symbol":"contains","kind":"method","lang":"java","code":"@Override\n public boolean contains(Object o) {\n return delegate.contains(o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":108,"symbol":"indexOf","kind":"method","lang":"java","code":"@Override\n public int indexOf(Object o) {\n return delegate.indexOf(o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":113,"symbol":"lastIndexOf","kind":"method","lang":"java","code":"@Override\n public int lastIndexOf(Object o) {\n return delegate.lastIndexOf(o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":118,"symbol":"toArray","kind":"method","lang":"java","code":"@Override\n public Object[] toArray() {\n return delegate.toArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":123,"symbol":"toArray","kind":"method","lang":"java","code":"@Override\n public T[] toArray(T[] a) {\n return delegate.toArray(a);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":128,"symbol":"sort","kind":"method","lang":"java","code":"@Override\n public void sort(Comparator c) {\n delegate.sort(c);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":133,"symbol":"spliterator","kind":"method","lang":"java","code":"@Override\n public Spliterator spliterator() {\n return delegate.spliterator();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":138,"symbol":"equals","kind":"method","lang":"java","code":"@Override\n public boolean equals(Object o) {\n return delegate.equals(o);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java","line":143,"symbol":"hashCode","kind":"method","lang":"java","code":"@Override\n public int hashCode() {\n return delegate.hashCode();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NumberLimits.java","line":10,"symbol":"NumberLimits","kind":"class","lang":"java","doc":"This class enforces limits on numbers parsed from JSON to avoid potential performance problems when extremely large numbers are used.","code":"public final class NumberLimits {\n private NumberLimits() {}\n\n private static final int MAX_NUMBER_STRING_LENGTH = 10_000;\n\n private static void checkNumberStringLength(String s) {\n if (s.length() > MAX_NUMBER_STRING_LENGTH) {\n throw new NumberFormatException(\"Number string too large: \" + s.substring(0, 30) + \"...\");\n }\n }\n\n public static BigDecimal parseBigDecimal(String s) throws NumberFormatException {\n checkNumberStringLength(s);\n BigDecimal decimal = new BigDecimal(s);\n\n // Cast to long to avoid issues with abs when value is Integer.MIN_VALUE\n if (Math.abs((long) decimal.scale()) >= 10_000) {\n throw new NumberFormatException(\"Number has unsupported scale: \" + s);\n }\n return decimal;\n }\n\n public static BigInteger parseBigInteger(String s) throws NumberFormatException {\n checkNumberStringLength(s);\n return new BigInteger(s);\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NumberLimits.java","line":11,"symbol":"NumberLimits","kind":"constructor","lang":"java","code":"private NumberLimits() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NumberLimits.java","line":15,"symbol":"checkNumberStringLength","kind":"method","lang":"java","code":"private static void checkNumberStringLength(String s) {\n if (s.length() > MAX_NUMBER_STRING_LENGTH) {\n throw new NumberFormatException(\"Number string too large: \" + s.substring(0, 30) + \"...\");\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NumberLimits.java","line":21,"symbol":"parseBigDecimal","kind":"method","lang":"java","code":"public static BigDecimal parseBigDecimal(String s) throws NumberFormatException {\n checkNumberStringLength(s);\n BigDecimal decimal = new BigDecimal(s);\n\n // Cast to long to avoid issues with abs when value is Integer.MIN_VALUE\n if (Math.abs((long) decimal.scale()) >= 10_000) {\n throw new NumberFormatException(\"Number has unsupported scale: \" + s);\n }\n return decimal;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/NumberLimits.java","line":32,"symbol":"parseBigInteger","kind":"method","lang":"java","code":"public static BigInteger parseBigInteger(String s) throws NumberFormatException {\n checkNumberStringLength(s);\n return new BigInteger(s);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ObjectConstructor.java","line":27,"symbol":"ObjectConstructor","kind":"interface","lang":"java","doc":"default instance of a class that can be used for object navigation while deserialization from its JSON representation. @author Inderjeet Singh @author Joel Leitch","code":"public interface ObjectConstructor {\n\n /** Returns a new instance. */\n T construct();\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ObjectConstructor.java","line":30,"symbol":"construct","kind":"method","lang":"java","doc":"Returns a new instance.","code":"T construct();"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java","line":23,"symbol":"PreJava9DateFormatProvider","kind":"class","lang":"java","doc":"Provides DateFormats for US locale with patterns which were the default ones before Java 9.","code":"public final class PreJava9DateFormatProvider {\n private PreJava9DateFormatProvider() {}\n\n /**\n * Returns the same DateFormat as {@code DateFormat.getDateTimeInstance(dateStyle, timeStyle,\n * Locale.US)} in Java 8 or below.\n */\n public static DateFormat getUsDateTimeFormat(int dateStyle, int timeStyle) {\n String pattern =\n getDatePartOfDateTimePattern(dateStyle) + \" \" + getTimePartOfDateTimePattern(timeStyle);\n return new SimpleDateFormat(pattern, Locale.US);\n }\n\n private static String getDatePartOfDateTimePattern(int dateStyle) {\n switch (dateStyle) {\n case DateFormat.SHORT:\n return \"M/d/yy\";\n case DateFormat.MEDIUM:\n return \"MMM d, yyyy\";\n case DateFormat.LONG:\n return \"MMMM d, yyyy\";\n case DateFormat.FULL:\n return \"EEEE, MMMM d, yyyy\";\n default:\n throw new IllegalArgumentException(\"Unknown DateFormat style: \" + dateStyle);\n }\n }\n\n private static String getTimePartOfDateTimePattern(int timeStyle) {\n switch (timeStyle) {\n case DateFormat.SHORT:\n return \"h:mm a\";\n case DateFormat.MEDIUM:\n return \"h:mm:ss a\";\n case DateFormat.FULL:\n case DateFormat.LONG:\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java","line":24,"symbol":"PreJava9DateFormatProvider","kind":"constructor","lang":"java","code":"private PreJava9DateFormatProvider() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java","line":30,"symbol":"getUsDateTimeFormat","kind":"method","lang":"java","doc":"Returns the same DateFormat as {@code DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.US)} in Java 8 or below.","code":"public static DateFormat getUsDateTimeFormat(int dateStyle, int timeStyle) {\n String pattern =\n getDatePartOfDateTimePattern(dateStyle) + \" \" + getTimePartOfDateTimePattern(timeStyle);\n return new SimpleDateFormat(pattern, Locale.US);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java","line":36,"symbol":"getDatePartOfDateTimePattern","kind":"method","lang":"java","code":"private static String getDatePartOfDateTimePattern(int dateStyle) {\n switch (dateStyle) {\n case DateFormat.SHORT:\n return \"M/d/yy\";\n case DateFormat.MEDIUM:\n return \"MMM d, yyyy\";\n case DateFormat.LONG:\n return \"MMMM d, yyyy\";\n case DateFormat.FULL:\n return \"EEEE, MMMM d, yyyy\";\n default:\n throw new IllegalArgumentException(\"Unknown DateFormat style: \" + dateStyle);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java","line":51,"symbol":"getTimePartOfDateTimePattern","kind":"method","lang":"java","code":"private static String getTimePartOfDateTimePattern(int timeStyle) {\n switch (timeStyle) {\n case DateFormat.SHORT:\n return \"h:mm a\";\n case DateFormat.MEDIUM:\n return \"h:mm:ss a\";\n case DateFormat.FULL:\n case DateFormat.LONG:\n return \"h:mm:ss a z\";\n default:\n throw new IllegalArgumentException(\"Unknown DateFormat style: \" + timeStyle);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Primitives.java","line":27,"symbol":"Primitives","kind":"class","lang":"java","doc":"Contains static utility methods pertaining to primitive types and their corresponding wrapper types. @author Kevin Bourrillion","code":"public final class Primitives {\n private Primitives() {}\n\n /** Returns true if this type is a primitive. */\n public static boolean isPrimitive(Type type) {\n return type instanceof Class && ((Class) type).isPrimitive();\n }\n\n /**\n * Returns {@code true} if {@code type} is one of the nine primitive-wrapper types, such as {@link\n * Integer}.\n *\n * @see Class#isPrimitive\n */\n public static boolean isWrapperType(Type type) {\n return type == Integer.class\n || type == Float.class\n || type == Byte.class\n || type == Double.class\n || type == Long.class\n || type == Character.class\n || type == Boolean.class\n || type == Short.class\n || type == Void.class;\n }\n\n /**\n * Returns the corresponding wrapper type of {@code type} if it is a primitive type; otherwise\n * returns {@code type} itself. Idempotent.\n *\n *

    \n   *     wrap(int.class) == Integer.class\n   *     wrap(Integer.class) == Integer.class\n   *     wrap(String.class) == String.class\n   * 
    \n */\n @SuppressWarnings({\"unchecked\", \"MissingBraces\"})\n public static Class wrap(Class type) {\n if (type == int.class) return (Class"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Primitives.java","line":28,"symbol":"Primitives","kind":"constructor","lang":"java","code":"private Primitives() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Primitives.java","line":31,"symbol":"isPrimitive","kind":"method","lang":"java","doc":"Returns true if this type is a primitive.","code":"public static boolean isPrimitive(Type type) {\n return type instanceof Class && ((Class) type).isPrimitive();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Primitives.java","line":41,"symbol":"isWrapperType","kind":"method","lang":"java","doc":"Returns {@code true} if {@code type} is one of the nine primitive-wrapper types, such as {@link Integer}. @see Class#isPrimitive","code":"public static boolean isWrapperType(Type type) {\n return type == Integer.class\n || type == Float.class\n || type == Byte.class\n || type == Double.class\n || type == Long.class\n || type == Character.class\n || type == Boolean.class\n || type == Short.class\n || type == Void.class;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Primitives.java","line":63,"symbol":"wrap","kind":"method","lang":"java","doc":"
     wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class 
    ","code":"@SuppressWarnings({\"unchecked\", \"MissingBraces\"})\n public static Class wrap(Class type) {\n if (type == int.class) return (Class) Integer.class;\n if (type == float.class) return (Class) Float.class;\n if (type == byte.class) return (Class) Byte.class;\n if (type == double.class) return (Class) Double.class;\n if (type == long.class) return (Class) Long.class;\n if (type == char.class) return (Class) Character.class;\n if (type == boolean.class) return (Class) Boolean.class;\n if (type == short.class) return (Class) Short.class;\n if (type == void.class) return (Class) Void.class;\n return type;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Primitives.java","line":87,"symbol":"unwrap","kind":"method","lang":"java","doc":"
     unwrap(Integer.class) == int.class unwrap(int.class) == int.class unwrap(String.class) == String.class 
    ","code":"@SuppressWarnings({\"unchecked\", \"MissingBraces\"})\n public static Class unwrap(Class type) {\n if (type == Integer.class) return (Class) int.class;\n if (type == Float.class) return (Class) float.class;\n if (type == Byte.class) return (Class) byte.class;\n if (type == Double.class) return (Class) double.class;\n if (type == Long.class) return (Class) long.class;\n if (type == Character.class) return (Class) char.class;\n if (type == Boolean.class) return (Class) boolean.class;\n if (type == Short.class) return (Class) short.class;\n if (type == Void.class) return (Class) void.class;\n return type;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":26,"symbol":"ReflectionAccessFilterHelper","kind":"class","lang":"java","doc":"Internal helper class for {@link ReflectionAccessFilter}.","code":"public final class ReflectionAccessFilterHelper {\n private ReflectionAccessFilterHelper() {}\n\n // Platform type detection is based on Moshi's Util.isPlatformType(Class)\n // See\n // https://github.com/square/moshi/blob/3c108919ee1cce88a433ffda04eeeddc0341eae7/moshi/src/main/java/com/squareup/moshi/internal/Util.java#L141\n\n public static boolean isJavaType(Class c) {\n return isJavaType(c.getName());\n }\n\n private static boolean isJavaType(String className) {\n return className.startsWith(\"java.\") || className.startsWith(\"javax.\");\n }\n\n public static boolean isAndroidType(Class c) {\n return isAndroidType(c.getName());\n }\n\n private static boolean isAndroidType(String className) {\n return className.startsWith(\"android.\")\n || className.startsWith(\"androidx.\")\n || isJavaType(className);\n }\n\n public static boolean isAnyPlatformType(Class c) {\n String className = c.getName();\n return isAndroidType(className) // Covers Android and Java\n || className.startsWith(\"kotlin.\")\n || className.startsWith(\"kotlinx.\")\n || className.startsWith(\"scala.\");\n }\n\n /**\n * Gets the result of applying all filters until the first one re"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":27,"symbol":"ReflectionAccessFilterHelper","kind":"constructor","lang":"java","code":"private ReflectionAccessFilterHelper() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":33,"symbol":"isJavaType","kind":"method","lang":"java","code":"public static boolean isJavaType(Class c) {\n return isJavaType(c.getName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":37,"symbol":"isJavaType","kind":"method","lang":"java","code":"private static boolean isJavaType(String className) {\n return className.startsWith(\"java.\") || className.startsWith(\"javax.\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":41,"symbol":"isAndroidType","kind":"method","lang":"java","code":"public static boolean isAndroidType(Class c) {\n return isAndroidType(c.getName());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":45,"symbol":"isAndroidType","kind":"method","lang":"java","code":"private static boolean isAndroidType(String className) {\n return className.startsWith(\"android.\")\n || className.startsWith(\"androidx.\")\n || isJavaType(className);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":51,"symbol":"isAnyPlatformType","kind":"method","lang":"java","code":"public static boolean isAnyPlatformType(Class c) {\n String className = c.getName();\n return isAndroidType(className) // Covers Android and Java\n || className.startsWith(\"kotlin.\")\n || className.startsWith(\"kotlinx.\")\n || className.startsWith(\"scala.\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":64,"symbol":"getFilterResult","kind":"method","lang":"java","doc":"Gets the result of applying all filters until the first one returns a result other than {@link FilterResult#INDECISIVE}, or {@link FilterResult#ALLOW} if the list of filters is empty or all returned {@code INDECISIVE}.","code":"public static FilterResult getFilterResult(\n List reflectionFilters, Class c) {\n for (ReflectionAccessFilter filter : reflectionFilters) {\n FilterResult result = filter.check(c);\n if (result != FilterResult.INDECISIVE) {\n return result;\n }\n }\n return FilterResult.ALLOW;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":76,"symbol":"canAccess","kind":"method","lang":"java","doc":"See {@link AccessibleObject#canAccess(Object)} (Java >= 9)","code":"@SuppressWarnings(\"InvalidLink\") // suppress Error Prone warning about link to Java 9 method\n public static boolean canAccess(AccessibleObject accessibleObject, Object object) {\n return AccessChecker.INSTANCE.canAccess(accessibleObject, object);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":81,"symbol":"AccessChecker","kind":"class","lang":"java","code":"private abstract static class AccessChecker {\n static final AccessChecker INSTANCE;\n\n static {\n AccessChecker accessChecker = null;\n // TODO: Ideally should use Multi-Release JAR for this version specific code\n if (JavaVersion.isJava9OrLater()) {\n try {\n Method canAccessMethod =\n AccessibleObject.class.getDeclaredMethod(\"canAccess\", Object.class);\n accessChecker =\n new AccessChecker() {\n @Override\n public boolean canAccess(AccessibleObject accessibleObject, Object object) {\n try {\n return (Boolean) canAccessMethod.invoke(accessibleObject, object);\n } catch (Exception e) {\n throw new RuntimeException(\"Failed invoking canAccess\", e);\n }\n }\n };\n } catch (NoSuchMethodException ignored) {\n // OK: will assume everything is accessible\n }\n }\n\n if (accessChecker == null) {\n accessChecker =\n new AccessChecker() {\n @Override\n public boolean canAccess(AccessibleObject accessibleObject, Object object) {\n"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":93,"symbol":"canAccess","kind":"method","lang":"java","code":"@Override\n public boolean canAccess(AccessibleObject accessibleObject, Object object) {\n try {\n return (Boolean) canAccessMethod.invoke(accessibleObject, object);\n } catch (Exception e) {\n throw new RuntimeException(\"Failed invoking canAccess\", e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":110,"symbol":"canAccess","kind":"method","lang":"java","code":"@Override\n public boolean canAccess(AccessibleObject accessibleObject, Object object) {\n // Cannot determine whether object can be accessed, so assume it can be accessed\n return true;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java","line":120,"symbol":"canAccess","kind":"method","lang":"java","code":"abstract boolean canAccess(AccessibleObject accessibleObject, Object object);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":37,"symbol":"Streams","kind":"class","lang":"java","doc":"Reads and writes GSON parse trees over streams.","code":"public final class Streams {\n private Streams() {\n throw new UnsupportedOperationException();\n }\n\n /** Takes a reader in any state and returns the next value as a JsonElement. */\n public static JsonElement parse(JsonReader reader) throws JsonParseException {\n boolean isEmpty = true;\n try {\n JsonToken unused = reader.peek();\n isEmpty = false;\n return JsonElementTypeAdapter.ADAPTER.read(reader);\n } catch (EOFException e) {\n /*\n * For compatibility with JSON 1.5 and earlier, we return a JsonNull for\n * empty documents instead of throwing.\n */\n if (isEmpty) {\n return JsonNull.INSTANCE;\n }\n // The stream ended prematurely so it is likely a syntax error.\n throw new JsonSyntaxException(e);\n } catch (MalformedJsonException e) {\n throw new JsonSyntaxException(e);\n } catch (IOException e) {\n throw new JsonIOException(e);\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n }\n\n /** Writes the JSON element to the writer, recursively. */\n public static void write(JsonElement element, JsonWriter writer) throws IOException {\n JsonElementTypeAdapter.ADAPTER.write"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":38,"symbol":"Streams","kind":"constructor","lang":"java","code":"private Streams() {\n throw new UnsupportedOperationException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":43,"symbol":"parse","kind":"method","lang":"java","doc":"Takes a reader in any state and returns the next value as a JsonElement.","code":"public static JsonElement parse(JsonReader reader) throws JsonParseException {\n boolean isEmpty = true;\n try {\n JsonToken unused = reader.peek();\n isEmpty = false;\n return JsonElementTypeAdapter.ADAPTER.read(reader);\n } catch (EOFException e) {\n /*\n * For compatibility with JSON 1.5 and earlier, we return a JsonNull for\n * empty documents instead of throwing.\n */\n if (isEmpty) {\n return JsonNull.INSTANCE;\n }\n // The stream ended prematurely so it is likely a syntax error.\n throw new JsonSyntaxException(e);\n } catch (MalformedJsonException e) {\n throw new JsonSyntaxException(e);\n } catch (IOException e) {\n throw new JsonIOException(e);\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":69,"symbol":"write","kind":"method","lang":"java","doc":"Writes the JSON element to the writer, recursively.","code":"public static void write(JsonElement element, JsonWriter writer) throws IOException {\n JsonElementTypeAdapter.ADAPTER.write(writer, element);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":73,"symbol":"writerForAppendable","kind":"method","lang":"java","code":"public static Writer writerForAppendable(Appendable appendable) {\n return appendable instanceof Writer ? (Writer) appendable : new AppendableWriter(appendable);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":78,"symbol":"AppendableWriter","kind":"class","lang":"java","doc":"Adapts an {@link Appendable} so it can be passed anywhere a {@link Writer} is used.","code":"private static final class AppendableWriter extends Writer {\n private final Appendable appendable;\n private final CurrentWrite currentWrite = new CurrentWrite();\n\n AppendableWriter(Appendable appendable) {\n this.appendable = appendable;\n }\n\n @SuppressWarnings(\"UngroupedOverloads\") // this is intentionally ungrouped, see comment below\n @Override\n public void write(char[] chars, int offset, int length) throws IOException {\n currentWrite.setChars(chars);\n appendable.append(currentWrite, offset, offset + length);\n }\n\n @Override\n public void flush() throws IOException {\n if (appendable instanceof Flushable) {\n ((Flushable) appendable).flush();\n }\n }\n\n @Override\n public void close() throws IOException {\n if (appendable instanceof Closeable) {\n ((Closeable) appendable).close();\n }\n }\n\n // Override these methods for better performance\n // They would otherwise unnecessarily create Strings or char arrays\n\n @Override\n public void write(int i) throws IOException {\n appendable.append((char) i);\n }\n\n @Override\n public void write(String str, int off, int len) throws IOException {\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":82,"symbol":"AppendableWriter","kind":"constructor","lang":"java","code":"AppendableWriter(Appendable appendable) {\n this.appendable = appendable;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":86,"symbol":"write","kind":"method","lang":"java","code":"@SuppressWarnings(\"UngroupedOverloads\") // this is intentionally ungrouped, see comment below\n @Override\n public void write(char[] chars, int offset, int length) throws IOException {\n currentWrite.setChars(chars);\n appendable.append(currentWrite, offset, offset + length);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":93,"symbol":"flush","kind":"method","lang":"java","code":"@Override\n public void flush() throws IOException {\n if (appendable instanceof Flushable) {\n ((Flushable) appendable).flush();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":100,"symbol":"close","kind":"method","lang":"java","code":"@Override\n public void close() throws IOException {\n if (appendable instanceof Closeable) {\n ((Closeable) appendable).close();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":110,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(int i) throws IOException {\n appendable.append((char) i);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":115,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(String str, int off, int len) throws IOException {\n // Appendable.append turns null -> \"null\", which is not desired here\n Objects.requireNonNull(str);\n appendable.append(str, off, off + len);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":122,"symbol":"append","kind":"method","lang":"java","code":"@Override\n public Writer append(CharSequence csq) throws IOException {\n appendable.append(csq);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":128,"symbol":"append","kind":"method","lang":"java","code":"@Override\n public Writer append(CharSequence csq, int start, int end) throws IOException {\n appendable.append(csq, start, end);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":135,"symbol":"CurrentWrite","kind":"class","lang":"java","doc":"A mutable char sequence pointing at a single char[].","code":"private static class CurrentWrite implements CharSequence {\n private char[] chars;\n private String cachedString;\n\n void setChars(char[] chars) {\n this.chars = chars;\n this.cachedString = null;\n }\n\n @Override\n public int length() {\n return chars.length;\n }\n\n @Override\n public char charAt(int i) {\n return chars[i];\n }\n\n @Override\n public CharSequence subSequence(int start, int end) {\n return new String(chars, start, end - start);\n }\n\n // Must return string representation to satisfy toString() contract\n @Override\n public String toString() {\n if (cachedString == null) {\n cachedString = new String(chars);\n }\n return cachedString;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":139,"symbol":"setChars","kind":"method","lang":"java","code":"void setChars(char[] chars) {\n this.chars = chars;\n this.cachedString = null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":144,"symbol":"length","kind":"method","lang":"java","code":"@Override\n public int length() {\n return chars.length;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":149,"symbol":"charAt","kind":"method","lang":"java","code":"@Override\n public char charAt(int i) {\n return chars[i];\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":154,"symbol":"subSequence","kind":"method","lang":"java","code":"@Override\n public CharSequence subSequence(int start, int end) {\n return new String(chars, start, end - start);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/Streams.java","line":160,"symbol":"toString","kind":"method","lang":"java","doc":"Must return string representation to satisfy toString() contract","code":"@Override\n public String toString() {\n if (cachedString == null) {\n cachedString = new String(chars);\n }\n return cachedString;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/TroubleshootingGuide.java","line":3,"symbol":"TroubleshootingGuide","kind":"class","lang":"java","code":"public final class TroubleshootingGuide {\n private TroubleshootingGuide() {}\n\n /** Creates a URL referring to the specified troubleshooting section. */\n public static String createUrl(String id) {\n return \"https://github.com/google/gson/blob/main/Troubleshooting.md#\" + id;\n }\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/TroubleshootingGuide.java","line":4,"symbol":"TroubleshootingGuide","kind":"constructor","lang":"java","code":"private TroubleshootingGuide() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/TroubleshootingGuide.java","line":7,"symbol":"createUrl","kind":"method","lang":"java","doc":"Creates a URL referring to the specified troubleshooting section.","code":"public static String createUrl(String id) {\n return \"https://github.com/google/gson/blob/main/Troubleshooting.md#\" + id;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":30,"symbol":"UnsafeAllocator","kind":"class","lang":"java","doc":"Do sneaky things to allocate objects without invoking their constructors. @author Joel Leitch @author Jesse Wilson","code":"public abstract class UnsafeAllocator {\n public abstract T newInstance(Class c) throws Exception;\n\n /**\n * Asserts that the class is instantiable. This check should have already occurred in {@link\n * ConstructorConstructor}; this check here acts as safeguard since trying to use Unsafe for\n * non-instantiable classes might crash the JVM on some devices.\n */\n private static void assertInstantiable(Class c) {\n String exceptionMessage = ConstructorConstructor.checkInstantiable(c);\n if (exceptionMessage != null) {\n throw new AssertionError(\n \"UnsafeAllocator is used for non-instantiable type: \" + exceptionMessage);\n }\n }\n\n public static final UnsafeAllocator INSTANCE = create();\n\n private static UnsafeAllocator create() {\n // try JVM\n // public class Unsafe {\n // public Object allocateInstance(Class type);\n // }\n try {\n Class unsafeClass = Class.forName(\"sun.misc.Unsafe\");\n Field f = unsafeClass.getDeclaredField(\"theUnsafe\");\n f.setAccessible(true);\n Object unsafe = f.get(null);\n Method allocateInstance = unsafeClass.getMethod(\"allocateInstance\", Class.class);\n return new UnsafeAllocator("} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":31,"symbol":"newInstance","kind":"method","lang":"java","code":"public abstract T newInstance(Class c) throws Exception;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":38,"symbol":"assertInstantiable","kind":"method","lang":"java","doc":"Asserts that the class is instantiable. This check should have already occurred in {@link ConstructorConstructor}; this check here acts as safeguard since trying to use Unsafe for non-instantiable classes might crash the JVM on some devices.","code":"private static void assertInstantiable(Class c) {\n String exceptionMessage = ConstructorConstructor.checkInstantiable(c);\n if (exceptionMessage != null) {\n throw new AssertionError(\n \"UnsafeAllocator is used for non-instantiable type: \" + exceptionMessage);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":48,"symbol":"create","kind":"method","lang":"java","code":"private static UnsafeAllocator create() {\n // try JVM\n // public class Unsafe {\n // public Object allocateInstance(Class type);\n // }\n try {\n Class unsafeClass = Class.forName(\"sun.misc.Unsafe\");\n Field f = unsafeClass.getDeclaredField(\"theUnsafe\");\n f.setAccessible(true);\n Object unsafe = f.get(null);\n Method allocateInstance = unsafeClass.getMethod(\"allocateInstance\", Class.class);\n return new UnsafeAllocator() {\n @Override\n @SuppressWarnings(\"unchecked\")\n public T newInstance(Class c) throws Exception {\n assertInstantiable(c);\n return (T) allocateInstance.invoke(unsafe, c);\n }\n };\n } catch (Exception ignored) {\n // OK: try the next way\n }\n\n // try dalvikvm, post-gingerbread\n // public class ObjectStreamClass {\n // private static native int getConstructorId(Class c);\n // private static native Object newInstance(Class instantiationClass, int methodId);\n // }\n try {\n Method getConstructorId =\n ObjectStreamClass.class.getDeclaredMethod(\"getConstructorId\", Class.class);\n getConstructorId.setAccessible(true);\n int"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":60,"symbol":"newInstance","kind":"method","lang":"java","code":"@Override\n @SuppressWarnings(\"unchecked\")\n public T newInstance(Class c) throws Exception {\n assertInstantiable(c);\n return (T) allocateInstance.invoke(unsafe, c);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":85,"symbol":"newInstance","kind":"method","lang":"java","code":"@Override\n @SuppressWarnings(\"unchecked\")\n public T newInstance(Class c) throws Exception {\n assertInstantiable(c);\n return (T) newInstance.invoke(null, c, constructorId);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":106,"symbol":"newInstance","kind":"method","lang":"java","code":"@Override\n @SuppressWarnings(\"unchecked\")\n public T newInstance(Class c) throws Exception {\n assertInstantiable(c);\n return (T) newInstance.invoke(null, c, Object.class);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java","line":119,"symbol":"newInstance","kind":"method","lang":"java","code":"@Override\n public T newInstance(Class c) {\n throw new UnsupportedOperationException(\n \"Cannot allocate \"\n + c\n + \". Usage of JDK sun.misc.Unsafe is enabled, but it could not be used.\"\n + \" Make sure your runtime is configured correctly.\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java","line":34,"symbol":"ArrayTypeAdapter","kind":"class","lang":"java","doc":"Adapter for arrays.","code":"public final class ArrayTypeAdapter extends TypeAdapter {\n public static final TypeAdapterFactory FACTORY =\n new TypeAdapterFactory() {\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Type type = typeToken.getType();\n if (!(type instanceof GenericArrayType\n || (type instanceof Class && ((Class) type).isArray()))) {\n return null;\n }\n\n Type componentType = GsonTypes.getArrayComponentType(type);\n TypeAdapter componentTypeAdapter = gson.getAdapter(TypeToken.get(componentType));\n\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n TypeAdapter arrayAdapter =\n new ArrayTypeAdapter(gson, componentTypeAdapter, GsonTypes.getRawType(componentType));\n return arrayAdapter;\n }\n };\n\n private final Class componentType;\n private final TypeAdapter componentTypeAdapter;\n\n public ArrayTypeAdapter(\n Gson context, TypeAdapter componentTypeAdapter, Class componentType) {\n this.componentTypeAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(context, componentTypeAdapter, componentType);\n t"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java","line":37,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Type type = typeToken.getType();\n if (!(type instanceof GenericArrayType\n || (type instanceof Class && ((Class) type).isArray()))) {\n return null;\n }\n\n Type componentType = GsonTypes.getArrayComponentType(type);\n TypeAdapter componentTypeAdapter = gson.getAdapter(TypeToken.get(componentType));\n\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n TypeAdapter arrayAdapter =\n new ArrayTypeAdapter(gson, componentTypeAdapter, GsonTypes.getRawType(componentType));\n return arrayAdapter;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java","line":58,"symbol":"ArrayTypeAdapter","kind":"constructor","lang":"java","code":"public ArrayTypeAdapter(\n Gson context, TypeAdapter componentTypeAdapter, Class componentType) {\n this.componentTypeAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(context, componentTypeAdapter, componentType);\n this.componentType = componentType;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java","line":65,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Object read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n ArrayList list = new ArrayList<>();\n in.beginArray();\n while (in.hasNext()) {\n E instance = componentTypeAdapter.read(in);\n list.add(instance);\n }\n in.endArray();\n\n int size = list.size();\n // Have to copy primitives one by one to primitive array\n if (componentType.isPrimitive()) {\n Object array = Array.newInstance(componentType, size);\n for (int i = 0; i < size; i++) {\n Array.set(array, i, list.get(i));\n }\n return array;\n }\n // But for Object[] can use ArrayList.toArray\n else {\n @SuppressWarnings(\"unchecked\")\n E[] array = (E[]) Array.newInstance(componentType, size);\n return list.toArray(array);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java","line":97,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Object array) throws IOException {\n if (array == null) {\n out.nullValue();\n return;\n }\n\n out.beginArray();\n for (int i = 0, length = Array.getLength(array); i < length; i++) {\n @SuppressWarnings(\"unchecked\")\n E value = (E) Array.get(array, i);\n componentTypeAdapter.write(out, value);\n }\n out.endArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":34,"symbol":"CollectionTypeAdapterFactory","kind":"class","lang":"java","doc":"Adapt a homogeneous collection of objects.","code":"public final class CollectionTypeAdapterFactory implements TypeAdapterFactory {\n private final ConstructorConstructor constructorConstructor;\n\n public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) {\n this.constructorConstructor = constructorConstructor;\n }\n\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Type type = typeToken.getType();\n\n Class rawType = typeToken.getRawType();\n if (!Collection.class.isAssignableFrom(rawType)) {\n return null;\n }\n\n Type elementType = GsonTypes.getCollectionElementType(type, rawType);\n TypeAdapter elementTypeAdapter = gson.getAdapter(TypeToken.get(elementType));\n TypeAdapter wrappedTypeAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(gson, elementTypeAdapter, elementType);\n // Don't allow Unsafe usage to create instance; instances might be in broken state and calling\n // Collection methods could lead to confusing exceptions\n boolean allowUnsafe = false;\n ObjectConstructor constructor = constructorConstructor.get(typeToken, allowUnsafe);\n\n @SuppressWarnings({\"unchecked\", \"rawtypes\"}) // create() doesn't define a ty"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":37,"symbol":"CollectionTypeAdapterFactory","kind":"constructor","lang":"java","code":"public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) {\n this.constructorConstructor = constructorConstructor;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":41,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Type type = typeToken.getType();\n\n Class rawType = typeToken.getRawType();\n if (!Collection.class.isAssignableFrom(rawType)) {\n return null;\n }\n\n Type elementType = GsonTypes.getCollectionElementType(type, rawType);\n TypeAdapter elementTypeAdapter = gson.getAdapter(TypeToken.get(elementType));\n TypeAdapter wrappedTypeAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(gson, elementTypeAdapter, elementType);\n // Don't allow Unsafe usage to create instance; instances might be in broken state and calling\n // Collection methods could lead to confusing exceptions\n boolean allowUnsafe = false;\n ObjectConstructor constructor = constructorConstructor.get(typeToken, allowUnsafe);\n\n @SuppressWarnings({\"unchecked\", \"rawtypes\"}) // create() doesn't define a type parameter\n TypeAdapter result = new Adapter(wrappedTypeAdapter, constructor);\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":64,"symbol":"Adapter","kind":"class","lang":"java","code":"private static final class Adapter extends TypeAdapter> {\n private final TypeAdapter elementTypeAdapter;\n private final ObjectConstructor> constructor;\n\n Adapter(\n TypeAdapter elementTypeAdapter, ObjectConstructor> constructor) {\n this.elementTypeAdapter = elementTypeAdapter;\n this.constructor = constructor;\n }\n\n @Override\n public Collection read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n Collection collection = constructor.construct();\n in.beginArray();\n while (in.hasNext()) {\n E instance = elementTypeAdapter.read(in);\n collection.add(instance);\n }\n in.endArray();\n return collection;\n }\n\n @Override\n public void write(JsonWriter out, Collection collection) throws IOException {\n if (collection == null) {\n out.nullValue();\n return;\n }\n\n out.beginArray();\n for (E element : collection) {\n elementTypeAdapter.write(out, element);\n }\n out.endArray();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":68,"symbol":"Adapter","kind":"constructor","lang":"java","code":"Adapter(\n TypeAdapter elementTypeAdapter, ObjectConstructor> constructor) {\n this.elementTypeAdapter = elementTypeAdapter;\n this.constructor = constructor;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":74,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Collection read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n Collection collection = constructor.construct();\n in.beginArray();\n while (in.hasNext()) {\n E instance = elementTypeAdapter.read(in);\n collection.add(instance);\n }\n in.endArray();\n return collection;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java","line":91,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Collection collection) throws IOException {\n if (collection == null) {\n out.nullValue();\n return;\n }\n\n out.beginArray();\n for (E element : collection) {\n elementTypeAdapter.write(out, element);\n }\n out.endArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":55,"symbol":"DefaultDateTypeAdapter","kind":"class","lang":"java","doc":"create a single adapter instance and its behavior would then depend on when Gson classes are loaded first, and which default {@code Locale} and {@code TimeZone} was used at that point. @author Inderjeet Singh @author Joel Leitch","code":"public final class DefaultDateTypeAdapter extends TypeAdapter {\n private static final String SIMPLE_NAME = \"DefaultDateTypeAdapter\";\n\n /** Factory for {@link Date} adapters which use {@link DateFormat#DEFAULT} as style. */\n public static final TypeAdapterFactory DEFAULT_STYLE_FACTORY =\n // Because SimpleDateFormat captures the default TimeZone when it was created, let the factory\n // always create new DefaultDateTypeAdapter instances (which are then cached by the Gson\n // instances) instead of having a single static DefaultDateTypeAdapter instance\n // Otherwise the behavior would depend on when an application first loads Gson classes and\n // which default TimeZone is set at that point, which would be quite brittle\n new TypeAdapterFactory() {\n @SuppressWarnings(\"unchecked\") // we use a runtime check to make sure the 'T's equal\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n return typeToken.getRawType() == Date.class\n ? (TypeAdapter)\n new DefaultDateTypeAdapter<>(\n DateType.DATE, DateFormat.DEFAULT, DateFormat.DEFA"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":66,"symbol":"create","kind":"method","lang":"java","code":"@SuppressWarnings(\"unchecked\") // we use a runtime check to make sure the 'T's equal\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n return typeToken.getRawType() == Date.class\n ? (TypeAdapter)\n new DefaultDateTypeAdapter<>(\n DateType.DATE, DateFormat.DEFAULT, DateFormat.DEFAULT)\n : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":76,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"DefaultDateTypeAdapter#DEFAULT_STYLE_FACTORY\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":82,"symbol":"DateType","kind":"class","lang":"java","code":"public abstract static class DateType {\n public static final DateType DATE =\n new DateType(Date.class) {\n @Override\n protected Date deserialize(Date date) {\n return date;\n }\n };\n\n private final Class dateClass;\n\n protected DateType(Class dateClass) {\n this.dateClass = dateClass;\n }\n\n protected abstract T deserialize(Date date);\n\n private TypeAdapterFactory createFactory(DefaultDateTypeAdapter adapter) {\n return TypeAdapters.newFactory(dateClass, adapter);\n }\n\n public final TypeAdapterFactory createAdapterFactory(String datePattern) {\n return createFactory(new DefaultDateTypeAdapter<>(this, datePattern));\n }\n\n public final TypeAdapterFactory createAdapterFactory(int dateStyle, int timeStyle) {\n return createFactory(new DefaultDateTypeAdapter<>(this, dateStyle, timeStyle));\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":85,"symbol":"deserialize","kind":"method","lang":"java","code":"@Override\n protected Date deserialize(Date date) {\n return date;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":93,"symbol":"DateType","kind":"constructor","lang":"java","code":"protected DateType(Class dateClass) {\n this.dateClass = dateClass;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":97,"symbol":"deserialize","kind":"method","lang":"java","code":"protected abstract T deserialize(Date date);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":99,"symbol":"createFactory","kind":"method","lang":"java","code":"private TypeAdapterFactory createFactory(DefaultDateTypeAdapter adapter) {\n return TypeAdapters.newFactory(dateClass, adapter);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":103,"symbol":"createAdapterFactory","kind":"method","lang":"java","code":"public final TypeAdapterFactory createAdapterFactory(String datePattern) {\n return createFactory(new DefaultDateTypeAdapter<>(this, datePattern));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":107,"symbol":"createAdapterFactory","kind":"method","lang":"java","code":"public final TypeAdapterFactory createAdapterFactory(int dateStyle, int timeStyle) {\n return createFactory(new DefaultDateTypeAdapter<>(this, dateStyle, timeStyle));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":120,"symbol":"DefaultDateTypeAdapter","kind":"constructor","lang":"java","code":"private DefaultDateTypeAdapter(DateType dateType, String datePattern) {\n this.dateType = Objects.requireNonNull(dateType);\n dateFormats.add(new SimpleDateFormat(datePattern, Locale.US));\n if (!Locale.getDefault().equals(Locale.US)) {\n dateFormats.add(new SimpleDateFormat(datePattern));\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":128,"symbol":"DefaultDateTypeAdapter","kind":"constructor","lang":"java","code":"private DefaultDateTypeAdapter(DateType dateType, int dateStyle, int timeStyle) {\n this.dateType = Objects.requireNonNull(dateType);\n dateFormats.add(DateFormat.getDateTimeInstance(dateStyle, timeStyle, Locale.US));\n if (!Locale.getDefault().equals(Locale.US)) {\n dateFormats.add(DateFormat.getDateTimeInstance(dateStyle, timeStyle));\n }\n if (JavaVersion.isJava9OrLater()) {\n dateFormats.add(PreJava9DateFormatProvider.getUsDateTimeFormat(dateStyle, timeStyle));\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":139,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Date value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n\n DateFormat dateFormat = dateFormats.get(0);\n String dateFormatAsString;\n // Needs to be synchronized since JDK DateFormat classes are not thread-safe\n synchronized (dateFormats) {\n dateFormatAsString = dateFormat.format(value);\n }\n out.value(dateFormatAsString);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":155,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n Date date = deserializeToDate(in);\n return dateType.deserialize(date);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":165,"symbol":"deserializeToDate","kind":"method","lang":"java","code":"private Date deserializeToDate(JsonReader in) throws IOException {\n String s = in.nextString();\n // Needs to be synchronized since JDK DateFormat classes are not thread-safe\n synchronized (dateFormats) {\n for (DateFormat dateFormat : dateFormats) {\n TimeZone originalTimeZone = dateFormat.getTimeZone();\n try {\n return dateFormat.parse(s);\n } catch (ParseException ignored) {\n // OK: try the next format\n } finally {\n dateFormat.setTimeZone(originalTimeZone);\n }\n }\n }\n\n try {\n return ISO8601Utils.parse(s, new ParsePosition(0));\n } catch (ParseException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + s + \"' as Date; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java","line":189,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n DateFormat defaultFormat = dateFormats.get(0);\n if (defaultFormat instanceof SimpleDateFormat) {\n return SIMPLE_NAME + '(' + ((SimpleDateFormat) defaultFormat).toPattern() + ')';\n } else {\n return SIMPLE_NAME + '(' + defaultFormat.getClass().getSimpleName() + ')';\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java","line":35,"symbol":"EnumTypeAdapter","kind":"class","lang":"java","doc":"Adapter for enum classes (but not for the base class {@code java.lang.Enum}).","code":"class EnumTypeAdapter> extends TypeAdapter {\n static final TypeAdapterFactory FACTORY =\n new TypeAdapterFactory() {\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Class rawType = typeToken.getRawType();\n if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {\n return null;\n }\n if (!rawType.isEnum()) {\n rawType = rawType.getSuperclass(); // handle anonymous subclasses\n }\n @SuppressWarnings({\"rawtypes\", \"unchecked\"})\n TypeAdapter adapter = (TypeAdapter) new EnumTypeAdapter(rawType);\n return adapter;\n }\n };\n\n /**\n * Taken from Java 19 method {@link HashMap.newHashMap}, using default load factor {@code 0.75F}.\n */\n private static int calculateHashMapCapacity(int numMappings) {\n return (int) Math.ceil(numMappings / 0.75F);\n }\n\n private final Map nameToConstant;\n private final Map stringToConstant;\n private final Map constantToName;\n\n private EnumTypeAdapter(Class classOfT) {\n try {\n // Uses reflection to find enum const"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java","line":38,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Class rawType = typeToken.getRawType();\n if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {\n return null;\n }\n if (!rawType.isEnum()) {\n rawType = rawType.getSuperclass(); // handle anonymous subclasses\n }\n @SuppressWarnings({\"rawtypes\", \"unchecked\"})\n TypeAdapter adapter = (TypeAdapter) new EnumTypeAdapter(rawType);\n return adapter;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java","line":56,"symbol":"calculateHashMapCapacity","kind":"method","lang":"java","doc":"Taken from Java 19 method {@link HashMap.newHashMap}, using default load factor {@code 0.75F}.","code":"private static int calculateHashMapCapacity(int numMappings) {\n return (int) Math.ceil(numMappings / 0.75F);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java","line":64,"symbol":"EnumTypeAdapter","kind":"constructor","lang":"java","code":"private EnumTypeAdapter(Class classOfT) {\n try {\n // Uses reflection to find enum constants to work around name mismatches for obfuscated\n // classes\n Field[] fields = classOfT.getDeclaredFields();\n int constantCount = 0;\n for (Field f : fields) {\n // Filter out non-constant fields, replacing elements as we go\n if (f.isEnumConstant()) {\n fields[constantCount++] = f;\n }\n }\n\n // Trim the array to the new length. Every enum type can be expected to have at least\n // one declared field which is not an enum constant, namely the implicit $VALUES array\n fields = Arrays.copyOf(fields, constantCount);\n\n int hashMapCapacity = calculateHashMapCapacity(constantCount);\n nameToConstant = new HashMap<>(hashMapCapacity);\n stringToConstant = new HashMap<>(hashMapCapacity);\n // Don't use `EnumMap` here; that can break when using ProGuard or R8\n constantToName = new HashMap<>(hashMapCapacity);\n\n AccessibleObject.setAccessible(fields, true);\n\n for (Field constantField : fields) {\n @SuppressWarnings(\"unchecked\")\n T constant = (T) constantField.get(null);\n String name ="} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java","line":113,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String key = in.nextString();\n T constant = nameToConstant.get(key);\n // Note: If none of the approaches find the constant, this returns null\n return (constant == null) ? stringToConstant.get(key) : constant;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java","line":125,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n out.value(value == null ? null : constantToName.get(value));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":43,"symbol":"JavaTimeTypeAdapters","kind":"class","lang":"java","doc":"intervening time, people have been using the reflective representations, and changing that would potentially be incompatible. Meanwhile, depending on the details of private fields in JDK classes is obviously fragile, and it also needs special {@code --add-opens} configuration with more recent JDK versions. So here we freeze the representation that was current with JDK 21, in a way that does not use reflection.","code":"@IgnoreJRERequirement // Protected by a reflective check\nfinal class JavaTimeTypeAdapters implements TypeAdapters.FactorySupplier {\n\n @Override\n public TypeAdapterFactory get() {\n return JAVA_TIME_FACTORY;\n }\n\n private static final TypeAdapter DURATION =\n new IntegerFieldsTypeAdapter(\"seconds\", \"nanos\") {\n @Override\n Duration create(long[] values) {\n return Duration.ofSeconds(values[0], values[1]);\n }\n\n @Override\n @SuppressWarnings(\"JavaDurationGetSecondsGetNano\")\n long[] integerValues(Duration duration) {\n return new long[] {duration.getSeconds(), duration.getNano()};\n }\n };\n\n private static final TypeAdapter INSTANT =\n new IntegerFieldsTypeAdapter(\"seconds\", \"nanos\") {\n @Override\n Instant create(long[] values) {\n return Instant.ofEpochSecond(values[0], values[1]);\n }\n\n @Override\n @SuppressWarnings(\"JavaInstantGetSecondsGetNano\")\n long[] integerValues(Instant instant) {\n return new long[] {instant.getEpochSecond(), instant.getNano()};\n }\n };\n\n private static final TypeAdapter localDateTime(Gson gson) {\n TypeAdapter localDateAdapter = gson.getAdapter(LocalDate.class);\n TypeAdapter localTimeAdapter = gson.getAdapter(LocalTime.class);\n return new TypeAdapter() {\n @Override\n public LocalDateTime read(JsonReader in) throws IOException {\n LocalDate localDate = null;\n LocalTime localTime = null;\n in.beginObject();\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"date\":\n localDate = localDateAdapter.read(in);\n break;\n case \"time\":\n localTime = localTimeAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return LocalDateTime.of(\n requireNonNullField(localDate, \"date\", in), requireNonNullField(localTime, \"time\", in));\n }\n\n @Override\n public void write(JsonWriter out, LocalDateTime value) throws IOException {\n out.beginObject();\n out.name(\"date\");"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":117,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public LocalDateTime read(JsonReader in) throws IOException {\n LocalDate localDate = null;\n LocalTime localTime = null;\n in.beginObject();\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"date\":\n localDate = localDateAdapter.read(in);\n break;\n case \"time\":\n localTime = localTimeAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return LocalDateTime.of(\n requireNonNullField(localDate, \"date\", in), requireNonNullField(localTime, \"time\", in));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":141,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, LocalDateTime value) throws IOException {\n out.beginObject();\n out.name(\"date\");\n localDateAdapter.write(out, value.toLocalDate());\n out.name(\"time\");\n localTimeAdapter.write(out, value.toLocalTime());\n out.endObject();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":155,"symbol":"create","kind":"method","lang":"java","code":"@Override\n MonthDay create(long[] values) {\n return MonthDay.of(toIntExact(values[0]), toIntExact(values[1]));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":160,"symbol":"integerValues","kind":"method","lang":"java","code":"@Override\n long[] integerValues(MonthDay monthDay) {\n return new long[] {monthDay.getMonthValue(), monthDay.getDayOfMonth()};\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":166,"symbol":"offsetDateTime","kind":"method","lang":"java","code":"private static TypeAdapter offsetDateTime(Gson gson) {\n TypeAdapter localDateTimeAdapter = localDateTime(gson);\n TypeAdapter zoneOffsetAdapter = gson.getAdapter(ZoneOffset.class);\n return new TypeAdapter() {\n @Override\n public OffsetDateTime read(JsonReader in) throws IOException {\n in.beginObject();\n LocalDateTime localDateTime = null;\n ZoneOffset zoneOffset = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"dateTime\":\n localDateTime = localDateTimeAdapter.read(in);\n break;\n case \"offset\":\n zoneOffset = zoneOffsetAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return OffsetDateTime.of(\n requireNonNullField(localDateTime, \"dateTime\", in),\n requireNonNullField(zoneOffset, \"offset\", in));\n }\n\n @Override\n public void write(JsonWriter out, OffsetDateTime value) throws IOException {"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":170,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public OffsetDateTime read(JsonReader in) throws IOException {\n in.beginObject();\n LocalDateTime localDateTime = null;\n ZoneOffset zoneOffset = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"dateTime\":\n localDateTime = localDateTimeAdapter.read(in);\n break;\n case \"offset\":\n zoneOffset = zoneOffsetAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return OffsetDateTime.of(\n requireNonNullField(localDateTime, \"dateTime\", in),\n requireNonNullField(zoneOffset, \"offset\", in));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":195,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, OffsetDateTime value) throws IOException {\n out.beginObject();\n out.name(\"dateTime\");\n localDateTimeAdapter.write(out, value.toLocalDateTime());\n out.name(\"offset\");\n zoneOffsetAdapter.write(out, value.getOffset());\n out.endObject();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":207,"symbol":"offsetTime","kind":"method","lang":"java","code":"private static TypeAdapter offsetTime(Gson gson) {\n TypeAdapter localTimeAdapter = gson.getAdapter(LocalTime.class);\n TypeAdapter zoneOffsetAdapter = gson.getAdapter(ZoneOffset.class);\n return new TypeAdapter() {\n @Override\n public OffsetTime read(JsonReader in) throws IOException {\n in.beginObject();\n LocalTime localTime = null;\n ZoneOffset zoneOffset = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"time\":\n localTime = localTimeAdapter.read(in);\n break;\n case \"offset\":\n zoneOffset = zoneOffsetAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return OffsetTime.of(\n requireNonNullField(localTime, \"time\", in),\n requireNonNullField(zoneOffset, \"offset\", in));\n }\n\n @Override\n public void write(JsonWriter out, OffsetTime value) throws IOException {\n out.beginObject();\n out.name(\"t"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":211,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public OffsetTime read(JsonReader in) throws IOException {\n in.beginObject();\n LocalTime localTime = null;\n ZoneOffset zoneOffset = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"time\":\n localTime = localTimeAdapter.read(in);\n break;\n case \"offset\":\n zoneOffset = zoneOffsetAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return OffsetTime.of(\n requireNonNullField(localTime, \"time\", in),\n requireNonNullField(zoneOffset, \"offset\", in));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":236,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, OffsetTime value) throws IOException {\n out.beginObject();\n out.name(\"time\");\n localTimeAdapter.write(out, value.toLocalTime());\n out.name(\"offset\");\n zoneOffsetAdapter.write(out, value.getOffset());\n out.endObject();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":250,"symbol":"create","kind":"method","lang":"java","code":"@Override\n Period create(long[] values) {\n return Period.of(toIntExact(values[0]), toIntExact(values[1]), toIntExact(values[2]));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":255,"symbol":"integerValues","kind":"method","lang":"java","code":"@Override\n long[] integerValues(Period period) {\n return new long[] {period.getYears(), period.getMonths(), period.getDays()};\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":263,"symbol":"create","kind":"method","lang":"java","code":"@Override\n Year create(long[] values) {\n return Year.of(toIntExact(values[0]));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":268,"symbol":"integerValues","kind":"method","lang":"java","code":"@Override\n long[] integerValues(Year year) {\n return new long[] {year.getValue()};\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":276,"symbol":"create","kind":"method","lang":"java","code":"@Override\n YearMonth create(long[] values) {\n return YearMonth.of(toIntExact(values[0]), toIntExact(values[1]));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":281,"symbol":"integerValues","kind":"method","lang":"java","code":"@Override\n long[] integerValues(YearMonth yearMonth) {\n return new long[] {yearMonth.getYear(), yearMonth.getMonthValue()};\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":294,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public ZoneId read(JsonReader in) throws IOException {\n in.beginObject();\n String id = null;\n Integer totalSeconds = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"id\":\n id = in.nextString();\n break;\n case \"totalSeconds\":\n totalSeconds = in.nextInt();\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n if (id != null) {\n return ZoneId.of(id);\n } else if (totalSeconds != null) {\n return ZoneOffset.ofTotalSeconds(totalSeconds);\n } else {\n throw new JsonSyntaxException(\n \"Missing id or totalSeconds field; at path \" + in.getPreviousPath());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":324,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, ZoneId value) throws IOException {\n if (value instanceof ZoneOffset) {\n out.beginObject();\n out.name(\"totalSeconds\");\n out.value(((ZoneOffset) value).getTotalSeconds());\n out.endObject();\n } else {\n out.beginObject();\n out.name(\"id\");\n out.value(value.getId());\n out.endObject();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":340,"symbol":"zonedDateTime","kind":"method","lang":"java","code":"private static TypeAdapter zonedDateTime(Gson gson) {\n TypeAdapter localDateTimeAdapter = localDateTime(gson);\n TypeAdapter zoneOffsetAdapter = gson.getAdapter(ZoneOffset.class);\n TypeAdapter zoneIdAdapter = gson.getAdapter(ZoneId.class);\n return new TypeAdapter() {\n @Override\n public ZonedDateTime read(JsonReader in) throws IOException {\n in.beginObject();\n LocalDateTime localDateTime = null;\n ZoneOffset zoneOffset = null;\n ZoneId zoneId = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"dateTime\":\n localDateTime = localDateTimeAdapter.read(in);\n break;\n case \"offset\":\n zoneOffset = zoneOffsetAdapter.read(in);\n break;\n case \"zone\":\n zoneId = zoneIdAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return ZonedDateTime.ofInstant(\n requireNonNullField(loc"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":345,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public ZonedDateTime read(JsonReader in) throws IOException {\n in.beginObject();\n LocalDateTime localDateTime = null;\n ZoneOffset zoneOffset = null;\n ZoneId zoneId = null;\n while (in.peek() != JsonToken.END_OBJECT) {\n String name = in.nextName();\n switch (name) {\n case \"dateTime\":\n localDateTime = localDateTimeAdapter.read(in);\n break;\n case \"offset\":\n zoneOffset = zoneOffsetAdapter.read(in);\n break;\n case \"zone\":\n zoneId = zoneIdAdapter.read(in);\n break;\n default:\n // Ignore other fields.\n in.skipValue();\n }\n }\n in.endObject();\n return ZonedDateTime.ofInstant(\n requireNonNullField(localDateTime, \"dateTime\", in),\n requireNonNullField(zoneOffset, \"offset\", in),\n requireNonNullField(zoneId, \"zone\", in));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":375,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, ZonedDateTime value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n out.beginObject();\n out.name(\"dateTime\");\n localDateTimeAdapter.write(out, value.toLocalDateTime());\n out.name(\"offset\");\n zoneOffsetAdapter.write(out, value.getOffset());\n out.name(\"zone\");\n zoneIdAdapter.write(out, value.getZone());\n out.endObject();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":395,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Class rawType = typeToken.getRawType();\n if (!rawType.getName().startsWith(\"java.time.\")) {\n // Immediately return null so we don't load all these classes when nobody's doing\n // anything with java.time.\n return null;\n }\n TypeAdapter adapter = null;\n if (rawType == Duration.class) {\n adapter = DURATION;\n } else if (rawType == Instant.class) {\n adapter = INSTANT;\n } else if (rawType == LocalDate.class) {\n adapter = LOCAL_DATE;\n } else if (rawType == LocalTime.class) {\n adapter = LOCAL_TIME;\n } else if (rawType == LocalDateTime.class) {\n adapter = localDateTime(gson);\n } else if (rawType == MonthDay.class) {\n adapter = MONTH_DAY;\n } else if (rawType == OffsetDateTime.class) {\n adapter = offsetDateTime(gson);\n } else if (rawType == OffsetTime.class) {\n adapter = offsetTime(gson);\n } else if (rawType == Period.class) {\n adapter = PERIOD;\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java","line":442,"symbol":"requireNonNullField","kind":"method","lang":"java","code":"private static T requireNonNullField(T field, String fieldName, JsonReader reader) {\n if (field == null) {\n throw new JsonSyntaxException(\n \"Missing \" + fieldName + \" field; at path \" + reader.getPreviousPath());\n }\n return field;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":37,"symbol":"JsonAdapterAnnotationTypeAdapterFactory","kind":"class","lang":"java","doc":"Given a type T, looks for the annotation {@link JsonAdapter} and uses an instance of the specified class as the default type adapter. @since 2.3","code":"public final class JsonAdapterAnnotationTypeAdapterFactory implements TypeAdapterFactory {\n private static final class DummyTypeAdapterFactory implements TypeAdapterFactory {\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n throw new AssertionError(\"Factory should not be used\");\n }\n }\n\n /** Factory used for {@link TreeTypeAdapter}s created for {@code @JsonAdapter} on a class. */\n private static final DummyTypeAdapterFactory TREE_TYPE_CLASS_DUMMY_FACTORY =\n new DummyTypeAdapterFactory();\n\n /** Factory used for {@link TreeTypeAdapter}s created for {@code @JsonAdapter} on a field. */\n private static final DummyTypeAdapterFactory TREE_TYPE_FIELD_DUMMY_FACTORY =\n new DummyTypeAdapterFactory();\n\n private final ConstructorConstructor constructorConstructor;\n\n /**\n * For a class, if it is annotated with {@code @JsonAdapter} and refers to a {@link\n * TypeAdapterFactory}, stores the factory instance in case it has been requested already. Has to\n * be a {@link ConcurrentMap} because {@link Gson} guarantees to be thread-safe.\n */\n // Note: In case these strong reference to TypeAdapterFactory instances are considered\n // a m"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":38,"symbol":"DummyTypeAdapterFactory","kind":"class","lang":"java","code":"private static final class DummyTypeAdapterFactory implements TypeAdapterFactory {\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n throw new AssertionError(\"Factory should not be used\");\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":39,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n throw new AssertionError(\"Factory should not be used\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":64,"symbol":"JsonAdapterAnnotationTypeAdapterFactory","kind":"constructor","lang":"java","code":"public JsonAdapterAnnotationTypeAdapterFactory(ConstructorConstructor constructorConstructor) {\n this.constructorConstructor = constructorConstructor;\n this.adapterFactoryMap = new ConcurrentHashMap<>();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":70,"symbol":"getAnnotation","kind":"method","lang":"java","doc":"Separate helper method to make sure callers retrieve annotation in a consistent way","code":"private static JsonAdapter getAnnotation(Class rawType) {\n return rawType.getAnnotation(JsonAdapter.class);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":75,"symbol":"create","kind":"method","lang":"java","doc":"this is not safe; requires that user has specified correct adapter class for @JsonAdapter","code":"@SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken targetType) {\n Class rawType = targetType.getRawType();\n JsonAdapter annotation = getAnnotation(rawType);\n if (annotation == null) {\n return null;\n }\n return (TypeAdapter)\n getTypeAdapter(constructorConstructor, gson, targetType, annotation, true);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":88,"symbol":"createAdapter","kind":"method","lang":"java","doc":"Separate helper method to make sure callers create adapter in a consistent way","code":"private static Object createAdapter(\n ConstructorConstructor constructorConstructor, Class adapterClass) {\n // TODO: The exception messages created by ConstructorConstructor are currently written in the\n // context of deserialization and for example suggest usage of TypeAdapter, which would not work\n // for @JsonAdapter usage\n // TODO: Should probably not allow usage of Unsafe; instances might be in broken state and\n // calling adapter methods on them might lead to confusing exceptions\n boolean allowUnsafe = true;\n return constructorConstructor.get(TypeToken.get(adapterClass), allowUnsafe).construct();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":99,"symbol":"putFactoryAndGetCurrent","kind":"method","lang":"java","code":"private TypeAdapterFactory putFactoryAndGetCurrent(Class rawType, TypeAdapterFactory factory) {\n // Uses putIfAbsent in case multiple threads concurrently create factory\n TypeAdapterFactory existingFactory = adapterFactoryMap.putIfAbsent(rawType, factory);\n return existingFactory != null ? existingFactory : factory;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":105,"symbol":"getTypeAdapter","kind":"method","lang":"java","code":"TypeAdapter getTypeAdapter(\n ConstructorConstructor constructorConstructor,\n Gson gson,\n TypeToken type,\n JsonAdapter annotation,\n boolean isClassAnnotation) {\n Object instance = createAdapter(constructorConstructor, annotation.value());\n\n TypeAdapter typeAdapter;\n boolean nullSafe = annotation.nullSafe();\n if (instance instanceof TypeAdapter) {\n typeAdapter = (TypeAdapter) instance;\n } else if (instance instanceof TypeAdapterFactory) {\n TypeAdapterFactory factory = (TypeAdapterFactory) instance;\n\n if (isClassAnnotation) {\n factory = putFactoryAndGetCurrent(type.getRawType(), factory);\n }\n\n typeAdapter = factory.create(gson, type);\n } else if (instance instanceof JsonSerializer || instance instanceof JsonDeserializer) {\n JsonSerializer serializer =\n instance instanceof JsonSerializer ? (JsonSerializer) instance : null;\n JsonDeserializer deserializer =\n instance instanceof JsonDeserializer ? (JsonDeserializer) instance : null;\n\n // Uses dummy factory instances because TreeTypeAdapter needs a 'skipPast' factory for\n // `Gson.getDelegateAdapter` call"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":164,"symbol":"areSameFactories","kind":"method","lang":"java","code":"@SuppressWarnings(\"ReferenceEquality\")\n private static boolean areSameFactories(TypeAdapterFactory a, TypeAdapterFactory b) {\n // Checks for reference equality, like it is done by `Gson.getDelegateAdapter`\n return a == b;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java","line":174,"symbol":"isClassJsonAdapterFactory","kind":"method","lang":"java","doc":"Returns whether {@code factory} is a type adapter factory created for {@code @JsonAdapter} placed on {@code type}.","code":"public boolean isClassJsonAdapterFactory(TypeToken type, TypeAdapterFactory factory) {\n Objects.requireNonNull(type);\n Objects.requireNonNull(factory);\n\n if (factory == TREE_TYPE_CLASS_DUMMY_FACTORY) {\n return true;\n }\n\n // Using raw type to match behavior of `create(Gson, TypeToken)` above\n Class rawType = type.getRawType();\n\n TypeAdapterFactory existingFactory = adapterFactoryMap.get(rawType);\n if (existingFactory != null) {\n return areSameFactories(existingFactory, factory);\n }\n\n // If no factory has been created for the type yet check manually for a @JsonAdapter annotation\n // which specifies a TypeAdapterFactory\n // Otherwise behavior would not be consistent, depending on whether or not adapter had been\n // requested before call to `isClassJsonAdapterFactory` was made\n JsonAdapter annotation = getAnnotation(rawType);\n if (annotation == null) {\n return false;\n }\n\n Class adapterClass = annotation.value();\n if (!TypeAdapterFactory.class.isAssignableFrom(adapterClass)) {\n return false;\n }\n\n Object adapter = createAdapter(constructorConstructor, adapterClass);\n TypeAdapterFactory newFacto"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java","line":35,"symbol":"JsonElementTypeAdapter","kind":"class","lang":"java","doc":"Adapter for {@link JsonElement} and subclasses.","code":"public class JsonElementTypeAdapter extends TypeAdapter {\n public static final JsonElementTypeAdapter ADAPTER = new JsonElementTypeAdapter();\n\n private JsonElementTypeAdapter() {}\n\n /**\n * Tries to begin reading a JSON array or JSON object, returning {@code null} if the next element\n * is neither of those.\n */\n private JsonElement tryBeginNesting(JsonReader in, JsonToken peeked) throws IOException {\n switch (peeked) {\n case BEGIN_ARRAY:\n in.beginArray();\n return new JsonArray();\n case BEGIN_OBJECT:\n in.beginObject();\n return new JsonObject();\n default:\n return null;\n }\n }\n\n /** Reads a {@link JsonElement} which cannot have any nested elements */\n private JsonElement readTerminal(JsonReader in, JsonToken peeked) throws IOException {\n switch (peeked) {\n case STRING:\n return new JsonPrimitive(in.nextString());\n case NUMBER:\n String number = in.nextString();\n return new JsonPrimitive(new LazilyParsedNumber(number));\n case BOOLEAN:\n return new JsonPrimitive(in.nextBoolean());\n case NULL:\n in.nextNull();\n return JsonNull.INSTANCE;\n defaul"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java","line":38,"symbol":"JsonElementTypeAdapter","kind":"constructor","lang":"java","code":"private JsonElementTypeAdapter() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java","line":44,"symbol":"tryBeginNesting","kind":"method","lang":"java","doc":"Tries to begin reading a JSON array or JSON object, returning {@code null} if the next element is neither of those.","code":"private JsonElement tryBeginNesting(JsonReader in, JsonToken peeked) throws IOException {\n switch (peeked) {\n case BEGIN_ARRAY:\n in.beginArray();\n return new JsonArray();\n case BEGIN_OBJECT:\n in.beginObject();\n return new JsonObject();\n default:\n return null;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java","line":58,"symbol":"readTerminal","kind":"method","lang":"java","doc":"Reads a {@link JsonElement} which cannot have any nested elements","code":"private JsonElement readTerminal(JsonReader in, JsonToken peeked) throws IOException {\n switch (peeked) {\n case STRING:\n return new JsonPrimitive(in.nextString());\n case NUMBER:\n String number = in.nextString();\n return new JsonPrimitive(new LazilyParsedNumber(number));\n case BOOLEAN:\n return new JsonPrimitive(in.nextBoolean());\n case NULL:\n in.nextNull();\n return JsonNull.INSTANCE;\n default:\n // When read(JsonReader) is called with JsonReader in invalid state\n throw new IllegalStateException(\"Unexpected token: \" + peeked);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java","line":76,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public JsonElement read(JsonReader in) throws IOException {\n // Optimization if value already exists as JsonElement\n if (in instanceof JsonTreeReader) {\n return ((JsonTreeReader) in).nextJsonElement();\n }\n\n // Either JsonArray or JsonObject\n JsonElement current;\n JsonToken peeked = in.peek();\n\n current = tryBeginNesting(in, peeked);\n if (current == null) {\n return readTerminal(in, peeked);\n }\n\n Deque stack = new ArrayDeque<>();\n\n while (true) {\n while (in.hasNext()) {\n String name = null;\n // Name is only used for JSON object members\n if (current instanceof JsonObject) {\n name = in.nextName();\n }\n\n peeked = in.peek();\n JsonElement value = tryBeginNesting(in, peeked);\n boolean isNesting = value != null;\n\n if (value == null) {\n value = readTerminal(in, peeked);\n }\n\n if (current instanceof JsonArray) {\n ((JsonArray) current).add(value);\n } else {\n ((JsonObject) current).add(name, value);\n }\n\n if (isNesting) {\n stack.addLast(current);\n current = value;\n }\n }\n\n"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java","line":138,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, JsonElement value) throws IOException {\n if (value == null || value.isJsonNull()) {\n out.nullValue();\n } else if (value.isJsonPrimitive()) {\n JsonPrimitive primitive = value.getAsJsonPrimitive();\n if (primitive.isNumber()) {\n out.value(primitive.getAsNumber());\n } else if (primitive.isBoolean()) {\n out.value(primitive.getAsBoolean());\n } else {\n out.value(primitive.getAsString());\n }\n\n } else if (value.isJsonArray()) {\n out.beginArray();\n for (JsonElement e : value.getAsJsonArray()) {\n write(out, e);\n }\n out.endArray();\n\n } else if (value.isJsonObject()) {\n out.beginObject();\n for (Map.Entry e : value.getAsJsonObject().entrySet()) {\n out.name(e.getKey());\n write(out, e.getValue());\n }\n out.endObject();\n\n } else {\n throw new IllegalArgumentException(\"Couldn't write \" + value.getClass());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":39,"symbol":"JsonTreeReader","kind":"class","lang":"java","doc":"This reader walks the elements of a JsonElement as if it was coming from a character stream. @author Jesse Wilson","code":"public final class JsonTreeReader extends JsonReader {\n private static final Reader UNREADABLE_READER =\n new Reader() {\n @Override\n public int read(char[] buffer, int offset, int count) {\n throw new AssertionError();\n }\n\n @Override\n public void close() {\n throw new AssertionError();\n }\n };\n private static final Object SENTINEL_CLOSED = new Object();\n\n /** The nesting stack. Using a manual array rather than an ArrayList saves 20%. */\n private Object[] stack = new Object[32];\n\n /**\n * The used size of {@link #stack}; the value at {@code stackSize - 1} is the value last placed on\n * the stack. {@code stackSize} might differ from the nesting depth, because the stack also\n * contains temporary additional objects, for example for a JsonArray it contains the JsonArray\n * object as well as the corresponding iterator.\n */\n private int stackSize = 0;\n\n /*\n * The path members. It corresponds directly to stack: At indices where the\n * stack contains an object (EMPTY_OBJECT, DANGLING_NAME or NONEMPTY_OBJECT),\n * pathNames contains the name at this scope. Where it contains an array\n * (EMPTY_ARRAY, NON"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":42,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public int read(char[] buffer, int offset, int count) {\n throw new AssertionError();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":47,"symbol":"close","kind":"method","lang":"java","code":"@Override\n public void close() {\n throw new AssertionError();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":76,"symbol":"JsonTreeReader","kind":"constructor","lang":"java","code":"public JsonTreeReader(JsonElement element) {\n super(UNREADABLE_READER);\n push(element);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":81,"symbol":"beginArray","kind":"method","lang":"java","code":"@Override\n public void beginArray() throws IOException {\n expect(JsonToken.BEGIN_ARRAY);\n JsonArray array = (JsonArray) peekStack();\n push(array.iterator());\n pathIndices[stackSize - 1] = 0;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":89,"symbol":"endArray","kind":"method","lang":"java","code":"@Override\n public void endArray() throws IOException {\n expect(JsonToken.END_ARRAY);\n popStack(); // empty iterator\n popStack(); // array\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":99,"symbol":"beginObject","kind":"method","lang":"java","code":"@Override\n public void beginObject() throws IOException {\n expect(JsonToken.BEGIN_OBJECT);\n JsonObject object = (JsonObject) peekStack();\n push(object.entrySet().iterator());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":106,"symbol":"endObject","kind":"method","lang":"java","code":"@Override\n public void endObject() throws IOException {\n expect(JsonToken.END_OBJECT);\n pathNames[stackSize - 1] = null; // Free the last path name so that it can be garbage collected\n popStack(); // empty iterator\n popStack(); // object\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":117,"symbol":"hasNext","kind":"method","lang":"java","code":"@Override\n public boolean hasNext() throws IOException {\n JsonToken token = peek();\n return token != JsonToken.END_OBJECT\n && token != JsonToken.END_ARRAY\n && token != JsonToken.END_DOCUMENT;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":127,"symbol":"peek","kind":"method","lang":"java","doc":"TODO: Suppression is likely redundant once https://github.com/google/error-prone/pull/5895 is released","code":"@SuppressWarnings(\"ReferenceEquality\")\n @Override\n public JsonToken peek() throws IOException {\n if (stackSize == 0) {\n return JsonToken.END_DOCUMENT;\n }\n\n Object o = peekStack();\n if (o instanceof Iterator) {\n boolean isObject = stack[stackSize - 2] instanceof JsonObject;\n Iterator iterator = (Iterator) o;\n if (iterator.hasNext()) {\n if (isObject) {\n return JsonToken.NAME;\n } else {\n push(iterator.next());\n return peek();\n }\n } else {\n return isObject ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;\n }\n } else if (o instanceof JsonObject) {\n return JsonToken.BEGIN_OBJECT;\n } else if (o instanceof JsonArray) {\n return JsonToken.BEGIN_ARRAY;\n } else if (o instanceof JsonPrimitive) {\n JsonPrimitive primitive = (JsonPrimitive) o;\n if (primitive.isString()) {\n return JsonToken.STRING;\n } else if (primitive.isBoolean()) {\n return JsonToken.BOOLEAN;\n } else if (primitive.isNumber()) {\n return JsonToken.NUMBER;\n } else {\n throw new AssertionError();\n }\n } else if (o instanceof JsonNull) {\n return JsonToke"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":173,"symbol":"peekStack","kind":"method","lang":"java","code":"private Object peekStack() {\n return stack[stackSize - 1];\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":177,"symbol":"popStack","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n private Object popStack() {\n Object result = stack[--stackSize];\n stack[stackSize] = null;\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":184,"symbol":"expect","kind":"method","lang":"java","code":"private void expect(JsonToken expected) throws IOException {\n if (peek() != expected) {\n throw new IllegalStateException(\n \"Expected \" + expected + \" but was \" + peek() + locationString());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":191,"symbol":"nextName","kind":"method","lang":"java","code":"private String nextName(boolean skipName) throws IOException {\n expect(JsonToken.NAME);\n Iterator i = (Iterator) peekStack();\n Map.Entry entry = (Map.Entry) i.next();\n String result = (String) entry.getKey();\n pathNames[stackSize - 1] = skipName ? \"\" : result;\n push(entry.getValue());\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":201,"symbol":"nextName","kind":"method","lang":"java","code":"@Override\n public String nextName() throws IOException {\n return nextName(false);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":206,"symbol":"nextString","kind":"method","lang":"java","code":"@Override\n public String nextString() throws IOException {\n JsonToken token = peek();\n if (token != JsonToken.STRING && token != JsonToken.NUMBER) {\n throw new IllegalStateException(\n \"Expected \" + JsonToken.STRING + \" but was \" + token + locationString());\n }\n String result = ((JsonPrimitive) popStack()).getAsString();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":220,"symbol":"nextBoolean","kind":"method","lang":"java","code":"@Override\n public boolean nextBoolean() throws IOException {\n expect(JsonToken.BOOLEAN);\n boolean result = ((JsonPrimitive) popStack()).getAsBoolean();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":230,"symbol":"nextNull","kind":"method","lang":"java","code":"@Override\n public void nextNull() throws IOException {\n expect(JsonToken.NULL);\n popStack();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":239,"symbol":"nextDouble","kind":"method","lang":"java","code":"@Override\n public double nextDouble() throws IOException {\n JsonToken token = peek();\n if (token != JsonToken.NUMBER && token != JsonToken.STRING) {\n throw new IllegalStateException(\n \"Expected \" + JsonToken.NUMBER + \" but was \" + token + locationString());\n }\n JsonPrimitive primitive = (JsonPrimitive) peekStack();\n double result;\n try {\n result = primitive.getAsDouble();\n } catch (NumberFormatException e) {\n throw numberFormatException(\"Expected a double but was \" + primitive.getAsString(), e);\n }\n if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) {\n throw new MalformedJsonException(\"JSON forbids NaN and infinities: \" + result);\n }\n popStack();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":263,"symbol":"nextLong","kind":"method","lang":"java","code":"@Override\n public long nextLong() throws IOException {\n JsonToken token = peek();\n if (token != JsonToken.NUMBER && token != JsonToken.STRING) {\n throw new IllegalStateException(\n \"Expected \" + JsonToken.NUMBER + \" but was \" + token + locationString());\n }\n JsonPrimitive primitive = (JsonPrimitive) peekStack();\n if (token == JsonToken.STRING) {\n validateAscii(primitive.getAsString());\n }\n long result;\n try {\n result = primitive.getAsLong();\n } catch (NumberFormatException e) {\n throw numberFormatException(\"Expected a long but was \" + primitive.getAsString(), e);\n }\n popStack();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":287,"symbol":"nextInt","kind":"method","lang":"java","code":"@Override\n public int nextInt() throws IOException {\n JsonToken token = peek();\n if (token != JsonToken.NUMBER && token != JsonToken.STRING) {\n throw new IllegalStateException(\n \"Expected \" + JsonToken.NUMBER + \" but was \" + token + locationString());\n }\n JsonPrimitive primitive = (JsonPrimitive) peekStack();\n if (token == JsonToken.STRING) {\n validateAscii(primitive.getAsString());\n }\n int result;\n try {\n result = primitive.getAsInt();\n } catch (NumberFormatException e) {\n throw numberFormatException(\"Expected an int but was \" + primitive.getAsString(), e);\n }\n popStack();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n return result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":311,"symbol":"nextJsonElement","kind":"method","lang":"java","code":"JsonElement nextJsonElement() throws IOException {\n JsonToken peeked = peek();\n if (peeked == JsonToken.NAME\n || peeked == JsonToken.END_ARRAY\n || peeked == JsonToken.END_OBJECT\n || peeked == JsonToken.END_DOCUMENT) {\n throw new IllegalStateException(\"Unexpected \" + peeked + \" when reading a JsonElement.\");\n }\n JsonElement element = (JsonElement) peekStack();\n skipValue();\n return element;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":324,"symbol":"close","kind":"method","lang":"java","code":"@Override\n public void close() throws IOException {\n stack = new Object[] {SENTINEL_CLOSED};\n stackSize = 1;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":330,"symbol":"skipValue","kind":"method","lang":"java","code":"@Override\n public void skipValue() throws IOException {\n JsonToken peeked = peek();\n switch (peeked) {\n case NAME:\n @SuppressWarnings(\"unused\")\n String unused = nextName(true);\n break;\n case END_ARRAY:\n endArray();\n break;\n case END_OBJECT:\n endObject();\n break;\n case END_DOCUMENT:\n // Do nothing\n break;\n default:\n popStack();\n if (stackSize > 0) {\n pathIndices[stackSize - 1]++;\n }\n break;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":356,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return getClass().getSimpleName() + locationString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":361,"symbol":"promoteNameToValue","kind":"method","lang":"java","code":"public void promoteNameToValue() throws IOException {\n expect(JsonToken.NAME);\n Iterator i = (Iterator) peekStack();\n Map.Entry entry = (Map.Entry) i.next();\n String name = (String) entry.getKey();\n // Record the name so the JSON path includes it after promotion (issue 1768).\n pathNames[stackSize - 1] = name;\n push(entry.getValue());\n push(new JsonPrimitive(name));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":372,"symbol":"push","kind":"method","lang":"java","code":"private void push(Object newTop) {\n if (stackSize == stack.length) {\n int newLength = stackSize * 2;\n stack = Arrays.copyOf(stack, newLength);\n pathIndices = Arrays.copyOf(pathIndices, newLength);\n pathNames = Arrays.copyOf(pathNames, newLength);\n }\n stack[stackSize++] = newTop;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":382,"symbol":"getPath","kind":"method","lang":"java","code":"private String getPath(boolean usePreviousPath) {\n StringBuilder result = new StringBuilder().append('$');\n for (int i = 0; i < stackSize; i++) {\n if (stack[i] instanceof JsonArray) {\n if (++i < stackSize && stack[i] instanceof Iterator) {\n int pathIndex = pathIndices[i];\n // If index is last path element it points to next array element; have to decrement\n // `- 1` covers case where iterator for next element is on stack\n // `- 2` covers case where peek() already pushed next element onto stack\n if (usePreviousPath && pathIndex > 0 && (i == stackSize - 1 || i == stackSize - 2)) {\n pathIndex--;\n }\n result.append('[').append(pathIndex).append(']');\n }\n } else if (stack[i] instanceof JsonObject) {\n if (++i < stackSize && stack[i] instanceof Iterator) {\n result.append('.');\n if (pathNames[i] != null) {\n result.append(pathNames[i]);\n }\n }\n }\n }\n return result.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":408,"symbol":"getPath","kind":"method","lang":"java","code":"@Override\n public String getPath() {\n return getPath(false);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":413,"symbol":"getPreviousPath","kind":"method","lang":"java","code":"@Override\n public String getPreviousPath() {\n return getPath(true);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":418,"symbol":"getCharacterOffset","kind":"method","lang":"java","code":"@Override\n public long getCharacterOffset() {\n return -1L;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":423,"symbol":"locationString","kind":"method","lang":"java","code":"private String locationString() {\n return \" at path \" + getPath();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":428,"symbol":"isAllAscii","kind":"method","lang":"java","doc":"Returns whether every character of {@code s} is ASCII (code point at most 127).","code":"public static boolean isAllAscii(String s) {\n for (int i = 0; i < s.length(); i++) {\n if (s.charAt(i) > 127) {\n return false;\n }\n }\n return true;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":437,"symbol":"validateAscii","kind":"method","lang":"java","code":"private void validateAscii(String s) throws MalformedJsonException {\n if (!isAllAscii(s)) {\n throw new MalformedJsonException(\n \"String contains non-ASCII characters: \" + s + locationString());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java","line":445,"symbol":"numberFormatException","kind":"method","lang":"java","doc":"Creates a {@link NumberFormatException} whose message includes the current path.","code":"private NumberFormatException numberFormatException(String message, NumberFormatException cause) {\n NumberFormatException exception = new NumberFormatException(message + locationString());\n exception.initCause(cause);\n return exception;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":33,"symbol":"JsonTreeWriter","kind":"class","lang":"java","doc":"This writer creates a JsonElement.","code":"public final class JsonTreeWriter extends JsonWriter {\n private static final Writer UNWRITABLE_WRITER =\n new Writer() {\n @Override\n public void write(char[] buffer, int offset, int counter) {\n throw new AssertionError();\n }\n\n @Override\n public void flush() {\n throw new AssertionError();\n }\n\n @Override\n public void close() {\n throw new AssertionError();\n }\n };\n\n /** Added to the top of the stack when this writer is closed to cause following ops to fail. */\n private static final JsonPrimitive SENTINEL_CLOSED = new JsonPrimitive(\"closed\");\n\n /** The JsonElements and JsonArrays under modification, outermost to innermost. */\n private final List stack = new ArrayList<>();\n\n /** The name for the next JSON object value. If non-null, the top of the stack is a JsonObject. */\n private String pendingName;\n\n /** the JSON element constructed by this writer. */\n private JsonElement product = JsonNull.INSTANCE; // TODO: is this really what we want?;\n\n public JsonTreeWriter() {\n super(UNWRITABLE_WRITER);\n }\n\n /** Returns the top level object produced by this writer. */\n p"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":36,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(char[] buffer, int offset, int counter) {\n throw new AssertionError();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":41,"symbol":"flush","kind":"method","lang":"java","code":"@Override\n public void flush() {\n throw new AssertionError();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":46,"symbol":"close","kind":"method","lang":"java","code":"@Override\n public void close() {\n throw new AssertionError();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":64,"symbol":"JsonTreeWriter","kind":"constructor","lang":"java","code":"public JsonTreeWriter() {\n super(UNWRITABLE_WRITER);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":69,"symbol":"get","kind":"method","lang":"java","doc":"Returns the top level object produced by this writer.","code":"public JsonElement get() {\n if (!stack.isEmpty()) {\n throw new IllegalStateException(\"Expected one JSON element but was \" + stack);\n }\n return product;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":76,"symbol":"peek","kind":"method","lang":"java","code":"private JsonElement peek() {\n return stack.get(stack.size() - 1);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":80,"symbol":"put","kind":"method","lang":"java","code":"private void put(JsonElement value) {\n if (pendingName != null) {\n if (!value.isJsonNull() || getSerializeNulls()) {\n JsonObject object = (JsonObject) peek();\n object.add(pendingName, value);\n }\n pendingName = null;\n } else if (stack.isEmpty()) {\n product = value;\n } else {\n JsonElement element = peek();\n if (element instanceof JsonArray) {\n ((JsonArray) element).add(value);\n } else {\n throw new IllegalStateException();\n }\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":99,"symbol":"beginArray","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter beginArray() throws IOException {\n JsonArray array = new JsonArray();\n put(array);\n stack.add(array);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":108,"symbol":"endArray","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter endArray() throws IOException {\n if (stack.isEmpty() || pendingName != null) {\n throw new IllegalStateException();\n }\n JsonElement element = peek();\n if (element instanceof JsonArray) {\n stack.remove(stack.size() - 1);\n return this;\n }\n throw new IllegalStateException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":122,"symbol":"beginObject","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter beginObject() throws IOException {\n JsonObject object = new JsonObject();\n put(object);\n stack.add(object);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":131,"symbol":"endObject","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter endObject() throws IOException {\n if (stack.isEmpty() || pendingName != null) {\n throw new IllegalStateException();\n }\n JsonElement element = peek();\n if (element instanceof JsonObject) {\n stack.remove(stack.size() - 1);\n return this;\n }\n throw new IllegalStateException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":145,"symbol":"name","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter name(String name) throws IOException {\n Objects.requireNonNull(name, \"name == null\");\n if (stack.isEmpty() || pendingName != null) {\n throw new IllegalStateException(\"Did not expect a name\");\n }\n JsonElement element = peek();\n if (element instanceof JsonObject) {\n pendingName = name;\n return this;\n }\n throw new IllegalStateException(\"Please begin an object before writing a name.\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":160,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(String value) throws IOException {\n if (value == null) {\n return nullValue();\n }\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":170,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(boolean value) throws IOException {\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":177,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(Boolean value) throws IOException {\n if (value == null) {\n return nullValue();\n }\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":187,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(float value) throws IOException {\n if (!isLenient() && (Float.isNaN(value) || Float.isInfinite(value))) {\n throw new IllegalArgumentException(\"JSON forbids NaN and infinities: \" + value);\n }\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":197,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(double value) throws IOException {\n if (!isLenient() && (Double.isNaN(value) || Double.isInfinite(value))) {\n throw new IllegalArgumentException(\"JSON forbids NaN and infinities: \" + value);\n }\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":207,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(long value) throws IOException {\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":214,"symbol":"value","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter value(Number value) throws IOException {\n if (value == null) {\n return nullValue();\n }\n\n if (!isLenient()) {\n double d = value.doubleValue();\n if (Double.isNaN(d) || Double.isInfinite(d)) {\n throw new IllegalArgumentException(\"JSON forbids NaN and infinities: \" + value);\n }\n }\n\n put(new JsonPrimitive(value));\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":232,"symbol":"nullValue","kind":"method","lang":"java","code":"@CanIgnoreReturnValue\n @Override\n public JsonWriter nullValue() throws IOException {\n put(JsonNull.INSTANCE);\n return this;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":239,"symbol":"jsonValue","kind":"method","lang":"java","code":"@Override\n public JsonWriter jsonValue(String value) throws IOException {\n throw new UnsupportedOperationException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":244,"symbol":"flush","kind":"method","lang":"java","code":"@Override\n public void flush() throws IOException {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java","line":247,"symbol":"close","kind":"method","lang":"java","code":"@Override\n public void close() throws IOException {\n if (!stack.isEmpty()) {\n throw new IOException(\"Incomplete document\");\n }\n stack.add(SENTINEL_CLOSED);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":115,"symbol":"MapTypeAdapterFactory","kind":"class","lang":"java","doc":"] ] } This format will serialize and deserialize just fine as long as this adapter is registered.","code":"public final class MapTypeAdapterFactory implements TypeAdapterFactory {\n private final ConstructorConstructor constructorConstructor;\n final boolean complexMapKeySerialization;\n\n public MapTypeAdapterFactory(\n ConstructorConstructor constructorConstructor, boolean complexMapKeySerialization) {\n this.constructorConstructor = constructorConstructor;\n this.complexMapKeySerialization = complexMapKeySerialization;\n }\n\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Type type = typeToken.getType();\n\n Class rawType = typeToken.getRawType();\n if (!Map.class.isAssignableFrom(rawType)) {\n return null;\n }\n\n Type[] keyAndValueTypes = GsonTypes.getMapKeyAndValueTypes(type, rawType);\n Type keyType = keyAndValueTypes[0];\n Type valueType = keyAndValueTypes[1];\n TypeAdapter keyAdapter = getKeyAdapter(gson, keyType);\n TypeAdapter wrappedKeyAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(gson, keyAdapter, keyType);\n TypeAdapter valueAdapter = gson.getAdapter(TypeToken.get(valueType));\n TypeAdapter wrappedValueAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(gson, valueAdapter, "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":119,"symbol":"MapTypeAdapterFactory","kind":"constructor","lang":"java","code":"public MapTypeAdapterFactory(\n ConstructorConstructor constructorConstructor, boolean complexMapKeySerialization) {\n this.constructorConstructor = constructorConstructor;\n this.complexMapKeySerialization = complexMapKeySerialization;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":125,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n Type type = typeToken.getType();\n\n Class rawType = typeToken.getRawType();\n if (!Map.class.isAssignableFrom(rawType)) {\n return null;\n }\n\n Type[] keyAndValueTypes = GsonTypes.getMapKeyAndValueTypes(type, rawType);\n Type keyType = keyAndValueTypes[0];\n Type valueType = keyAndValueTypes[1];\n TypeAdapter keyAdapter = getKeyAdapter(gson, keyType);\n TypeAdapter wrappedKeyAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(gson, keyAdapter, keyType);\n TypeAdapter valueAdapter = gson.getAdapter(TypeToken.get(valueType));\n TypeAdapter wrappedValueAdapter =\n new TypeAdapterRuntimeTypeWrapper<>(gson, valueAdapter, valueType);\n // Don't allow Unsafe usage to create instance; instances might be in broken state and calling\n // Map methods could lead to confusing exceptions\n boolean allowUnsafe = false;\n ObjectConstructor constructor = constructorConstructor.get(typeToken, allowUnsafe);\n\n @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n // we don't define a type parameter for the key or value types\n TypeAdapter result = n"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":155,"symbol":"getKeyAdapter","kind":"method","lang":"java","doc":"Returns a type adapter that writes the value as a string.","code":"private TypeAdapter getKeyAdapter(Gson context, Type keyType) {\n return (keyType == boolean.class || keyType == Boolean.class)\n ? TypeAdapters.BOOLEAN_AS_STRING\n : context.getAdapter(TypeToken.get(keyType));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":161,"symbol":"Adapter","kind":"class","lang":"java","code":"private final class Adapter extends TypeAdapter> {\n private final TypeAdapter keyTypeAdapter;\n private final TypeAdapter valueTypeAdapter;\n private final ObjectConstructor> constructor;\n\n Adapter(\n TypeAdapter keyTypeAdapter,\n TypeAdapter valueTypeAdapter,\n ObjectConstructor> constructor) {\n this.keyTypeAdapter = keyTypeAdapter;\n this.valueTypeAdapter = valueTypeAdapter;\n this.constructor = constructor;\n }\n\n @Override\n public Map read(JsonReader in) throws IOException {\n JsonToken peek = in.peek();\n if (peek == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n Map map = constructor.construct();\n\n if (peek == JsonToken.BEGIN_ARRAY) {\n in.beginArray();\n while (in.hasNext()) {\n in.beginArray(); // entry array\n K key = keyTypeAdapter.read(in);\n if (map.containsKey(key)) {\n throw new JsonSyntaxException(\n \"Duplicate key '\" + key + \"'; at path \" + in.getPreviousPath());\n }\n V value = valueTypeAdapter.read(in);\n map.put("} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":166,"symbol":"Adapter","kind":"constructor","lang":"java","code":"Adapter(\n TypeAdapter keyTypeAdapter,\n TypeAdapter valueTypeAdapter,\n ObjectConstructor> constructor) {\n this.keyTypeAdapter = keyTypeAdapter;\n this.valueTypeAdapter = valueTypeAdapter;\n this.constructor = constructor;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":175,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Map read(JsonReader in) throws IOException {\n JsonToken peek = in.peek();\n if (peek == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n Map map = constructor.construct();\n\n if (peek == JsonToken.BEGIN_ARRAY) {\n in.beginArray();\n while (in.hasNext()) {\n in.beginArray(); // entry array\n K key = keyTypeAdapter.read(in);\n if (map.containsKey(key)) {\n throw new JsonSyntaxException(\n \"Duplicate key '\" + key + \"'; at path \" + in.getPreviousPath());\n }\n V value = valueTypeAdapter.read(in);\n map.put(key, value);\n in.endArray();\n }\n in.endArray();\n } else {\n in.beginObject();\n while (in.hasNext()) {\n JsonReaderInternalAccess.INSTANCE.promoteNameToValue(in);\n K key = keyTypeAdapter.read(in);\n if (map.containsKey(key)) {\n throw new JsonSyntaxException(\n \"Duplicate key '\" + key + \"'; at path \" + in.getPreviousPath());\n }\n V value = valueTypeAdapter.read(in);\n map.put(key, value);\n }\n in.endObje"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":216,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Map map) throws IOException {\n if (map == null) {\n out.nullValue();\n return;\n }\n\n if (!complexMapKeySerialization) {\n out.beginObject();\n for (Map.Entry entry : map.entrySet()) {\n out.name(String.valueOf(entry.getKey()));\n valueTypeAdapter.write(out, entry.getValue());\n }\n out.endObject();\n return;\n }\n\n boolean hasComplexKeys = false;\n List keys = new ArrayList<>(map.size());\n\n List values = new ArrayList<>(map.size());\n for (Map.Entry entry : map.entrySet()) {\n JsonElement keyElement = keyTypeAdapter.toJsonTree(entry.getKey());\n keys.add(keyElement);\n values.add(entry.getValue());\n hasComplexKeys |= keyElement.isJsonArray() || keyElement.isJsonObject();\n }\n\n if (hasComplexKeys) {\n out.beginArray();\n for (int i = 0, size = keys.size(); i < size; i++) {\n out.beginArray(); // entry array\n Streams.write(keys.get(i), out);\n valueTypeAdapter.write(out, values.get(i));\n out.endArray();\n }\n out.endArray"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java","line":264,"symbol":"keyToString","kind":"method","lang":"java","code":"private String keyToString(JsonElement keyElement) {\n if (keyElement.isJsonPrimitive()) {\n JsonPrimitive primitive = keyElement.getAsJsonPrimitive();\n if (primitive.isNumber()) {\n return String.valueOf(primitive.getAsNumber());\n } else if (primitive.isBoolean()) {\n return Boolean.toString(primitive.getAsBoolean());\n } else if (primitive.isString()) {\n return primitive.getAsString();\n } else {\n throw new AssertionError();\n }\n } else if (keyElement.isJsonNull()) {\n return \"null\";\n } else {\n throw new AssertionError();\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":32,"symbol":"NumberTypeAdapter","kind":"class","lang":"java","doc":"Type adapter for {@link Number}.","code":"public final class NumberTypeAdapter extends TypeAdapter {\n /** Gson default factory using {@link ToNumberPolicy#LAZILY_PARSED_NUMBER}. */\n private static final TypeAdapterFactory LAZILY_PARSED_NUMBER_FACTORY =\n newFactory(ToNumberPolicy.LAZILY_PARSED_NUMBER);\n\n private final ToNumberStrategy toNumberStrategy;\n\n private NumberTypeAdapter(ToNumberStrategy toNumberStrategy) {\n this.toNumberStrategy = toNumberStrategy;\n }\n\n private static TypeAdapterFactory newFactory(ToNumberStrategy toNumberStrategy) {\n NumberTypeAdapter adapter = new NumberTypeAdapter(toNumberStrategy);\n return new TypeAdapterFactory() {\n @SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n return type.getRawType() == Number.class ? (TypeAdapter) adapter : null;\n }\n };\n }\n\n public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberStrategy) {\n if (toNumberStrategy == ToNumberPolicy.LAZILY_PARSED_NUMBER) {\n return LAZILY_PARSED_NUMBER_FACTORY;\n } else {\n return newFactory(toNumberStrategy);\n }\n }\n\n @Override\n public Number read(JsonReader in) throws IOException {\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":39,"symbol":"NumberTypeAdapter","kind":"constructor","lang":"java","code":"private NumberTypeAdapter(ToNumberStrategy toNumberStrategy) {\n this.toNumberStrategy = toNumberStrategy;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":43,"symbol":"newFactory","kind":"method","lang":"java","code":"private static TypeAdapterFactory newFactory(ToNumberStrategy toNumberStrategy) {\n NumberTypeAdapter adapter = new NumberTypeAdapter(toNumberStrategy);\n return new TypeAdapterFactory() {\n @SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n return type.getRawType() == Number.class ? (TypeAdapter) adapter : null;\n }\n };\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":46,"symbol":"create","kind":"method","lang":"java","code":"@SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n return type.getRawType() == Number.class ? (TypeAdapter) adapter : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":54,"symbol":"getFactory","kind":"method","lang":"java","code":"public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberStrategy) {\n if (toNumberStrategy == ToNumberPolicy.LAZILY_PARSED_NUMBER) {\n return LAZILY_PARSED_NUMBER_FACTORY;\n } else {\n return newFactory(toNumberStrategy);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":62,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Number read(JsonReader in) throws IOException {\n JsonToken jsonToken = in.peek();\n switch (jsonToken) {\n case NULL:\n in.nextNull();\n return null;\n case NUMBER:\n case STRING:\n return toNumberStrategy.readNumber(in);\n default:\n throw new JsonSyntaxException(\n \"Expecting number, got: \" + jsonToken + \"; at path \" + in.getPath());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java","line":78,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n out.value(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":40,"symbol":"ObjectTypeAdapter","kind":"class","lang":"java","doc":"Adapts types whose static type is only 'Object'. Uses getClass() on serialization and a primitive/Map/List on deserialization.","code":"public final class ObjectTypeAdapter extends TypeAdapter {\n /** Gson default factory using {@link ToNumberPolicy#DOUBLE}. */\n private static final TypeAdapterFactory DOUBLE_FACTORY = newFactory(ToNumberPolicy.DOUBLE);\n\n private final Gson gson;\n private final ToNumberStrategy toNumberStrategy;\n\n private ObjectTypeAdapter(Gson gson, ToNumberStrategy toNumberStrategy) {\n this.gson = gson;\n this.toNumberStrategy = toNumberStrategy;\n }\n\n private static TypeAdapterFactory newFactory(ToNumberStrategy toNumberStrategy) {\n return new TypeAdapterFactory() {\n @SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n if (type.getRawType() == Object.class) {\n return (TypeAdapter) new ObjectTypeAdapter(gson, toNumberStrategy);\n }\n return null;\n }\n };\n }\n\n public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberStrategy) {\n if (toNumberStrategy == ToNumberPolicy.DOUBLE) {\n return DOUBLE_FACTORY;\n } else {\n return newFactory(toNumberStrategy);\n }\n }\n\n /**\n * Tries to begin reading a JSON array or JSON object, returning {@code null"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":47,"symbol":"ObjectTypeAdapter","kind":"constructor","lang":"java","code":"private ObjectTypeAdapter(Gson gson, ToNumberStrategy toNumberStrategy) {\n this.gson = gson;\n this.toNumberStrategy = toNumberStrategy;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":52,"symbol":"newFactory","kind":"method","lang":"java","code":"private static TypeAdapterFactory newFactory(ToNumberStrategy toNumberStrategy) {\n return new TypeAdapterFactory() {\n @SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n if (type.getRawType() == Object.class) {\n return (TypeAdapter) new ObjectTypeAdapter(gson, toNumberStrategy);\n }\n return null;\n }\n };\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":54,"symbol":"create","kind":"method","lang":"java","code":"@SuppressWarnings(\"unchecked\")\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n if (type.getRawType() == Object.class) {\n return (TypeAdapter) new ObjectTypeAdapter(gson, toNumberStrategy);\n }\n return null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":65,"symbol":"getFactory","kind":"method","lang":"java","code":"public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberStrategy) {\n if (toNumberStrategy == ToNumberPolicy.DOUBLE) {\n return DOUBLE_FACTORY;\n } else {\n return newFactory(toNumberStrategy);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":77,"symbol":"tryBeginNesting","kind":"method","lang":"java","doc":"Tries to begin reading a JSON array or JSON object, returning {@code null} if the next element is neither of those.","code":"private Object tryBeginNesting(JsonReader in, JsonToken peeked) throws IOException {\n switch (peeked) {\n case BEGIN_ARRAY:\n in.beginArray();\n return new ArrayList<>();\n case BEGIN_OBJECT:\n in.beginObject();\n return new LinkedHashMap<>();\n default:\n return null;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":91,"symbol":"readTerminal","kind":"method","lang":"java","doc":"Reads an {@code Object} which cannot have any nested elements","code":"private Object readTerminal(JsonReader in, JsonToken peeked) throws IOException {\n switch (peeked) {\n case STRING:\n return in.nextString();\n case NUMBER:\n return toNumberStrategy.readNumber(in);\n case BOOLEAN:\n return in.nextBoolean();\n case NULL:\n in.nextNull();\n return null;\n default:\n // When read(JsonReader) is called with JsonReader in invalid state\n throw new IllegalStateException(\"Unexpected token: \" + peeked);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":108,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Object read(JsonReader in) throws IOException {\n // Either List or Map\n Object current;\n JsonToken peeked = in.peek();\n\n current = tryBeginNesting(in, peeked);\n if (current == null) {\n return readTerminal(in, peeked);\n }\n\n Deque stack = new ArrayDeque<>();\n\n while (true) {\n while (in.hasNext()) {\n String name = null;\n // Name is only used for JSON object members\n if (current instanceof Map) {\n name = in.nextName();\n }\n\n peeked = in.peek();\n Object value = tryBeginNesting(in, peeked);\n boolean isNesting = value != null;\n\n if (value == null) {\n value = readTerminal(in, peeked);\n }\n\n if (current instanceof List) {\n @SuppressWarnings(\"unchecked\")\n List list = (List) current;\n list.add(value);\n } else {\n @SuppressWarnings(\"unchecked\")\n Map map = (Map) current;\n map.put(name, value);\n }\n\n if (isNesting) {\n stack.addLast(current);\n current = value;\n }\n }\n\n // End current element\n if"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java","line":169,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Object value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n\n @SuppressWarnings(\"unchecked\")\n TypeAdapter typeAdapter = (TypeAdapter) gson.getAdapter(value.getClass());\n if (typeAdapter instanceof ObjectTypeAdapter) {\n out.beginObject();\n out.endObject();\n return;\n }\n\n typeAdapter.write(out, value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":60,"symbol":"ReflectiveTypeAdapterFactory","kind":"class","lang":"java","doc":"Type adapter that reflects over the fields and methods of a class.","code":"public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {\n private final ConstructorConstructor constructorConstructor;\n private final FieldNamingStrategy fieldNamingPolicy;\n private final Excluder excluder;\n private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;\n private final List reflectionFilters;\n\n public ReflectiveTypeAdapterFactory(\n ConstructorConstructor constructorConstructor,\n FieldNamingStrategy fieldNamingPolicy,\n Excluder excluder,\n JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory,\n List reflectionFilters) {\n this.constructorConstructor = constructorConstructor;\n this.fieldNamingPolicy = fieldNamingPolicy;\n this.excluder = excluder;\n this.jsonAdapterFactory = jsonAdapterFactory;\n this.reflectionFilters = reflectionFilters;\n }\n\n private boolean includeField(Field f, boolean serialize) {\n return !excluder.excludeField(f, serialize);\n }\n\n /** first element holds the default name */\n @SuppressWarnings(\"MixedMutabilityReturnType\")\n private List getFieldNames(Field f) {\n\n String fieldName;\n List alter"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":67,"symbol":"ReflectiveTypeAdapterFactory","kind":"constructor","lang":"java","code":"public ReflectiveTypeAdapterFactory(\n ConstructorConstructor constructorConstructor,\n FieldNamingStrategy fieldNamingPolicy,\n Excluder excluder,\n JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory,\n List reflectionFilters) {\n this.constructorConstructor = constructorConstructor;\n this.fieldNamingPolicy = fieldNamingPolicy;\n this.excluder = excluder;\n this.jsonAdapterFactory = jsonAdapterFactory;\n this.reflectionFilters = reflectionFilters;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":80,"symbol":"includeField","kind":"method","lang":"java","code":"private boolean includeField(Field f, boolean serialize) {\n return !excluder.excludeField(f, serialize);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":85,"symbol":"getFieldNames","kind":"method","lang":"java","doc":"first element holds the default name","code":"@SuppressWarnings(\"MixedMutabilityReturnType\")\n private List getFieldNames(Field f) {\n\n String fieldName;\n List alternates;\n SerializedName annotation = f.getAnnotation(SerializedName.class);\n if (annotation == null) {\n fieldName = fieldNamingPolicy.translateName(f);\n alternates = fieldNamingPolicy.alternateNames(f);\n } else {\n fieldName = annotation.value();\n alternates = Arrays.asList(annotation.alternate());\n }\n\n if (alternates.isEmpty()) {\n return Collections.singletonList(fieldName);\n }\n\n List fieldNames = new ArrayList<>(alternates.size() + 1);\n fieldNames.add(fieldName);\n fieldNames.addAll(alternates);\n return fieldNames;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":109,"symbol":"create","kind":"method","lang":"java","code":"@Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n Class raw = type.getRawType();\n\n if (!Object.class.isAssignableFrom(raw)) {\n return null; // it's a primitive!\n }\n\n // Don't allow using reflection on anonymous and local classes because synthetic fields for\n // captured enclosing values make this unreliable\n if (ReflectionHelper.isAnonymousOrNonStaticLocal(raw)) {\n // This adapter just serializes and deserializes null, ignoring the actual values\n // This is done for backward compatibility; troubleshooting-wise it might be better to throw\n // exceptions\n return new TypeAdapter() {\n @Override\n public T read(JsonReader in) throws IOException {\n in.skipValue();\n return null;\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n out.nullValue();\n }\n\n @Override\n public String toString() {\n return \"AnonymousOrNonStaticLocalClassAdapter\";\n }\n };\n }\n\n FilterResult filterResult =\n ReflectionAccessFilterHelper.getFilterResult(reflectionFilters, raw);\n if (filterRes"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":124,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n in.skipValue();\n return null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":130,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n out.nullValue();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":135,"symbol":"toString","kind":"method","lang":"java","code":"@Override\n public String toString() {\n return \"AnonymousOrNonStaticLocalClassAdapter\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":168,"symbol":"checkAccessible","kind":"method","lang":"java","code":"private static void checkAccessible(\n Object object, M member) {\n if (!ReflectionAccessFilterHelper.canAccess(\n member, Modifier.isStatic(member.getModifiers()) ? null : object)) {\n String memberDescription = ReflectionHelper.getAccessibleObjectDescription(member, true);\n throw new JsonIOException(\n memberDescription\n + \" is not accessible and ReflectionAccessFilter does not permit making it\"\n + \" accessible. Register a TypeAdapter for the declaring type, adjust the access\"\n + \" filter or increase the visibility of the element and its declaring type.\");\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":181,"symbol":"createBoundField","kind":"method","lang":"java","code":"private BoundField createBoundField(\n Gson context,\n Field field,\n Method accessor,\n String serializedName,\n TypeToken fieldType,\n boolean serialize,\n boolean blockInaccessible) {\n\n boolean isPrimitive = Primitives.isPrimitive(fieldType.getRawType());\n\n int modifiers = field.getModifiers();\n boolean isStaticFinalField = Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);\n\n JsonAdapter annotation = field.getAnnotation(JsonAdapter.class);\n TypeAdapter mapped = null;\n if (annotation != null) {\n // This is not safe; requires that user has specified correct adapter class for @JsonAdapter\n mapped =\n jsonAdapterFactory.getTypeAdapter(\n constructorConstructor, context, fieldType, annotation, false);\n }\n boolean jsonAdapterPresent = mapped != null;\n if (mapped == null) {\n mapped = context.getAdapter(fieldType);\n }\n\n @SuppressWarnings(\"unchecked\")\n TypeAdapter typeAdapter = (TypeAdapter) mapped;\n TypeAdapter writeTypeAdapter;\n if (serialize) {\n writeTypeAdapter =\n jsonAdapterPresent\n ? typeAdapter\n : n"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":236,"symbol":"write","kind":"method","lang":"java","code":"@Override\n void write(JsonWriter writer, Object source) throws IOException, IllegalAccessException {\n if (blockInaccessible) {\n if (!knownAccessible) {\n if (accessor == null) {\n checkAccessible(source, field);\n } else {\n // Note: This check might actually be redundant because access check for canonical\n // constructor should have failed already\n checkAccessible(source, accessor);\n }\n knownAccessible = true;\n }\n }\n\n Object fieldValue;\n if (accessor != null) {\n try {\n fieldValue = accessor.invoke(source);\n } catch (InvocationTargetException e) {\n String accessorDescription =\n ReflectionHelper.getAccessibleObjectDescription(accessor, false);\n throw new JsonIOException(\n \"Accessor \" + accessorDescription + \" threw exception\", e.getCause());\n }\n } else {\n fieldValue = field.get(source);\n }\n\n @SuppressWarnings(\"ReferenceEquality\")\n boolean isSameObject = fieldValue == source;\n if (isSameObject) {\n // av"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":275,"symbol":"readIntoArray","kind":"method","lang":"java","code":"@Override\n void readIntoArray(JsonReader reader, int index, Object[] target)\n throws IOException, JsonParseException {\n Object fieldValue = typeAdapter.read(reader);\n if (fieldValue == null && isPrimitive) {\n throw new JsonParseException(\n \"null is not allowed as value for record component '\"\n + fieldName\n + \"' of primitive type; at path \"\n + reader.getPath());\n }\n target[index] = fieldValue;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":289,"symbol":"readIntoField","kind":"method","lang":"java","code":"@Override\n void readIntoField(JsonReader reader, Object target)\n throws IOException, IllegalAccessException {\n Object fieldValue = typeAdapter.read(reader);\n if (fieldValue != null || !isPrimitive) {\n if (blockInaccessible) {\n if (!knownAccessible) {\n checkAccessible(target, field);\n knownAccessible = true;\n }\n } else if (isStaticFinalField) {\n // Reflection does not permit setting value of `static final` field, even after calling\n // `setAccessible`\n // Handle this here to avoid causing IllegalAccessException when calling `Field.set`\n String fieldDescription = ReflectionHelper.getAccessibleObjectDescription(field, false);\n throw new JsonIOException(\"Cannot set value of 'static final' \" + fieldDescription);\n }\n field.set(target, fieldValue);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":312,"symbol":"FieldsData","kind":"class","lang":"java","code":"private static class FieldsData {\n static final FieldsData EMPTY = new FieldsData(Collections.emptyMap(), Collections.emptyList());\n\n /** Maps from JSON member name to field */\n final Map deserializedFields;\n\n final List serializedFields;\n\n FieldsData(Map deserializedFields, List serializedFields) {\n this.deserializedFields = deserializedFields;\n this.serializedFields = serializedFields;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":320,"symbol":"FieldsData","kind":"constructor","lang":"java","code":"FieldsData(Map deserializedFields, List serializedFields) {\n this.deserializedFields = deserializedFields;\n this.serializedFields = serializedFields;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":326,"symbol":"createDuplicateFieldException","kind":"method","lang":"java","code":"private static IllegalArgumentException createDuplicateFieldException(\n Class declaringType, String duplicateName, Field field1, Field field2) {\n throw new IllegalArgumentException(\n \"Class \"\n + declaringType.getName()\n + \" declares multiple JSON fields named '\"\n + duplicateName\n + \"'; conflict is caused by fields \"\n + ReflectionHelper.fieldToString(field1)\n + \" and \"\n + ReflectionHelper.fieldToString(field2)\n + \"\\nSee \"\n + TroubleshootingGuide.createUrl(\"duplicate-fields\"));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":341,"symbol":"getBoundFields","kind":"method","lang":"java","code":"private FieldsData getBoundFields(\n Gson context, TypeToken type, Class raw, boolean blockInaccessible, boolean isRecord) {\n if (raw.isInterface()) {\n return FieldsData.EMPTY;\n }\n\n Map deserializedFields = new LinkedHashMap<>();\n // For serialized fields use a Map to track duplicate field names; otherwise this could be a\n // List instead\n Map serializedFields = new LinkedHashMap<>();\n\n Class originalRaw = raw;\n while (raw != Object.class) {\n Field[] fields = raw.getDeclaredFields();\n\n // For inherited fields, check if access to their declaring class is allowed\n if (raw != originalRaw && fields.length > 0) {\n FilterResult filterResult =\n ReflectionAccessFilterHelper.getFilterResult(reflectionFilters, raw);\n if (filterResult == FilterResult.BLOCK_ALL) {\n throw new JsonIOException(\n \"ReflectionAccessFilter does not permit using reflection for \"\n + raw\n + \" (supertype of \"\n + originalRaw\n + \"). Register a TypeAdapter for this type or adjust the access filter.\");\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":452,"symbol":"BoundField","kind":"class","lang":"java","code":"abstract static class BoundField {\n /** Name used for serialization (but not for deserialization) */\n final String serializedName;\n\n final Field field;\n\n /** Name of the underlying field */\n final String fieldName;\n\n protected BoundField(String serializedName, Field field) {\n this.serializedName = serializedName;\n this.field = field;\n this.fieldName = field.getName();\n }\n\n /** Read this field value from the source, and append its JSON value to the writer */\n abstract void write(JsonWriter writer, Object source)\n throws IOException, IllegalAccessException;\n\n /** Read the value into the target array, used to provide constructor arguments for records */\n abstract void readIntoArray(JsonReader reader, int index, Object[] target)\n throws IOException, JsonParseException;\n\n /**\n * Read the value from the reader, and set it on the corresponding field on target via\n * reflection\n */\n abstract void readIntoField(JsonReader reader, Object target)\n throws IOException, IllegalAccessException;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":461,"symbol":"BoundField","kind":"constructor","lang":"java","code":"protected BoundField(String serializedName, Field field) {\n this.serializedName = serializedName;\n this.field = field;\n this.fieldName = field.getName();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":468,"symbol":"write","kind":"method","lang":"java","doc":"Read this field value from the source, and append its JSON value to the writer","code":"abstract void write(JsonWriter writer, Object source)\n throws IOException, IllegalAccessException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":472,"symbol":"readIntoArray","kind":"method","lang":"java","doc":"Read the value into the target array, used to provide constructor arguments for records","code":"abstract void readIntoArray(JsonReader reader, int index, Object[] target)\n throws IOException, JsonParseException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":479,"symbol":"readIntoField","kind":"method","lang":"java","doc":"Read the value from the reader, and set it on the corresponding field on target via reflection","code":"abstract void readIntoField(JsonReader reader, Object target)\n throws IOException, IllegalAccessException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":498,"symbol":"Adapter","kind":"class","lang":"java","doc":"@param type of objects that this Adapter creates. @param type of accumulator used to build the deserialization result. This class is public because external projects check for this class with `instanceof` (even though it is internal)","code":"public abstract static class Adapter extends TypeAdapter {\n private final FieldsData fieldsData;\n\n private Adapter(FieldsData fieldsData) {\n this.fieldsData = fieldsData;\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n\n out.beginObject();\n try {\n for (BoundField boundField : fieldsData.serializedFields) {\n boundField.write(out, value);\n }\n } catch (IllegalAccessException e) {\n throw ReflectionHelper.createExceptionForUnexpectedIllegalAccess(e);\n }\n out.endObject();\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n A accumulator = createAccumulator();\n Map deserializedFields = fieldsData.deserializedFields;\n\n try {\n in.beginObject();\n while (in.hasNext()) {\n String name = in.nextName();\n BoundField field = deserializedFields.get(name);\n if (field == null) {\n in.skipValue();\n } else"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":501,"symbol":"Adapter","kind":"constructor","lang":"java","code":"private Adapter(FieldsData fieldsData) {\n this.fieldsData = fieldsData;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":505,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n\n out.beginObject();\n try {\n for (BoundField boundField : fieldsData.serializedFields) {\n boundField.write(out, value);\n }\n } catch (IllegalAccessException e) {\n throw ReflectionHelper.createExceptionForUnexpectedIllegalAccess(e);\n }\n out.endObject();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":523,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n A accumulator = createAccumulator();\n Map deserializedFields = fieldsData.deserializedFields;\n\n try {\n in.beginObject();\n while (in.hasNext()) {\n String name = in.nextName();\n BoundField field = deserializedFields.get(name);\n if (field == null) {\n in.skipValue();\n } else {\n readField(accumulator, in, field);\n }\n }\n } catch (IllegalStateException e) {\n throw new JsonSyntaxException(e);\n } catch (IllegalAccessException e) {\n throw ReflectionHelper.createExceptionForUnexpectedIllegalAccess(e);\n }\n in.endObject();\n return finalize(accumulator);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":554,"symbol":"createAccumulator","kind":"method","lang":"java","doc":"Create the Object that will be used to collect each field value","code":"abstract A createAccumulator();"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":560,"symbol":"readField","kind":"method","lang":"java","doc":"Read a single BoundField into the accumulator. The JsonReader will be pointed at the start of the value for the BoundField to read from.","code":"abstract void readField(A accumulator, JsonReader in, BoundField field)\n throws IllegalAccessException, IOException;"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":564,"symbol":"finalize","kind":"method","lang":"java","doc":"Convert the accumulator to a final instance of T.","code":"abstract T finalize(A accumulator);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":567,"symbol":"FieldReflectionAdapter","kind":"class","lang":"java","code":"private static final class FieldReflectionAdapter extends Adapter {\n private final ObjectConstructor constructor;\n\n FieldReflectionAdapter(ObjectConstructor constructor, FieldsData fieldsData) {\n super(fieldsData);\n this.constructor = constructor;\n }\n\n @Override\n T createAccumulator() {\n return constructor.construct();\n }\n\n @Override\n void readField(T accumulator, JsonReader in, BoundField field)\n throws IllegalAccessException, IOException {\n field.readIntoField(in, accumulator);\n }\n\n @Override\n T finalize(T accumulator) {\n return accumulator;\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":570,"symbol":"FieldReflectionAdapter","kind":"constructor","lang":"java","code":"FieldReflectionAdapter(ObjectConstructor constructor, FieldsData fieldsData) {\n super(fieldsData);\n this.constructor = constructor;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":575,"symbol":"createAccumulator","kind":"method","lang":"java","code":"@Override\n T createAccumulator() {\n return constructor.construct();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":580,"symbol":"readField","kind":"method","lang":"java","code":"@Override\n void readField(T accumulator, JsonReader in, BoundField field)\n throws IllegalAccessException, IOException {\n field.readIntoField(in, accumulator);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":586,"symbol":"finalize","kind":"method","lang":"java","code":"@Override\n T finalize(T accumulator) {\n return accumulator;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":592,"symbol":"RecordAdapter","kind":"class","lang":"java","code":"private static final class RecordAdapter extends Adapter {\n static final Map, Object> PRIMITIVE_DEFAULTS = primitiveDefaults();\n\n // The canonical constructor of the record\n private final Constructor constructor;\n // Array of arguments to the constructor, initialized with default values for primitives\n private final Object[] constructorArgsDefaults;\n // Map from component names to index into the constructors arguments.\n private final Map componentIndices = new HashMap<>();\n\n RecordAdapter(Class raw, FieldsData fieldsData, boolean blockInaccessible) {\n super(fieldsData);\n constructor = ReflectionHelper.getCanonicalRecordConstructor(raw);\n\n if (blockInaccessible) {\n checkAccessible(null, constructor);\n } else {\n // Ensure the constructor is accessible\n ReflectionHelper.makeAccessible(constructor);\n }\n\n String[] componentNames = ReflectionHelper.getRecordComponentNames(raw);\n for (int i = 0; i < componentNames.length; i++) {\n componentIndices.put(componentNames[i], i);\n }\n Class[] parameterTypes = constructor.getParameterTypes();\n\n //"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":602,"symbol":"RecordAdapter","kind":"constructor","lang":"java","code":"RecordAdapter(Class raw, FieldsData fieldsData, boolean blockInaccessible) {\n super(fieldsData);\n constructor = ReflectionHelper.getCanonicalRecordConstructor(raw);\n\n if (blockInaccessible) {\n checkAccessible(null, constructor);\n } else {\n // Ensure the constructor is accessible\n ReflectionHelper.makeAccessible(constructor);\n }\n\n String[] componentNames = ReflectionHelper.getRecordComponentNames(raw);\n for (int i = 0; i < componentNames.length; i++) {\n componentIndices.put(componentNames[i], i);\n }\n Class[] parameterTypes = constructor.getParameterTypes();\n\n // We need to ensure that we are passing non-null values to primitive fields in the\n // constructor. To do this, we create an Object[] where all primitives are initialized to\n // non-null values.\n constructorArgsDefaults = new Object[parameterTypes.length];\n for (int i = 0; i < parameterTypes.length; i++) {\n // This will correctly be null for non-primitive types:\n constructorArgsDefaults[i] = PRIMITIVE_DEFAULTS.get(parameterTypes[i]);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":629,"symbol":"primitiveDefaults","kind":"method","lang":"java","code":"private static Map, Object> primitiveDefaults() {\n Map, Object> zeroes = new HashMap<>();\n zeroes.put(byte.class, (byte) 0);\n zeroes.put(short.class, (short) 0);\n zeroes.put(int.class, 0);\n zeroes.put(long.class, 0L);\n zeroes.put(float.class, 0F);\n zeroes.put(double.class, 0D);\n zeroes.put(char.class, '\\0');\n zeroes.put(boolean.class, false);\n return zeroes;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":642,"symbol":"createAccumulator","kind":"method","lang":"java","code":"@Override\n Object[] createAccumulator() {\n return constructorArgsDefaults.clone();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":647,"symbol":"readField","kind":"method","lang":"java","code":"@Override\n void readField(Object[] accumulator, JsonReader in, BoundField field) throws IOException {\n // Obtain the component index from the name of the field backing it\n Integer componentIndex = componentIndices.get(field.fieldName);\n if (componentIndex == null) {\n throw new IllegalStateException(\n \"Could not find the index in the constructor '\"\n + ReflectionHelper.constructorToString(constructor)\n + \"' for field with name '\"\n + field.fieldName\n + \"', unable to determine which argument in the constructor the field corresponds\"\n + \" to. This is unexpected behavior, as we expect the RecordComponents to have the\"\n + \" same names as the fields in the Java class, and that the order of the\"\n + \" RecordComponents is the same as the order of the canonical constructor\"\n + \" parameters.\");\n }\n field.readIntoArray(in, componentIndex, accumulator);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java","line":666,"symbol":"finalize","kind":"method","lang":"java","code":"@Override\n T finalize(Object[] accumulator) {\n try {\n return constructor.newInstance(accumulator);\n } catch (IllegalAccessException e) {\n throw ReflectionHelper.createExceptionForUnexpectedIllegalAccess(e);\n }\n // Note: InstantiationException should be impossible because record class is not abstract;\n // IllegalArgumentException should not be possible unless a bad adapter returns objects of\n // the wrong type\n catch (InstantiationException | IllegalArgumentException e) {\n throw new RuntimeException(\n \"Failed to invoke constructor '\"\n + ReflectionHelper.constructorToString(constructor)\n + \"' with args \"\n + Arrays.toString(accumulator),\n e);\n } catch (InvocationTargetException e) {\n // TODO: JsonParseException ?\n throw new RuntimeException(\n \"Failed to invoke constructor '\"\n + ReflectionHelper.constructorToString(constructor)\n + \"' with args \"\n + Arrays.toString(accumulator),\n e.getCause());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/SerializationDelegatingTypeAdapter.java","line":22,"symbol":"SerializationDelegatingTypeAdapter","kind":"class","lang":"java","doc":"Type adapter which might delegate serialization to another adapter.","code":"public abstract class SerializationDelegatingTypeAdapter extends TypeAdapter {\n /**\n * Returns the adapter used for serialization, might be {@code this} or another adapter. That\n * other adapter might itself also be a {@code SerializationDelegatingTypeAdapter}.\n */\n public abstract TypeAdapter getSerializationDelegate();\n}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/SerializationDelegatingTypeAdapter.java","line":27,"symbol":"getSerializationDelegate","kind":"method","lang":"java","doc":"Returns the adapter used for serialization, might be {@code this} or another adapter. That other adapter might itself also be a {@code SerializationDelegatingTypeAdapter}.","code":"public abstract TypeAdapter getSerializationDelegate();"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":41,"symbol":"TreeTypeAdapter","kind":"class","lang":"java","doc":"Adapts a Gson 1.x tree-style adapter as a streaming TypeAdapter. Since the tree adapter may be serialization-only or deserialization-only, this class has a facility to look up a delegate type adapter on demand.","code":"public final class TreeTypeAdapter extends SerializationDelegatingTypeAdapter {\n private final JsonSerializer serializer;\n private final JsonDeserializer deserializer;\n final Gson gson;\n private final TypeToken typeToken;\n\n /**\n * Only intended as {@code skipPast} for {@link Gson#getDelegateAdapter(TypeAdapterFactory,\n * TypeToken)}, must not be used in any other way.\n */\n private final TypeAdapterFactory skipPastForGetDelegateAdapter;\n\n private final GsonContextImpl context = new GsonContextImpl();\n private final boolean nullSafe;\n\n /**\n * The delegate is lazily created because it may not be needed, and creating it may fail. Field\n * has to be {@code volatile} because {@link Gson} guarantees to be thread-safe.\n */\n private volatile TypeAdapter delegate;\n\n public TreeTypeAdapter(\n JsonSerializer serializer,\n JsonDeserializer deserializer,\n Gson gson,\n TypeToken typeToken,\n TypeAdapterFactory skipPast,\n boolean nullSafe) {\n this.serializer = serializer;\n this.deserializer = deserializer;\n this.gson = gson;\n this.typeToken = typeToken;\n this.skipPastForGetDelegateAdapter = skipPast;\n thi"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":62,"symbol":"TreeTypeAdapter","kind":"constructor","lang":"java","code":"public TreeTypeAdapter(\n JsonSerializer serializer,\n JsonDeserializer deserializer,\n Gson gson,\n TypeToken typeToken,\n TypeAdapterFactory skipPast,\n boolean nullSafe) {\n this.serializer = serializer;\n this.deserializer = deserializer;\n this.gson = gson;\n this.typeToken = typeToken;\n this.skipPastForGetDelegateAdapter = skipPast;\n this.nullSafe = nullSafe;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":77,"symbol":"TreeTypeAdapter","kind":"constructor","lang":"java","code":"public TreeTypeAdapter(\n JsonSerializer serializer,\n JsonDeserializer deserializer,\n Gson gson,\n TypeToken typeToken,\n TypeAdapterFactory skipPast) {\n this(serializer, deserializer, gson, typeToken, skipPast, true);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":86,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n if (deserializer == null) {\n return delegate().read(in);\n }\n JsonElement value = Streams.parse(in);\n if (nullSafe && value.isJsonNull()) {\n return null;\n }\n return deserializer.deserialize(value, typeToken.getType(), context);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":98,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n if (serializer == null) {\n delegate().write(out, value);\n return;\n }\n if (nullSafe && value == null) {\n out.nullValue();\n return;\n }\n JsonElement tree = serializer.serialize(value, typeToken.getType(), context);\n Streams.write(tree, out);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":112,"symbol":"delegate","kind":"method","lang":"java","code":"private TypeAdapter delegate() {\n // A race might lead to `delegate` being assigned by multiple threads but the last assignment\n // will stick\n TypeAdapter d = delegate;\n if (d == null) {\n d = delegate = gson.getDelegateAdapter(skipPastForGetDelegateAdapter, typeToken);\n }\n return d;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":126,"symbol":"getSerializationDelegate","kind":"method","lang":"java","doc":"Returns the type adapter which is used for serialization. Returns {@code this} if this {@code TreeTypeAdapter} has a {@link #serializer}; otherwise returns the delegate.","code":"@Override\n public TypeAdapter getSerializationDelegate() {\n return serializer != null ? this : delegate();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":132,"symbol":"newFactory","kind":"method","lang":"java","doc":"Returns a new factory that will match each type against {@code exactType}.","code":"public static TypeAdapterFactory newFactory(TypeToken exactType, Object typeAdapter) {\n return new SingleTypeFactory(typeAdapter, exactType, false, null);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":137,"symbol":"newFactoryWithMatchRawType","kind":"method","lang":"java","doc":"Returns a new factory that will match each type and its raw type against {@code exactType}.","code":"public static TypeAdapterFactory newFactoryWithMatchRawType(\n TypeToken exactType, Object typeAdapter) {\n // only bother matching raw types if exact type is a raw type\n boolean matchRawType = exactType.getType() == exactType.getRawType();\n return new SingleTypeFactory(typeAdapter, exactType, matchRawType, null);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":148,"symbol":"newTypeHierarchyFactory","kind":"method","lang":"java","doc":"Returns a new factory that will match each type's raw type for assignability to {@code hierarchyType}.","code":"public static TypeAdapterFactory newTypeHierarchyFactory(\n Class hierarchyType, Object typeAdapter) {\n return new SingleTypeFactory(typeAdapter, null, false, hierarchyType);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":153,"symbol":"SingleTypeFactory","kind":"class","lang":"java","code":"private static final class SingleTypeFactory implements TypeAdapterFactory {\n private final TypeToken exactType;\n private final boolean matchRawType;\n private final Class hierarchyType;\n private final JsonSerializer serializer;\n private final JsonDeserializer deserializer;\n\n SingleTypeFactory(\n Object typeAdapter, TypeToken exactType, boolean matchRawType, Class hierarchyType) {\n serializer = typeAdapter instanceof JsonSerializer ? (JsonSerializer) typeAdapter : null;\n deserializer =\n typeAdapter instanceof JsonDeserializer ? (JsonDeserializer) typeAdapter : null;\n if (serializer == null && deserializer == null) {\n Objects.requireNonNull(typeAdapter);\n throw new IllegalArgumentException(\n \"Type adapter \"\n + typeAdapter.getClass().getName()\n + \" must implement JsonSerializer or JsonDeserializer\");\n }\n this.exactType = exactType;\n this.matchRawType = matchRawType;\n this.hierarchyType = hierarchyType;\n }\n\n @SuppressWarnings(\"unchecked\") // guarded by typeToken.equals() call\n @Override\n public TypeAdapter create(Gson gson"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":160,"symbol":"SingleTypeFactory","kind":"constructor","lang":"java","code":"SingleTypeFactory(\n Object typeAdapter, TypeToken exactType, boolean matchRawType, Class hierarchyType) {\n serializer = typeAdapter instanceof JsonSerializer ? (JsonSerializer) typeAdapter : null;\n deserializer =\n typeAdapter instanceof JsonDeserializer ? (JsonDeserializer) typeAdapter : null;\n if (serializer == null && deserializer == null) {\n Objects.requireNonNull(typeAdapter);\n throw new IllegalArgumentException(\n \"Type adapter \"\n + typeAdapter.getClass().getName()\n + \" must implement JsonSerializer or JsonDeserializer\");\n }\n this.exactType = exactType;\n this.matchRawType = matchRawType;\n this.hierarchyType = hierarchyType;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":177,"symbol":"create","kind":"method","lang":"java","code":"@SuppressWarnings(\"unchecked\") // guarded by typeToken.equals() call\n @Override\n public TypeAdapter create(Gson gson, TypeToken type) {\n boolean matches =\n exactType != null\n ? exactType.equals(type) || (matchRawType && exactType.getType() == type.getRawType())\n : hierarchyType.isAssignableFrom(type.getRawType());\n return matches\n ? new TreeTypeAdapter<>(\n (JsonSerializer) serializer, (JsonDeserializer) deserializer, gson, type, this)\n : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":191,"symbol":"GsonContextImpl","kind":"class","lang":"java","code":"private final class GsonContextImpl\n implements JsonSerializationContext, JsonDeserializationContext {\n @Override\n public JsonElement serialize(Object src) {\n return gson.toJsonTree(src);\n }\n\n @Override\n public JsonElement serialize(Object src, Type typeOfSrc) {\n return gson.toJsonTree(src, typeOfSrc);\n }\n\n @Override\n @SuppressWarnings(\"TypeParameterUnusedInFormals\")\n public R deserialize(JsonElement json, Type typeOfT) throws JsonParseException {\n return gson.fromJson(json, typeOfT);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":193,"symbol":"serialize","kind":"method","lang":"java","code":"@Override\n public JsonElement serialize(Object src) {\n return gson.toJsonTree(src);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":198,"symbol":"serialize","kind":"method","lang":"java","code":"@Override\n public JsonElement serialize(Object src, Type typeOfSrc) {\n return gson.toJsonTree(src, typeOfSrc);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java","line":203,"symbol":"deserialize","kind":"method","lang":"java","code":"@Override\n @SuppressWarnings(\"TypeParameterUnusedInFormals\")\n public R deserialize(JsonElement json, Type typeOfT) throws JsonParseException {\n return gson.fromJson(json, typeOfT);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java","line":28,"symbol":"TypeAdapterRuntimeTypeWrapper","kind":"class","lang":"java","code":"final class TypeAdapterRuntimeTypeWrapper extends TypeAdapter {\n private final Gson context;\n private final TypeAdapter delegate;\n private final Type type;\n\n TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter delegate, Type type) {\n this.context = context;\n this.delegate = delegate;\n this.type = type;\n }\n\n @Override\n public T read(JsonReader in) throws IOException {\n return delegate.read(in);\n }\n\n @Override\n public void write(JsonWriter out, T value) throws IOException {\n // Order of preference for choosing type adapters\n // First preference: a type adapter registered for the runtime type\n // Second preference: a type adapter registered for the declared type\n // Third preference: reflective type adapter for the runtime type\n // (if it is a subclass of the declared type)\n // Fourth preference: reflective type adapter for the declared type\n\n TypeAdapter chosen = delegate;\n Type runtimeType = getRuntimeTypeIfMoreSpecific(type, value);\n\n @SuppressWarnings(\"ReferenceEquality\")\n boolean isDifferentType = runtimeType != type;\n if (isDifferentType) {\n @SuppressWarnings(\"unchecked\")\n TypeA"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java","line":33,"symbol":"TypeAdapterRuntimeTypeWrapper","kind":"constructor","lang":"java","code":"TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter delegate, Type type) {\n this.context = context;\n this.delegate = delegate;\n this.type = type;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java","line":39,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public T read(JsonReader in) throws IOException {\n return delegate.read(in);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java","line":44,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, T value) throws IOException {\n // Order of preference for choosing type adapters\n // First preference: a type adapter registered for the runtime type\n // Second preference: a type adapter registered for the declared type\n // Third preference: reflective type adapter for the runtime type\n // (if it is a subclass of the declared type)\n // Fourth preference: reflective type adapter for the declared type\n\n TypeAdapter chosen = delegate;\n Type runtimeType = getRuntimeTypeIfMoreSpecific(type, value);\n\n @SuppressWarnings(\"ReferenceEquality\")\n boolean isDifferentType = runtimeType != type;\n if (isDifferentType) {\n @SuppressWarnings(\"unchecked\")\n TypeAdapter runtimeTypeAdapter =\n (TypeAdapter) context.getAdapter(TypeToken.get(runtimeType));\n // For backward compatibility only check ReflectiveTypeAdapterFactory.Adapter here but not any\n // other wrapping adapters, see\n // https://github.com/google/gson/pull/1787#issuecomment-1222175189\n if (!(runtimeTypeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter)) {\n // The user registered a type"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java","line":85,"symbol":"isReflective","kind":"method","lang":"java","doc":"Returns whether the type adapter uses reflection. @param typeAdapter the type adapter to check.","code":"private static boolean isReflective(TypeAdapter typeAdapter) {\n // Run this in loop in case multiple delegating adapters are nested\n while (typeAdapter instanceof SerializationDelegatingTypeAdapter) {\n TypeAdapter delegate =\n ((SerializationDelegatingTypeAdapter) typeAdapter).getSerializationDelegate();\n\n @SuppressWarnings(\"ReferenceEquality\")\n boolean hasNoDelegate = delegate == typeAdapter;\n if (hasNoDelegate) {\n break;\n }\n typeAdapter = delegate;\n }\n\n return typeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java","line":103,"symbol":"getRuntimeTypeIfMoreSpecific","kind":"method","lang":"java","doc":"Finds a compatible runtime type if it is more specific","code":"private static Type getRuntimeTypeIfMoreSpecific(Type type, Object value) {\n if (value == null) {\n return type;\n }\n\n Type declaredType = type;\n // A wildcard says nothing more than its upper bound, so `? extends Base` is decided the same\n // way as `Base`. Note that the bound is only used to make this decision; when it is a\n // parameterized type the declared type is kept, the same as for a plain parameterized type,\n // because the runtime class would lose the type arguments.\n if (declaredType instanceof WildcardType) {\n declaredType = ((WildcardType) declaredType).getUpperBounds()[0];\n }\n\n if (declaredType instanceof Class || declaredType instanceof TypeVariable) {\n return value.getClass();\n }\n return type;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":63,"symbol":"TypeAdapters","kind":"class","lang":"java","doc":"Type adapters for basic types. More complex adapters exist as separate classes in the enclosing package.","code":"public final class TypeAdapters {\n private TypeAdapters() {\n throw new UnsupportedOperationException();\n }\n\n @SuppressWarnings(\"rawtypes\")\n public static final TypeAdapter CLASS =\n new TypeAdapter() {\n @Override\n public void write(JsonWriter out, Class value) throws IOException {\n throw new UnsupportedOperationException(\n \"Attempted to serialize java.lang.Class: \"\n + value.getName()\n + \". Forgot to register a type adapter?\"\n + \"\\nSee \"\n + TroubleshootingGuide.createUrl(\"java-lang-class-unsupported\"));\n }\n\n @Override\n public Class read(JsonReader in) throws IOException {\n throw new UnsupportedOperationException(\n \"Attempted to deserialize a java.lang.Class. Forgot to register a type adapter?\"\n + \"\\nSee \"\n + TroubleshootingGuide.createUrl(\"java-lang-class-unsupported\"));\n }\n }.nullSafe();\n\n public static final TypeAdapterFactory CLASS_FACTORY = newFactory(Class.class, CLASS);\n\n public static final TypeAdapter BIT_SET =\n new TypeAdapter() {\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":64,"symbol":"TypeAdapters","kind":"constructor","lang":"java","code":"private TypeAdapters() {\n throw new UnsupportedOperationException();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":71,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Class value) throws IOException {\n throw new UnsupportedOperationException(\n \"Attempted to serialize java.lang.Class: \"\n + value.getName()\n + \". Forgot to register a type adapter?\"\n + \"\\nSee \"\n + TroubleshootingGuide.createUrl(\"java-lang-class-unsupported\"));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":81,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Class read(JsonReader in) throws IOException {\n throw new UnsupportedOperationException(\n \"Attempted to deserialize a java.lang.Class. Forgot to register a type adapter?\"\n + \"\\nSee \"\n + TroubleshootingGuide.createUrl(\"java-lang-class-unsupported\"));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":94,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public BitSet read(JsonReader in) throws IOException {\n BitSet bitset = new BitSet();\n in.beginArray();\n int i = 0;\n JsonToken tokenType = in.peek();\n while (tokenType != JsonToken.END_ARRAY) {\n boolean set;\n switch (tokenType) {\n case NUMBER:\n case STRING:\n int intValue = in.nextInt();\n if (intValue == 0) {\n set = false;\n } else if (intValue == 1) {\n set = true;\n } else {\n throw new JsonSyntaxException(\n \"Invalid bitset value \"\n + intValue\n + \", expected 0 or 1; at path \"\n + in.getPreviousPath());\n }\n break;\n case BOOLEAN:\n set = in.nextBoolean();\n break;\n default:\n throw new JsonSyntaxException(\n \"Invalid bitset value type: \" + tokenType + \"; at path \" + in.getPath());\n }\n if (set) {\n bitset.set(i);\n }\n "} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":135,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, BitSet src) throws IOException {\n out.beginArray();\n for (int i = 0, length = src.length(); i < length; i++) {\n int value = src.get(i) ? 1 : 0;\n out.value(value);\n }\n out.endArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":150,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Boolean read(JsonReader in) throws IOException {\n JsonToken peek = in.peek();\n if (peek == JsonToken.NULL) {\n in.nextNull();\n return null;\n } else if (peek == JsonToken.STRING) {\n // support strings for compatibility with GSON 1.7\n return Boolean.parseBoolean(in.nextString());\n }\n return in.nextBoolean();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":163,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Boolean value) throws IOException {\n out.value(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":174,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Boolean read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return Boolean.valueOf(in.nextString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":183,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Boolean value) throws IOException {\n out.value(value == null ? \"null\" : value.toString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":194,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Number read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n int intValue;\n try {\n intValue = in.nextInt();\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n // Allow up to 255 to support unsigned values\n if (intValue > 255 || intValue < Byte.MIN_VALUE) {\n throw new JsonSyntaxException(\n \"Lossy conversion from \" + intValue + \" to byte; at path \" + in.getPreviousPath());\n }\n return (byte) intValue;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":215,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n } else {\n out.value(value.byteValue());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":229,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Number read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n\n int intValue;\n try {\n intValue = in.nextInt();\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n // Allow up to 65535 to support unsigned values\n if (intValue > 65535 || intValue < Short.MIN_VALUE) {\n throw new JsonSyntaxException(\n \"Lossy conversion from \" + intValue + \" to short; at path \" + in.getPreviousPath());\n }\n return (short) intValue;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":250,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n } else {\n out.value(value.shortValue());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":265,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Number read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n try {\n return in.nextInt();\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":278,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n } else {\n out.value(value.intValue());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":292,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public AtomicInteger read(JsonReader in) throws IOException {\n try {\n return new AtomicInteger(in.nextInt());\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":301,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, AtomicInteger value) throws IOException {\n out.value(value.get());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":309,"symbol":"atomicLongAdapter","kind":"method","lang":"java","code":"public static TypeAdapter atomicLongAdapter(TypeAdapter longAdapter) {\n Objects.requireNonNull(longAdapter);\n return new TypeAdapter() {\n @Override\n public AtomicLong read(JsonReader in) throws IOException {\n Number value = longAdapter.read(in);\n return new AtomicLong(value.longValue());\n }\n\n @Override\n public void write(JsonWriter out, AtomicLong value) throws IOException {\n longAdapter.write(out, value.get());\n }\n }.nullSafe();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":312,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public AtomicLong read(JsonReader in) throws IOException {\n Number value = longAdapter.read(in);\n return new AtomicLong(value.longValue());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":318,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, AtomicLong value) throws IOException {\n longAdapter.write(out, value.get());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":327,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public AtomicBoolean read(JsonReader in) throws IOException {\n return new AtomicBoolean(in.nextBoolean());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":332,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, AtomicBoolean value) throws IOException {\n out.value(value.get());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":342,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public AtomicIntegerArray read(JsonReader in) throws IOException {\n List list = new ArrayList<>();\n in.beginArray();\n while (in.hasNext()) {\n try {\n int integer = in.nextInt();\n list.add(integer);\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n }\n in.endArray();\n int length = list.size();\n AtomicIntegerArray array = new AtomicIntegerArray(length);\n for (int i = 0; i < length; ++i) {\n array.set(i, list.get(i));\n }\n return array;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":363,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, AtomicIntegerArray value) throws IOException {\n out.beginArray();\n for (int i = 0, length = value.length(); i < length; i++) {\n out.value(value.get(i));\n }\n out.endArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":375,"symbol":"atomicLongArrayAdapter","kind":"method","lang":"java","code":"public static TypeAdapter atomicLongArrayAdapter(\n TypeAdapter longAdapter) {\n Objects.requireNonNull(longAdapter);\n return new TypeAdapter() {\n @Override\n public AtomicLongArray read(JsonReader in) throws IOException {\n List list = new ArrayList<>();\n in.beginArray();\n while (in.hasNext()) {\n Number value = longAdapter.read(in);\n if (value == null) {\n throw new JsonSyntaxException(\n \"null is not a valid AtomicLongArray element; at path \" + in.getPreviousPath());\n }\n list.add(value.longValue());\n }\n in.endArray();\n int length = list.size();\n AtomicLongArray array = new AtomicLongArray(length);\n for (int i = 0; i < length; ++i) {\n array.set(i, list.get(i));\n }\n return array;\n }\n\n @Override\n public void write(JsonWriter out, AtomicLongArray value) throws IOException {\n out.beginArray();\n for (int i = 0, length = value.length(); i < length; i++) {\n longAdapter.write(out, value.get(i));\n }\n out.endArray();\n }\n }.nullSafe"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":379,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public AtomicLongArray read(JsonReader in) throws IOException {\n List list = new ArrayList<>();\n in.beginArray();\n while (in.hasNext()) {\n Number value = longAdapter.read(in);\n if (value == null) {\n throw new JsonSyntaxException(\n \"null is not a valid AtomicLongArray element; at path \" + in.getPreviousPath());\n }\n list.add(value.longValue());\n }\n in.endArray();\n int length = list.size();\n AtomicLongArray array = new AtomicLongArray(length);\n for (int i = 0; i < length; ++i) {\n array.set(i, list.get(i));\n }\n return array;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":400,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, AtomicLongArray value) throws IOException {\n out.beginArray();\n for (int i = 0, length = value.length(); i < length; i++) {\n longAdapter.write(out, value.get(i));\n }\n out.endArray();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":413,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Number read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n try {\n return in.nextLong();\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":426,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n } else {\n out.value(value.longValue());\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":438,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Number read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return in.nextLong();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":447,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n out.value(value.toString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":457,"symbol":"FloatAdapter","kind":"class","lang":"java","code":"private static class FloatAdapter extends TypeAdapter {\n private final boolean strict;\n\n FloatAdapter(boolean strict) {\n this.strict = strict;\n }\n\n @Override\n public Float read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return (float) in.nextDouble();\n }\n\n @Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n float floatValue = value.floatValue();\n if (strict) {\n checkValidFloatingPoint(floatValue);\n }\n // For backward compatibility don't call `JsonWriter.value(float)` because that method has\n // been newly added and not all custom JsonWriter implementations might override it yet\n Number floatNumber = value instanceof Float ? value : floatValue;\n out.value(floatNumber);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":460,"symbol":"FloatAdapter","kind":"constructor","lang":"java","code":"FloatAdapter(boolean strict) {\n this.strict = strict;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":464,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Float read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return (float) in.nextDouble();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":473,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n float floatValue = value.floatValue();\n if (strict) {\n checkValidFloatingPoint(floatValue);\n }\n // For backward compatibility don't call `JsonWriter.value(float)` because that method has\n // been newly added and not all custom JsonWriter implementations might override it yet\n Number floatNumber = value instanceof Float ? value : floatValue;\n out.value(floatNumber);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":490,"symbol":"DoubleAdapter","kind":"class","lang":"java","code":"private static class DoubleAdapter extends TypeAdapter {\n private final boolean strict;\n\n DoubleAdapter(boolean strict) {\n this.strict = strict;\n }\n\n @Override\n public Double read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return in.nextDouble();\n }\n\n @Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n double doubleValue = value.doubleValue();\n if (strict) {\n checkValidFloatingPoint(doubleValue);\n }\n out.value(doubleValue);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":493,"symbol":"DoubleAdapter","kind":"constructor","lang":"java","code":"DoubleAdapter(boolean strict) {\n this.strict = strict;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":497,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Double read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return in.nextDouble();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":506,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Number value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n double doubleValue = value.doubleValue();\n if (strict) {\n checkValidFloatingPoint(doubleValue);\n }\n out.value(doubleValue);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":520,"symbol":"checkValidFloatingPoint","kind":"method","lang":"java","code":"private static void checkValidFloatingPoint(double value) {\n if (Double.isNaN(value) || Double.isInfinite(value)) {\n throw new IllegalArgumentException(\n value\n + \" is not a valid double value as per JSON specification. To override this\"\n + \" behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.\");\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":537,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public Character read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String str = in.nextString();\n int length = str.length();\n if (length != 1) {\n throw new JsonSyntaxException(\n \"Expecting single character, got: '\"\n + str\n + \"' (length \"\n + length\n + \"); at path \"\n + in.getPreviousPath());\n }\n return str.charAt(0);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":557,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, Character value) throws IOException {\n out.value(value == null ? null : String.valueOf(value));\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":568,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public String read(JsonReader in) throws IOException {\n JsonToken peek = in.peek();\n if (peek == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n /* coerce booleans to strings for backwards compatibility */\n if (peek == JsonToken.BOOLEAN) {\n return Boolean.toString(in.nextBoolean());\n }\n return in.nextString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":582,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, String value) throws IOException {\n out.value(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":590,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public BigDecimal read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String s = in.nextString();\n try {\n return NumberLimits.parseBigDecimal(s);\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + s + \"' as BigDecimal; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":605,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, BigDecimal value) throws IOException {\n out.value(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":616,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public BigInteger read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String s = in.nextString();\n try {\n return NumberLimits.parseBigInteger(s);\n } catch (NumberFormatException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + s + \"' as BigInteger; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":631,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, BigInteger value) throws IOException {\n out.value(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":645,"symbol":"read","kind":"method","lang":"java","doc":"Normally users should not be able to access and deserialize LazilyParsedNumber because it is an internal type, but implement this nonetheless in case there are legit corner cases where this is possible","code":"@Override\n public LazilyParsedNumber read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return new LazilyParsedNumber(in.nextString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":654,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, LazilyParsedNumber value) throws IOException {\n out.value(value);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":667,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public StringBuilder read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return new StringBuilder(in.nextString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":676,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, StringBuilder value) throws IOException {\n out.value(value == null ? null : value.toString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":687,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public StringBuffer read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n return new StringBuffer(in.nextString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":696,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, StringBuffer value) throws IOException {\n out.value(value == null ? null : value.toString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":707,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public URL read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String nextString = in.nextString();\n if (nextString.equals(\"null\")) {\n return null;\n }\n try {\n return new URL(nextString);\n } catch (MalformedURLException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + nextString + \"' as URL; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":725,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, URL value) throws IOException {\n out.value(value == null ? null : value.toExternalForm());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":735,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public URI read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String nextString = in.nextString();\n if (nextString.equals(\"null\")) {\n return null;\n }\n try {\n return new URI(nextString);\n } catch (URISyntaxException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + nextString + \"' as URI; at path \" + in.getPreviousPath(), e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":753,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, URI value) throws IOException {\n out.value(value == null ? null : value.toString());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java","line":770,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public InetAddress read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String s = in.nextString();\n if (!ipAddressPattern.matcher(s).matches()\n && !Boolean.getBoolean(\"gson.allowDnsInetAddress\")) {\n throw new JsonSyntaxException(\n \"Failed parsing '\"\n + s\n + \"' as InetAddress; at path \"\n + in.getPreviousPath()\n + \"; to allow DNS addresses, set system property gson.allowDnsInetAddress to\"\n + \" \\\"true\\\"\");\n }\n @SuppressWarnings(\"AddressSelection\")\n InetAddress addr = InetAddress.getByName(s);\n return addr;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":38,"symbol":"ISO8601Utils","kind":"class","lang":"java","doc":"[yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh[:]mm]] @see this specification Date parsing code from Jackson databind ISO8601Utils.java https://github.com/FasterXML/jackson-databind/blob/2.8/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java","code":"@SuppressWarnings(\"MemberName\") // legacy class name\npublic final class ISO8601Utils {\n private ISO8601Utils() {}\n\n /**\n * ID to represent the 'UTC' string, default timezone since Jackson 2.7\n *\n * @since 2.7\n */\n private static final String UTC_ID = \"UTC\";\n\n /**\n * The UTC timezone, prefetched to avoid more lookups.\n *\n * @since 2.7\n */\n private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone(UTC_ID);\n\n /*\n /**********************************************************\n /* Formatting\n /**********************************************************\n */\n\n /**\n * Format a date into 'yyyy-MM-ddThh:mm:ssZ' (default timezone, no milliseconds precision)\n *\n * @param date the date to format\n * @return the date formatted as 'yyyy-MM-ddThh:mm:ssZ'\n */\n public static String format(Date date) {\n return format(date, false, TIMEZONE_UTC);\n }\n\n /**\n * Format a date into 'yyyy-MM-ddThh:mm:ss[.sss]Z' (GMT timezone)\n *\n * @param date the date to format\n * @param millis true to include millis precision otherwise false\n * @return the date formatted as 'yyyy-MM-ddThh:mm:ss[.sss]Z'\n */\n public static String format(Date date, boolean millis) {\n"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":40,"symbol":"ISO8601Utils","kind":"constructor","lang":"java","code":"private ISO8601Utils() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":68,"symbol":"format","kind":"method","lang":"java","doc":"Format a date into 'yyyy-MM-ddThh:mm:ssZ' (default timezone, no milliseconds precision) @param date the date to format @return the date formatted as 'yyyy-MM-ddThh:mm:ssZ'","code":"public static String format(Date date) {\n return format(date, false, TIMEZONE_UTC);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":79,"symbol":"format","kind":"method","lang":"java","doc":"Format a date into 'yyyy-MM-ddThh:mm:ss[.sss]Z' (GMT timezone) @param date the date to format @param millis true to include millis precision otherwise false @return the date formatted as 'yyyy-MM-ddThh:mm:ss[.sss]Z'","code":"public static String format(Date date, boolean millis) {\n return format(date, millis, TIMEZONE_UTC);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":91,"symbol":"format","kind":"method","lang":"java","doc":"@param date the date to format @param millis true to include millis precision otherwise false @param tz timezone to use for the formatting (UTC will produce 'Z') @return the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]","code":"public static String format(Date date, boolean millis, TimeZone tz) {\n Calendar calendar = new GregorianCalendar(tz, Locale.US);\n calendar.setTime(date);\n\n // estimate capacity of buffer as close as we can (yeah, that's pedantic ;)\n int capacity = \"yyyy-MM-ddThh:mm:ss\".length();\n capacity += millis ? \".sss\".length() : 0;\n capacity += tz.getRawOffset() == 0 ? \"Z\".length() : \"+hh:mm\".length();\n StringBuilder formatted = new StringBuilder(capacity);\n\n padInt(formatted, calendar.get(Calendar.YEAR), \"yyyy\".length());\n formatted.append('-');\n padInt(formatted, calendar.get(Calendar.MONTH) + 1, \"MM\".length());\n formatted.append('-');\n padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), \"dd\".length());\n formatted.append('T');\n padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), \"hh\".length());\n formatted.append(':');\n padInt(formatted, calendar.get(Calendar.MINUTE), \"mm\".length());\n formatted.append(':');\n padInt(formatted, calendar.get(Calendar.SECOND), \"ss\".length());\n if (millis) {\n formatted.append('.');\n padInt(formatted, calendar.get(Calendar.MILLISECOND), \"sss\".length());\n }\n\n int offset = tz.getOffset(cal"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":147,"symbol":"parse","kind":"method","lang":"java","doc":"@param date ISO string to parse in the appropriate format. @param pos The position to start parsing from, updated to where parsing stopped. @return the parsed date @throws ParseException if the date is not in the appropriate format","code":"public static Date parse(String date, ParsePosition pos) throws ParseException {\n Exception fail = null;\n try {\n int offset = pos.getIndex();\n\n // extract year\n int year = parseInt(date, offset, offset += 4);\n if (checkOffset(date, offset, '-')) {\n offset += 1;\n }\n\n // extract month\n int month = parseInt(date, offset, offset += 2);\n if (checkOffset(date, offset, '-')) {\n offset += 1;\n }\n\n // extract day\n int day = parseInt(date, offset, offset += 2);\n\n // default time value\n int hour = 0;\n int minutes = 0;\n int seconds = 0;\n\n // always use 0 otherwise returned date will include millis of current time\n int milliseconds = 0;\n\n // if the value has no time component (and no time zone), we are done\n boolean hasT = checkOffset(date, offset, 'T');\n\n if (!hasT && (date.length() <= offset)) {\n Calendar calendar = new GregorianCalendar(year, month - 1, day);\n calendar.setLenient(false);\n\n pos.setIndex(offset);\n return calendar.getTime();\n }\n\n if (hasT) {\n\n // extract hours, minutes, seconds and milliseconds\n hour = parseIn"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":319,"symbol":"checkOffset","kind":"method","lang":"java","doc":"@param value the string to check at the specified offset @param offset the offset to look for the expected character @param expected the expected character @return true if the expected character exist at the given offset","code":"private static boolean checkOffset(String value, int offset, char expected) {\n return (offset < value.length()) && (value.charAt(offset) == expected);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":332,"symbol":"parseInt","kind":"method","lang":"java","doc":"@param value the string to parse @param beginIndex the start index for the integer in the string @param endIndex the end index for the integer in the string @return the int @throws NumberFormatException if the value is not a number","code":"private static int parseInt(String value, int beginIndex, int endIndex)\n throws NumberFormatException {\n if (beginIndex < 0 || endIndex > value.length() || beginIndex > endIndex) {\n throw new NumberFormatException(value);\n }\n // use same logic as in Integer.parseInt() but less generic we're not supporting negative values\n int i = beginIndex;\n int result = 0;\n int digit;\n if (i < endIndex) {\n digit = Character.digit(value.charAt(i++), 10);\n if (digit < 0) {\n throw new NumberFormatException(\"Invalid number: \" + value.substring(beginIndex, endIndex));\n }\n result = -digit;\n }\n while (i < endIndex) {\n digit = Character.digit(value.charAt(i++), 10);\n if (digit < 0) {\n throw new NumberFormatException(\"Invalid number: \" + value.substring(beginIndex, endIndex));\n }\n result *= 10;\n result -= digit;\n }\n return -result;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":366,"symbol":"padInt","kind":"method","lang":"java","doc":"Zero pad a number to a specified length @param buffer buffer to use for padding @param value the integer value to pad if necessary. @param length the length of the string we should zero pad","code":"private static void padInt(StringBuilder buffer, int value, int length) {\n String strValue = Integer.toString(value);\n for (int i = length - strValue.length(); i > 0; i--) {\n buffer.append('0');\n }\n buffer.append(strValue);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java","line":377,"symbol":"indexOfNonDigit","kind":"method","lang":"java","doc":"Returns the index of the first character in the string that is not a digit, starting at offset.","code":"private static int indexOfNonDigit(String string, int offset) {\n for (int i = offset; i < string.length(); i++) {\n char c = string.charAt(i);\n if (c < '0' || c > '9') {\n return i;\n }\n }\n return string.length();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":28,"symbol":"ReflectionHelper","kind":"class","lang":"java","code":"public final class ReflectionHelper {\n\n private static final RecordHelper RECORD_HELPER;\n\n static {\n RecordHelper instance;\n try {\n // Try to construct the RecordSupportedHelper, if this fails, records are not supported on\n // this JVM.\n instance = new RecordSupportedHelper();\n } catch (ReflectiveOperationException e) {\n instance = new RecordNotSupportedHelper();\n }\n RECORD_HELPER = instance;\n }\n\n private ReflectionHelper() {}\n\n private static String getInaccessibleTroubleshootingSuffix(Exception e) {\n // Class was added in Java 9, therefore cannot use instanceof\n if (e.getClass().getName().equals(\"java.lang.reflect.InaccessibleObjectException\")) {\n String message = e.getMessage();\n String troubleshootingId =\n message != null && message.contains(\"to module com.google.gson\")\n ? \"reflection-inaccessible-to-module-gson\"\n : \"reflection-inaccessible\";\n return \"\\nSee \" + TroubleshootingGuide.createUrl(troubleshootingId);\n }\n return \"\";\n }\n\n /**\n * Internal implementation of making an {@link AccessibleObject} accessible.\n *\n * @param object the object that {@link AccessibleObject#"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":44,"symbol":"ReflectionHelper","kind":"constructor","lang":"java","code":"private ReflectionHelper() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":46,"symbol":"getInaccessibleTroubleshootingSuffix","kind":"method","lang":"java","code":"private static String getInaccessibleTroubleshootingSuffix(Exception e) {\n // Class was added in Java 9, therefore cannot use instanceof\n if (e.getClass().getName().equals(\"java.lang.reflect.InaccessibleObjectException\")) {\n String message = e.getMessage();\n String troubleshootingId =\n message != null && message.contains(\"to module com.google.gson\")\n ? \"reflection-inaccessible-to-module-gson\"\n : \"reflection-inaccessible\";\n return \"\\nSee \" + TroubleshootingGuide.createUrl(troubleshootingId);\n }\n return \"\";\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":66,"symbol":"makeAccessible","kind":"method","lang":"java","doc":"Internal implementation of making an {@link AccessibleObject} accessible. @param object the object that {@link AccessibleObject#setAccessible(boolean)} should be called on. @throws JsonIOException if making the object accessible fails","code":"public static void makeAccessible(AccessibleObject object) throws JsonIOException {\n try {\n object.setAccessible(true);\n } catch (Exception exception) {\n String description = getAccessibleObjectDescription(object, false);\n throw new JsonIOException(\n \"Failed making \"\n + description\n + \" accessible; either increase its visibility\"\n + \" or write a custom TypeAdapter for its declaring type.\"\n + getInaccessibleTroubleshootingSuffix(exception),\n exception);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":89,"symbol":"getAccessibleObjectDescription","kind":"method","lang":"java","doc":"result is normally shorter than {@link AccessibleObject#toString()} because it omits modifiers (e.g. {@code final}) and uses simple names for constructor and method parameter types. @param object object to describe @param uppercaseFirstLetter whether the first letter of the description should be uppercased","code":"public static String getAccessibleObjectDescription(\n AccessibleObject object, boolean uppercaseFirstLetter) {\n String description;\n\n if (object instanceof Field) {\n description = \"field '\" + fieldToString((Field) object) + \"'\";\n } else if (object instanceof Method) {\n Method method = (Method) object;\n\n StringBuilder methodSignatureBuilder = new StringBuilder(method.getName());\n appendExecutableParameters(method, methodSignatureBuilder);\n String methodSignature = methodSignatureBuilder.toString();\n\n description = \"method '\" + method.getDeclaringClass().getName() + \"#\" + methodSignature + \"'\";\n } else if (object instanceof Constructor) {\n description = \"constructor '\" + constructorToString((Constructor) object) + \"'\";\n } else {\n description = \" \" + object.toString();\n }\n\n if (uppercaseFirstLetter && Character.isLowerCase(description.charAt(0))) {\n description = Character.toUpperCase(description.charAt(0)) + description.substring(1);\n }\n return description;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":116,"symbol":"fieldToString","kind":"method","lang":"java","doc":"Creates a string representation for a field, omitting modifiers and the field type.","code":"public static String fieldToString(Field field) {\n return field.getDeclaringClass().getName() + \"#\" + field.getName();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":124,"symbol":"constructorToString","kind":"method","lang":"java","doc":"Creates a string representation for a constructor. E.g.: {@code java.lang.String(char[], int, int)}","code":"public static String constructorToString(Constructor constructor) {\n StringBuilder stringBuilder = new StringBuilder(constructor.getDeclaringClass().getName());\n appendExecutableParameters(constructor, stringBuilder);\n\n return stringBuilder.toString();\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":133,"symbol":"appendExecutableParameters","kind":"method","lang":"java","doc":"Ideally parameter type would be java.lang.reflect.Executable, but that was added in Android API level 26","code":"private static void appendExecutableParameters(\n AccessibleObject executable, StringBuilder stringBuilder) {\n stringBuilder.append('(');\n\n Class[] parameters =\n (executable instanceof Method)\n ? ((Method) executable).getParameterTypes()\n : ((Constructor) executable).getParameterTypes();\n for (int i = 0; i < parameters.length; i++) {\n if (i > 0) {\n stringBuilder.append(\", \");\n }\n stringBuilder.append(parameters[i].getSimpleName());\n }\n\n stringBuilder.append(')');\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":151,"symbol":"isStatic","kind":"method","lang":"java","code":"public static boolean isStatic(Class clazz) {\n return Modifier.isStatic(clazz.getModifiers());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":156,"symbol":"isAnonymousOrNonStaticLocal","kind":"method","lang":"java","doc":"Returns whether the class is anonymous or a non-static local class.","code":"public static boolean isAnonymousOrNonStaticLocal(Class clazz) {\n return !isStatic(clazz) && (clazz.isAnonymousClass() || clazz.isLocalClass());\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":166,"symbol":"tryMakeAccessible","kind":"method","lang":"java","doc":"Tries making the constructor accessible, returning an exception message if this fails. @param constructor constructor to make accessible @return exception message; {@code null} if successful, non-{@code null} if unsuccessful","code":"public static String tryMakeAccessible(Constructor constructor) {\n try {\n constructor.setAccessible(true);\n return null;\n } catch (Exception exception) {\n return \"Failed making constructor '\"\n + constructorToString(constructor)\n + \"' accessible; either increase its visibility or write a custom InstanceCreator or\"\n + \" TypeAdapter for its declaring type: \"\n // Include the message since it might contain more detailed information\n + exception.getMessage()\n + getInaccessibleTroubleshootingSuffix(exception);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":182,"symbol":"isRecord","kind":"method","lang":"java","doc":"If records are supported on the JVM, this is equivalent to a call to Class.isRecord()","code":"public static boolean isRecord(Class raw) {\n return RECORD_HELPER.isRecord(raw);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":186,"symbol":"getRecordComponentNames","kind":"method","lang":"java","code":"public static String[] getRecordComponentNames(Class raw) {\n return RECORD_HELPER.getRecordComponentNames(raw);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":191,"symbol":"getAccessor","kind":"method","lang":"java","doc":"Looks up the record accessor method that corresponds to the given record field","code":"public static Method getAccessor(Class raw, Field field) {\n return RECORD_HELPER.getAccessor(raw, field);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":195,"symbol":"getCanonicalRecordConstructor","kind":"method","lang":"java","code":"public static Constructor getCanonicalRecordConstructor(Class raw) {\n return RECORD_HELPER.getCanonicalRecordConstructor(raw);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":199,"symbol":"createExceptionForUnexpectedIllegalAccess","kind":"method","lang":"java","code":"public static RuntimeException createExceptionForUnexpectedIllegalAccess(\n IllegalAccessException exception) {\n throw new RuntimeException(\n \"Unexpected IllegalAccessException occurred (Gson \"\n + GsonBuildConfig.VERSION\n + \"). Certain ReflectionAccessFilter features require Java >= 9 to work correctly. If\"\n + \" you are not using ReflectionAccessFilter, report this to the Gson maintainers.\",\n exception);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":209,"symbol":"createExceptionForRecordReflectionException","kind":"method","lang":"java","code":"private static RuntimeException createExceptionForRecordReflectionException(\n ReflectiveOperationException exception) {\n throw new RuntimeException(\n \"Unexpected ReflectiveOperationException occurred\"\n + \" (Gson \"\n + GsonBuildConfig.VERSION\n + \").\"\n + \" To support Java records, reflection is utilized to read out information\"\n + \" about records. All these invocations happens after it is established\"\n + \" that records exist in the JVM. This exception is unexpected behavior.\",\n exception);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":223,"symbol":"RecordHelper","kind":"class","lang":"java","doc":"Internal abstraction over reflection when Records are supported.","code":"private abstract static class RecordHelper {\n abstract boolean isRecord(Class clazz);\n\n abstract String[] getRecordComponentNames(Class clazz);\n\n abstract Constructor getCanonicalRecordConstructor(Class raw);\n\n abstract Method getAccessor(Class raw, Field field);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":224,"symbol":"isRecord","kind":"method","lang":"java","code":"abstract boolean isRecord(Class clazz);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":226,"symbol":"getRecordComponentNames","kind":"method","lang":"java","code":"abstract String[] getRecordComponentNames(Class clazz);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":228,"symbol":"getCanonicalRecordConstructor","kind":"method","lang":"java","code":"abstract Constructor getCanonicalRecordConstructor(Class raw);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":230,"symbol":"getAccessor","kind":"method","lang":"java","code":"abstract Method getAccessor(Class raw, Field field);"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":233,"symbol":"RecordSupportedHelper","kind":"class","lang":"java","code":"private static final class RecordSupportedHelper extends RecordHelper {\n private final Method isRecord;\n private final Method getRecordComponents;\n private final Method getName;\n private final Method getType;\n\n private RecordSupportedHelper() throws NoSuchMethodException, ClassNotFoundException {\n isRecord = Class.class.getMethod(\"isRecord\");\n getRecordComponents = Class.class.getMethod(\"getRecordComponents\");\n Class classRecordComponent = Class.forName(\"java.lang.reflect.RecordComponent\");\n getName = classRecordComponent.getMethod(\"getName\");\n getType = classRecordComponent.getMethod(\"getType\");\n }\n\n @Override\n boolean isRecord(Class raw) {\n try {\n return (boolean) isRecord.invoke(raw);\n } catch (ReflectiveOperationException e) {\n throw createExceptionForRecordReflectionException(e);\n }\n }\n\n @Override\n String[] getRecordComponentNames(Class raw) {\n try {\n Object[] recordComponents = (Object[]) getRecordComponents.invoke(raw);\n String[] componentNames = new String[recordComponents.length];\n for (int i = 0; i < recordComponents.length; i++) {\n componentN"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":239,"symbol":"RecordSupportedHelper","kind":"constructor","lang":"java","code":"private RecordSupportedHelper() throws NoSuchMethodException, ClassNotFoundException {\n isRecord = Class.class.getMethod(\"isRecord\");\n getRecordComponents = Class.class.getMethod(\"getRecordComponents\");\n Class classRecordComponent = Class.forName(\"java.lang.reflect.RecordComponent\");\n getName = classRecordComponent.getMethod(\"getName\");\n getType = classRecordComponent.getMethod(\"getType\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":247,"symbol":"isRecord","kind":"method","lang":"java","code":"@Override\n boolean isRecord(Class raw) {\n try {\n return (boolean) isRecord.invoke(raw);\n } catch (ReflectiveOperationException e) {\n throw createExceptionForRecordReflectionException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":256,"symbol":"getRecordComponentNames","kind":"method","lang":"java","code":"@Override\n String[] getRecordComponentNames(Class raw) {\n try {\n Object[] recordComponents = (Object[]) getRecordComponents.invoke(raw);\n String[] componentNames = new String[recordComponents.length];\n for (int i = 0; i < recordComponents.length; i++) {\n componentNames[i] = (String) getName.invoke(recordComponents[i]);\n }\n return componentNames;\n } catch (ReflectiveOperationException e) {\n throw createExceptionForRecordReflectionException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":270,"symbol":"getCanonicalRecordConstructor","kind":"method","lang":"java","code":"@Override\n public Constructor getCanonicalRecordConstructor(Class raw) {\n try {\n Object[] recordComponents = (Object[]) getRecordComponents.invoke(raw);\n Class[] recordComponentTypes = new Class[recordComponents.length];\n for (int i = 0; i < recordComponents.length; i++) {\n recordComponentTypes[i] = (Class) getType.invoke(recordComponents[i]);\n }\n // Uses getDeclaredConstructor because implicit constructor has same visibility as record\n // and might therefore not be public\n return raw.getDeclaredConstructor(recordComponentTypes);\n } catch (ReflectiveOperationException e) {\n throw createExceptionForRecordReflectionException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":286,"symbol":"getAccessor","kind":"method","lang":"java","code":"@Override\n public Method getAccessor(Class raw, Field field) {\n try {\n // Records consists of record components, each with a unique name, a corresponding field and\n // accessor method with the same name. Ref.:\n // https://docs.oracle.com/javase/specs/jls/se17/html/jls-8.html#jls-8.10.3\n return raw.getMethod(field.getName());\n } catch (ReflectiveOperationException e) {\n throw createExceptionForRecordReflectionException(e);\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":300,"symbol":"RecordNotSupportedHelper","kind":"class","lang":"java","doc":"Instance used when records are not supported","code":"private static final class RecordNotSupportedHelper extends RecordHelper {\n\n @Override\n boolean isRecord(Class clazz) {\n return false;\n }\n\n @Override\n String[] getRecordComponentNames(Class clazz) {\n throw new UnsupportedOperationException(\n \"Records are not supported on this JVM, this method should not be called\");\n }\n\n @Override\n Constructor getCanonicalRecordConstructor(Class raw) {\n throw new UnsupportedOperationException(\n \"Records are not supported on this JVM, this method should not be called\");\n }\n\n @Override\n public Method getAccessor(Class raw, Field field) {\n throw new UnsupportedOperationException(\n \"Records are not supported on this JVM, this method should not be called\");\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":302,"symbol":"isRecord","kind":"method","lang":"java","code":"@Override\n boolean isRecord(Class clazz) {\n return false;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":307,"symbol":"getRecordComponentNames","kind":"method","lang":"java","code":"@Override\n String[] getRecordComponentNames(Class clazz) {\n throw new UnsupportedOperationException(\n \"Records are not supported on this JVM, this method should not be called\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":313,"symbol":"getCanonicalRecordConstructor","kind":"method","lang":"java","code":"@Override\n Constructor getCanonicalRecordConstructor(Class raw) {\n throw new UnsupportedOperationException(\n \"Records are not supported on this JVM, this method should not be called\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java","line":319,"symbol":"getAccessor","kind":"method","lang":"java","code":"@Override\n public Method getAccessor(Class raw, Field field) {\n throw new UnsupportedOperationException(\n \"Records are not supported on this JVM, this method should not be called\");\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java","line":39,"symbol":"SqlDateTypeAdapter","kind":"class","lang":"java","doc":"Adapter for java.sql.Date. Although this class appears stateless, it is not. DateFormat captures its time zone and locale when it is created, which gives this class state. DateFormat isn't thread safe either, so this class has to synchronize its read and write methods.","code":"@SuppressWarnings(\"JavaUtilDate\")\nfinal class SqlDateTypeAdapter extends TypeAdapter {\n static final TypeAdapterFactory FACTORY =\n new TypeAdapterFactory() {\n @SuppressWarnings(\"unchecked\") // we use a runtime check to make sure the 'T's equal\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n return typeToken.getRawType() == java.sql.Date.class\n ? (TypeAdapter) new SqlDateTypeAdapter()\n : null;\n }\n };\n\n private final DateFormat format = new SimpleDateFormat(\"MMM d, yyyy\");\n\n private SqlDateTypeAdapter() {}\n\n @Override\n public java.sql.Date read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String s = in.nextString();\n synchronized (this) {\n TimeZone originalTimeZone = format.getTimeZone(); // Save the original time zone\n try {\n Date utilDate = format.parse(s);\n return new java.sql.Date(utilDate.getTime());\n } catch (ParseException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + s + \"' as SQL Date; at path \" + in.getPr"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java","line":43,"symbol":"create","kind":"method","lang":"java","code":"@SuppressWarnings(\"unchecked\") // we use a runtime check to make sure the 'T's equal\n @Override\n public TypeAdapter create(Gson gson, TypeToken typeToken) {\n return typeToken.getRawType() == java.sql.Date.class\n ? (TypeAdapter) new SqlDateTypeAdapter()\n : null;\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java","line":54,"symbol":"SqlDateTypeAdapter","kind":"constructor","lang":"java","code":"private SqlDateTypeAdapter() {}"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java","line":56,"symbol":"read","kind":"method","lang":"java","code":"@Override\n public java.sql.Date read(JsonReader in) throws IOException {\n if (in.peek() == JsonToken.NULL) {\n in.nextNull();\n return null;\n }\n String s = in.nextString();\n synchronized (this) {\n TimeZone originalTimeZone = format.getTimeZone(); // Save the original time zone\n try {\n Date utilDate = format.parse(s);\n return new java.sql.Date(utilDate.getTime());\n } catch (ParseException e) {\n throw new JsonSyntaxException(\n \"Failed parsing '\" + s + \"' as SQL Date; at path \" + in.getPreviousPath(), e);\n } finally {\n format.setTimeZone(originalTimeZone); // Restore the original time zone after parsing\n }\n }\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java","line":77,"symbol":"write","kind":"method","lang":"java","code":"@Override\n public void write(JsonWriter out, java.sql.Date value) throws IOException {\n if (value == null) {\n out.nullValue();\n return;\n }\n String dateString;\n synchronized (this) {\n dateString = format.format(value);\n }\n out.value(dateString);\n }"} {"repo":"gson","file":"gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java","line":40,"symbol":"SqlTimeTypeAdapter","kind":"class","lang":"java","doc":"Adapter for java.sql.Time. Although this class appears stateless, it is not. DateFormat captures its time zone and locale when it is created, which gives this class state. DateFormat isn't thread safe either, so this class has to synchronize its read and write methods.","code":"@SuppressWarnings(\"JavaUtilDate\")\nfinal class SqlTimeTypeAdapter extends TypeAdapter