kpandit | 5a9d139 | 2021-11-20 00:56:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | namespace java org.apache.thrift.partial |
| 21 | |
| 22 | // This thrift file is meant for testing partial deserialization. |
| 23 | // It includes all field types and most combinations of complex types. |
| 24 | // Those fields help ensure correctness of partial deserialization. |
| 25 | |
| 26 | enum TstEnum { |
| 27 | UNKNOWN = 0, |
| 28 | E_ONE = 1, |
| 29 | E_TWO = 2 |
| 30 | } |
| 31 | |
| 32 | struct SmallStruct { |
| 33 | // Primitive fields |
| 34 | 1: optional byte byteField; |
| 35 | 2: optional i16 i16Field; |
| 36 | 3: optional i32 i32Field; |
| 37 | 4: optional i64 i64Field; |
| 38 | 5: optional double doubleField; |
| 39 | 6: optional string stringField; |
| 40 | |
| 41 | // Enum |
| 42 | 7: optional TstEnum enumField; |
| 43 | } |
| 44 | |
| 45 | // TODO(kpandit): Need to add bool field |
| 46 | struct TestStruct { |
| 47 | // Primitive fields |
| 48 | 1: optional byte byteField; |
| 49 | 2: optional i16 i16Field; |
| 50 | 3: optional i32 i32Field; |
| 51 | 4: optional i64 i64Field; |
| 52 | 5: optional double doubleField; |
| 53 | 6: optional string stringField; |
| 54 | |
| 55 | // Enum |
| 56 | 7: optional TstEnum enumField; |
| 57 | |
| 58 | 8: optional binary binaryField; |
| 59 | |
| 60 | // List |
| 61 | 10: optional list<byte> byteList; |
| 62 | 11: optional list<i16> i16List; |
| 63 | 12: optional list<i32> i32List; |
| 64 | 13: optional list<i64> i64List; |
| 65 | 14: optional list<double> doubleList; |
| 66 | 15: optional list<string> stringList; |
| 67 | 16: optional list<TstEnum> enumList; |
| 68 | 17: optional list<list<i32>> listList; |
| 69 | 18: optional list<set<i32>> setList; |
| 70 | 19: optional list<map<string, i32>> mapList; |
| 71 | 20: optional list<SmallStruct> structList; |
| 72 | 21: optional list<binary> binaryList; |
| 73 | |
| 74 | // Set |
| 75 | 30: optional set<byte> byteSet; |
| 76 | 31: optional set<i16> i16Set; |
| 77 | 32: optional set<i32> i32Set; |
| 78 | 33: optional set<i64> i64Set; |
| 79 | 34: optional set<double> doubleSet; |
| 80 | 35: optional set<string> stringSet; |
| 81 | 36: optional set<TstEnum> enumSet; |
| 82 | 37: optional set<list<i32>> listSet (nolint = "set.value.type"); |
| 83 | 38: optional set<set<i32>> setSet (nolint = "set.value.type"); |
| 84 | 39: optional set<map<string, i32>> mapSet (nolint = "set.value.type"); |
| 85 | 40: optional set<SmallStruct> structSet (nolint = "set.value.type"); |
| 86 | 41: optional set<binary> binarySet; |
| 87 | |
| 88 | // Map |
| 89 | 50: optional map<byte, byte> byteMap; |
| 90 | 51: optional map<i16, i16> i16Map; |
| 91 | 52: optional map<i32, i32> i32Map; |
| 92 | 53: optional map<i64, i64> i64Map; |
| 93 | 54: optional map<double, double> doubleMap; |
| 94 | 55: optional map<string, string> stringMap; |
| 95 | 56: optional map<TstEnum, TstEnum> enumMap; |
| 96 | 57: optional map<i32, list<i32>> listMap; |
| 97 | 58: optional map<i32, set<i32>> setMap; |
| 98 | 59: optional map<i32, map<i32, i32>> mapMap; |
| 99 | 60: optional map<SmallStruct, SmallStruct> structMap (nolint = "map.key.type"); |
| 100 | 61: optional map<i32, binary> binaryMap; |
| 101 | |
| 102 | 70: optional SmallStruct structField; |
| 103 | } |
| 104 | |
| 105 | struct InnermostStruct { |
| 106 | 1: optional string value; |
| 107 | 2: optional i32 intValue; |
| 108 | } |
| 109 | |
| 110 | struct InnerStruct { |
| 111 | 1: optional InnermostStruct value; |
| 112 | 2: optional i32 intValue; |
| 113 | } |
| 114 | |
| 115 | struct OuterStruct { |
| 116 | 1: optional InnerStruct value; |
| 117 | 2: optional map<string, InnerStruct> structMap; |
| 118 | } |
| 119 | |
| 120 | union SimpleUnion { |
| 121 | 1: optional i32 intValue; |
| 122 | 2: optional string stringValue; |
| 123 | } |
| 124 | |
| 125 | struct StructWithUnions { |
| 126 | 1: optional i32 intValue; |
| 127 | 2: optional SmallStruct smallStruct; |
| 128 | 3: optional SimpleUnion simpleUnion; |
| 129 | 4: optional list<SimpleUnion> unionList; |
| 130 | 5: optional set<SimpleUnion> unionSet (nolint = "set.value.type"); |
| 131 | 6: optional map<SimpleUnion, string> keyUnionMap (nolint = "map.key.type"); |
| 132 | 7: optional map<string, SimpleUnion> valUnionMap; |
| 133 | 8: optional map<SimpleUnion, SimpleUnion> unionMap (nolint = "map.key.type"); |
| 134 | } |