A JSON object. Asking for the value as the worng type results in a ClassCastException.
| 66 | * ClassCastException. |
| 67 | */ |
| 68 | public interface JObject extends Serializable { |
| 69 | default JArray arrayValue() { |
| 70 | throw new ClassCastException(); |
| 71 | } |
| 72 | |
| 73 | default boolean boolValue() { |
| 74 | throw new ClassCastException(); |
| 75 | } |
| 76 | |
| 77 | JSONOne.Type getType(); |
| 78 | |
| 79 | default JMap mapValue() { |
| 80 | throw new ClassCastException(); |
| 81 | } |
| 82 | |
| 83 | default boolean nullValue() { |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | default Number numberValue() { |
| 88 | throw new ClassCastException(); |
| 89 | } |
| 90 | |
| 91 | Object pojoValue(); |
| 92 | |
| 93 | default String stringValue() { |
| 94 | throw new ClassCastException(); |
| 95 | } |
| 96 | |
| 97 | void print(Writer w, int indent, boolean compact) throws IOException; |
| 98 | |
| 99 | default String print(boolean compact) throws IOException { return print(0, compact); } |
| 100 | |
| 101 | default String print() throws IOException { return print(0, true); } |
| 102 | |
| 103 | default String print(int indent, boolean compact) throws IOException { |
| 104 | StringWriter sw = new StringWriter(); |
| 105 | print(sw, indent, compact); |
| 106 | return sw.toString(); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | private static abstract class AbstractJSONObject implements JObject { |
| 111 | private Type type; |
no outgoing calls
no test coverage detected