|
1 | 1 | from __future__ import print_function |
2 | 2 |
|
3 | | -from typing import Any, Iterable, Optional, Union |
| 3 | +from typing import Any, Iterable, Optional, TypeVar, Union |
4 | 4 |
|
5 | | -from java.lang import Object, String |
| 5 | +from com.inductiveautomation.ignition.common.gson.reflect import TypeToken |
| 6 | +from com.inductiveautomation.ignition.common.gson.stream import JsonReader, JsonWriter |
| 7 | +from java.io import Reader, Writer |
| 8 | +from java.lang import Class, Enum, Object, String |
| 9 | + |
| 10 | +T = TypeVar("T") |
| 11 | + |
| 12 | + |
| 13 | +class ExclusionStrategy(object): |
| 14 | + def shouldSkipClass(self, clazz): |
| 15 | + # type: (Class) -> bool |
| 16 | + raise NotImplementedError |
| 17 | + |
| 18 | + def shouldSkipField(self, attributes): |
| 19 | + # type: (FieldAttributes) -> bool |
| 20 | + raise NotImplementedError |
| 21 | + |
| 22 | + |
| 23 | +class FieldNamingStrategy(object): |
| 24 | + def translateName(self, arg): |
| 25 | + # type: (Any) -> String |
| 26 | + raise NotImplementedError |
| 27 | + |
| 28 | + |
| 29 | +class TypeAdapterFactory(object): |
| 30 | + def create(self, gson, token): |
| 31 | + # type: (Gson, TypeToken) -> TypeAdapter |
| 32 | + raise NotImplementedError |
| 33 | + |
| 34 | + |
| 35 | +class FieldAttributes(Object): |
| 36 | + def __init__(self, *args): |
| 37 | + # type: (Any) -> None |
| 38 | + pass |
| 39 | + |
| 40 | + def getAnnotation(self, annotation): |
| 41 | + # type: (Class) -> T |
| 42 | + pass |
| 43 | + |
| 44 | + def getAnnotations(self): |
| 45 | + # type: () -> Iterable[Any] |
| 46 | + pass |
| 47 | + |
| 48 | + def getDeclaredClass(self): |
| 49 | + # type: () -> Class |
| 50 | + pass |
| 51 | + |
| 52 | + def getDeclaredType(self): |
| 53 | + # type: () -> Any |
| 54 | + pass |
| 55 | + |
| 56 | + def getDeclaringClass(self): |
| 57 | + # type: () -> Class |
| 58 | + pass |
| 59 | + |
| 60 | + def getName(self): |
| 61 | + # type: () -> String |
| 62 | + pass |
| 63 | + |
| 64 | + def hasModifier(self, modifier): |
| 65 | + # type: (int) -> bool |
| 66 | + pass |
| 67 | + |
| 68 | + def isSynthetic(self): |
| 69 | + # type: () -> bool |
| 70 | + pass |
| 71 | + |
| 72 | + |
| 73 | +class FieldNamingPolicy(Enum, FieldNamingStrategy): |
| 74 | + IDENTITY = None # type: String |
| 75 | + UPPER_CAMEL_CASE = None # type: String |
| 76 | + UPPER_CAMEL_CASE_WITH_SPACES = None # type: String |
| 77 | + LOWER_CASE_WITH_UNDERSCORES = None # type: String |
| 78 | + LOWER_CASE_WITH_DASHES = None # type: String |
| 79 | + LOWER_CASE_WITH_DOTS = None # type: String |
| 80 | + |
| 81 | + def translateName(self, arg): |
| 82 | + # type: (Any) -> String |
| 83 | + pass |
| 84 | + |
| 85 | + |
| 86 | +class Gson(Object): |
| 87 | + def excluder(self): |
| 88 | + # type: () -> Any |
| 89 | + pass |
| 90 | + |
| 91 | + def fieldNamingStrategy(self): |
| 92 | + # type: () -> FieldNamingStrategy |
| 93 | + pass |
| 94 | + |
| 95 | + def fromJson(self, *args): |
| 96 | + # type: (Any) -> T |
| 97 | + pass |
| 98 | + |
| 99 | + def getAdapter(self, TypeToken=None): |
| 100 | + # type: (TypeToken) -> TypeAdapter |
| 101 | + pass |
| 102 | + |
| 103 | + def getDelegateAdapter(self, skipPast, type): |
| 104 | + # type: (TypeAdapterFactory, TypeToken) -> TypeAdapter |
| 105 | + pass |
| 106 | + |
| 107 | + def htmlSafe(self): |
| 108 | + # type: () -> bool |
| 109 | + pass |
| 110 | + |
| 111 | + def newBuilder(self): |
| 112 | + # type: () -> GsonBuilder |
| 113 | + pass |
| 114 | + |
| 115 | + def newJsonReader(self, reader): |
| 116 | + # type: (Reader) -> JsonReader |
| 117 | + pass |
| 118 | + |
| 119 | + def newJsonWriter(self, writer): |
| 120 | + # type: (Writer) -> JsonWriter |
| 121 | + pass |
| 122 | + |
| 123 | + def serializeNulls(self): |
| 124 | + # type: () -> bool |
| 125 | + pass |
| 126 | + |
| 127 | + def toJson(self, *args): |
| 128 | + # type: (Any) -> Optional[String] |
| 129 | + pass |
| 130 | + |
| 131 | + def toJsonTree(self, src, typeOfSrc=None): |
| 132 | + # type: (Object, Any) -> JsonElement |
| 133 | + pass |
| 134 | + |
| 135 | + |
| 136 | +class GsonBuilder(object): |
| 137 | + def __init__(self, *args): |
| 138 | + # type: (Any) -> None |
| 139 | + pass |
| 140 | + |
| 141 | + def addDeserializationExclusionStrategy(self, strategy): |
| 142 | + # type: (ExclusionStrategy) -> GsonBuilder |
| 143 | + pass |
| 144 | + |
| 145 | + def addSerializationExclusionStrategy(self, strategy): |
| 146 | + # type: (ExclusionStrategy) -> GsonBuilder |
| 147 | + pass |
| 148 | + |
| 149 | + def create(self): |
| 150 | + # type: () -> Gson |
| 151 | + pass |
| 152 | + |
| 153 | + def disableHtmlEscaping(self): |
| 154 | + # type: () -> GsonBuilder |
| 155 | + pass |
| 156 | + |
| 157 | + def disableInnerClassSerialization(self): |
| 158 | + # type: () -> GsonBuilder |
| 159 | + pass |
| 160 | + |
| 161 | + def enableComplexMapKeySerialization(self): |
| 162 | + # type: () -> GsonBuilder |
| 163 | + pass |
| 164 | + |
| 165 | + def excludeFieldsWithoutExposeAnnotation(self): |
| 166 | + # type: () -> GsonBuilder |
| 167 | + pass |
| 168 | + |
| 169 | + def excludeFieldsWithModifiers(self, *args): |
| 170 | + # type: (int) -> GsonBuilder |
| 171 | + pass |
| 172 | + |
| 173 | + def generateNonExecutableJson(self): |
| 174 | + # type: () -> GsonBuilder |
| 175 | + pass |
| 176 | + |
| 177 | + def setLenient(self): |
| 178 | + # type: () -> GsonBuilder |
| 179 | + pass |
| 180 | + |
| 181 | + def registerTypeAdapter(self, type, typeAdapter): |
| 182 | + # type: (Any, Object) -> GsonBuilder |
| 183 | + pass |
| 184 | + |
| 185 | + def registerTypeAdapterFactory(self, factory): |
| 186 | + # type: (TypeAdapterFactory) -> GsonBuilder |
| 187 | + pass |
| 188 | + |
| 189 | + def registerTypeHierarchyAdapter(self, baseType, typeAdapter): |
| 190 | + # type: (Class, Object) -> GsonBuilder |
| 191 | + pass |
| 192 | + |
| 193 | + def serializeNulls(self): |
| 194 | + # type: () -> GsonBuilder |
| 195 | + pass |
| 196 | + |
| 197 | + def serializeSpecialFloatingPointValues(self): |
| 198 | + # type: () -> GsonBuilder |
| 199 | + pass |
| 200 | + |
| 201 | + def setDateFormat(self, *args): |
| 202 | + # type: (Any) -> GsonBuilder |
| 203 | + pass |
| 204 | + |
| 205 | + def setExclusionStrategies(self, *args): |
| 206 | + # type: (ExclusionStrategy) -> GsonBuilder |
| 207 | + pass |
| 208 | + |
| 209 | + def setFieldNamingPolicy(self, namingConvention): |
| 210 | + # type: (FieldNamingPolicy) -> GsonBuilder |
| 211 | + pass |
| 212 | + |
| 213 | + def setFieldNamingStrategy(self, fieldNamingStrategy): |
| 214 | + # type: (FieldNamingStrategy) -> GsonBuilder |
| 215 | + pass |
| 216 | + |
| 217 | + def setLongSerializationPolicy(self, policy): |
| 218 | + # type: (LongSerializationPolicy) -> GsonBuilder |
| 219 | + pass |
| 220 | + |
| 221 | + def setPrettyPrinting(self): |
| 222 | + # type: () -> GsonBuilder |
| 223 | + pass |
| 224 | + |
| 225 | + def setVersion(self, ignoreVersionsAfter): |
| 226 | + # type: (float) -> GsonBuilder |
| 227 | + pass |
6 | 228 |
|
7 | 229 |
|
8 | 230 | class JsonElement(object): |
@@ -367,3 +589,41 @@ def isIntegral(primitive): |
367 | 589 | def isString(self): |
368 | 590 | # type: () -> bool |
369 | 591 | pass |
| 592 | + |
| 593 | + |
| 594 | +class LongSerializationPolicy(object): |
| 595 | + DEFAULT = None # type: JsonElement |
| 596 | + STRING = None # type: JsonElement |
| 597 | + |
| 598 | + def serialize(self, arg): |
| 599 | + # type: (long) -> JsonElement |
| 600 | + raise NotImplementedError |
| 601 | + |
| 602 | + |
| 603 | +class TypeAdapter(object): |
| 604 | + def fromJson(self, arg): |
| 605 | + # type: (Union[Reader, String]) -> T |
| 606 | + pass |
| 607 | + |
| 608 | + def fromJsonTree(self, jsonTree): |
| 609 | + # type: (JsonElement) -> T |
| 610 | + pass |
| 611 | + |
| 612 | + def nullSafe(self): |
| 613 | + # type: () -> TypeAdapter |
| 614 | + pass |
| 615 | + |
| 616 | + def read(self, reader): |
| 617 | + # type: (JsonReader) -> T |
| 618 | + raise NotImplementedError |
| 619 | + |
| 620 | + def toJson(self, out, value): |
| 621 | + # type: (Writer, T) -> Optional[String] |
| 622 | + pass |
| 623 | + |
| 624 | + def toJsonTree(self, value): |
| 625 | + # type: (T) -> JsonElement |
| 626 | + pass |
| 627 | + |
| 628 | + def write(self, *args): |
| 629 | + raise NotImplementedError |
0 commit comments