1 /* 2 * This file is auto-generated. DO NOT MODIFY. 3 */ 4 package android.aidl.tests; 5 6 public final class Union implements android.os.Parcelable { 7 // tags for union fields 8 public final static int ns = 0; // int[] ns; 9 public final static int n = 1; // int n; 10 public final static int m = 2; // int m; 11 public final static int s = 3; // String s; 12 public final static int ibinder = 4; // IBinder ibinder; 13 public final static int ss = 5; // List<String> ss; 14 public final static int be = 6; // android.aidl.tests.ByteEnum be; 15 16 private int _tag; 17 private Object _value; 18 Union()19 public Union() { 20 int[] _value = {}; 21 this._tag = ns; 22 this._value = _value; 23 } 24 Union(android.os.Parcel _aidl_parcel)25 private Union(android.os.Parcel _aidl_parcel) { 26 readFromParcel(_aidl_parcel); 27 } 28 Union(int _tag, Object _value)29 private Union(int _tag, Object _value) { 30 this._tag = _tag; 31 this._value = _value; 32 } 33 getTag()34 public int getTag() { 35 return _tag; 36 } 37 38 // int[] ns; 39 ns(int[] _value)40 public static Union ns(int[] _value) { 41 return new Union(ns, _value); 42 } 43 getNs()44 public int[] getNs() { 45 _assertTag(ns); 46 return (int[]) _value; 47 } 48 setNs(int[] _value)49 public void setNs(int[] _value) { 50 _set(ns, _value); 51 } 52 53 // int n; 54 n(int _value)55 public static Union n(int _value) { 56 return new Union(n, _value); 57 } 58 getN()59 public int getN() { 60 _assertTag(n); 61 return (int) _value; 62 } 63 setN(int _value)64 public void setN(int _value) { 65 _set(n, _value); 66 } 67 68 // int m; 69 m(int _value)70 public static Union m(int _value) { 71 return new Union(m, _value); 72 } 73 getM()74 public int getM() { 75 _assertTag(m); 76 return (int) _value; 77 } 78 setM(int _value)79 public void setM(int _value) { 80 _set(m, _value); 81 } 82 83 // String s; 84 s(java.lang.String _value)85 public static Union s(java.lang.String _value) { 86 return new Union(s, _value); 87 } 88 getS()89 public java.lang.String getS() { 90 _assertTag(s); 91 return (java.lang.String) _value; 92 } 93 setS(java.lang.String _value)94 public void setS(java.lang.String _value) { 95 _set(s, _value); 96 } 97 98 // IBinder ibinder; 99 ibinder(android.os.IBinder _value)100 public static Union ibinder(android.os.IBinder _value) { 101 return new Union(ibinder, _value); 102 } 103 getIbinder()104 public android.os.IBinder getIbinder() { 105 _assertTag(ibinder); 106 return (android.os.IBinder) _value; 107 } 108 setIbinder(android.os.IBinder _value)109 public void setIbinder(android.os.IBinder _value) { 110 _set(ibinder, _value); 111 } 112 113 // List<String> ss; 114 ss(java.util.List<java.lang.String> _value)115 public static Union ss(java.util.List<java.lang.String> _value) { 116 return new Union(ss, _value); 117 } 118 119 @SuppressWarnings("unchecked") getSs()120 public java.util.List<java.lang.String> getSs() { 121 _assertTag(ss); 122 return (java.util.List<java.lang.String>) _value; 123 } 124 setSs(java.util.List<java.lang.String> _value)125 public void setSs(java.util.List<java.lang.String> _value) { 126 _set(ss, _value); 127 } 128 129 // android.aidl.tests.ByteEnum be; 130 be(byte _value)131 public static Union be(byte _value) { 132 return new Union(be, _value); 133 } 134 getBe()135 public byte getBe() { 136 _assertTag(be); 137 return (byte) _value; 138 } 139 setBe(byte _value)140 public void setBe(byte _value) { 141 _set(be, _value); 142 } 143 144 public static final android.os.Parcelable.Creator<Union> CREATOR = new android.os.Parcelable.Creator<Union>() { 145 @Override 146 public Union createFromParcel(android.os.Parcel _aidl_source) { 147 return new Union(_aidl_source); 148 } 149 @Override 150 public Union[] newArray(int _aidl_size) { 151 return new Union[_aidl_size]; 152 } 153 }; 154 155 @Override writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag)156 public final void writeToParcel(android.os.Parcel _aidl_parcel, int _aidl_flag) { 157 _aidl_parcel.writeInt(_tag); 158 switch (_tag) { 159 case ns: 160 _aidl_parcel.writeIntArray(getNs()); 161 break; 162 case n: 163 _aidl_parcel.writeInt(getN()); 164 break; 165 case m: 166 _aidl_parcel.writeInt(getM()); 167 break; 168 case s: 169 _aidl_parcel.writeString(getS()); 170 break; 171 case ibinder: 172 _aidl_parcel.writeStrongBinder(getIbinder()); 173 break; 174 case ss: 175 _aidl_parcel.writeStringList(getSs()); 176 break; 177 case be: 178 _aidl_parcel.writeByte(getBe()); 179 break; 180 } 181 } 182 readFromParcel(android.os.Parcel _aidl_parcel)183 public void readFromParcel(android.os.Parcel _aidl_parcel) { 184 int _aidl_tag; 185 _aidl_tag = _aidl_parcel.readInt(); 186 switch (_aidl_tag) { 187 case ns: { 188 int[] _aidl_value; 189 _aidl_value = _aidl_parcel.createIntArray(); 190 _set(_aidl_tag, _aidl_value); 191 return; } 192 case n: { 193 int _aidl_value; 194 _aidl_value = _aidl_parcel.readInt(); 195 _set(_aidl_tag, _aidl_value); 196 return; } 197 case m: { 198 int _aidl_value; 199 _aidl_value = _aidl_parcel.readInt(); 200 _set(_aidl_tag, _aidl_value); 201 return; } 202 case s: { 203 java.lang.String _aidl_value; 204 _aidl_value = _aidl_parcel.readString(); 205 _set(_aidl_tag, _aidl_value); 206 return; } 207 case ibinder: { 208 android.os.IBinder _aidl_value; 209 _aidl_value = _aidl_parcel.readStrongBinder(); 210 _set(_aidl_tag, _aidl_value); 211 return; } 212 case ss: { 213 java.util.List<java.lang.String> _aidl_value; 214 _aidl_value = _aidl_parcel.createStringArrayList(); 215 _set(_aidl_tag, _aidl_value); 216 return; } 217 case be: { 218 byte _aidl_value; 219 _aidl_value = _aidl_parcel.readByte(); 220 _set(_aidl_tag, _aidl_value); 221 return; } 222 } 223 throw new IllegalArgumentException("union: unknown tag: " + _aidl_tag); 224 } 225 226 public static final String S1 = "a string constant in union"; 227 @Override describeContents()228 public int describeContents() { 229 int _mask = 0; 230 switch (getTag()) { 231 } 232 return _mask; 233 } 234 235 @Override toString()236 public String toString() { 237 switch (_tag) { 238 case ns: return "android.aidl.tests.Union.ns(" + (java.util.Arrays.toString(getNs())) + ")"; 239 case n: return "android.aidl.tests.Union.n(" + (getN()) + ")"; 240 case m: return "android.aidl.tests.Union.m(" + (getM()) + ")"; 241 case s: return "android.aidl.tests.Union.s(" + (java.util.Objects.toString(getS())) + ")"; 242 case ibinder: return "android.aidl.tests.Union.ibinder(" + (java.util.Objects.toString(getIbinder())) + ")"; 243 case ss: return "android.aidl.tests.Union.ss(" + (java.util.Objects.toString(getSs())) + ")"; 244 case be: return "android.aidl.tests.Union.be(" + (getBe()) + ")"; 245 } 246 throw new IllegalStateException("unknown field: " + _tag); 247 } 248 @Override equals(Object other)249 public boolean equals(Object other) { 250 if (this == other) return true; 251 if (other == null) return false; 252 if (!(other instanceof Union)) return false; 253 Union that = (Union)other; 254 if (_tag != that._tag) return false; 255 if (!java.util.Objects.deepEquals(_value, that._value)) return false; 256 return true; 257 } 258 259 @Override hashCode()260 public int hashCode() { 261 return java.util.Arrays.deepHashCode(java.util.Arrays.asList(_tag, _value).toArray()); 262 } 263 _assertTag(int tag)264 private void _assertTag(int tag) { 265 if (getTag() != tag) { 266 throw new IllegalStateException("bad access: " + _tagString(tag) + ", " + _tagString(getTag()) + " is available."); 267 } 268 } 269 _tagString(int _tag)270 private String _tagString(int _tag) { 271 switch (_tag) { 272 case ns: return "ns"; 273 case n: return "n"; 274 case m: return "m"; 275 case s: return "s"; 276 case ibinder: return "ibinder"; 277 case ss: return "ss"; 278 case be: return "be"; 279 } 280 throw new IllegalStateException("unknown field: " + _tag); 281 } 282 _set(int _tag, Object _value)283 private void _set(int _tag, Object _value) { 284 this._tag = _tag; 285 this._value = _value; 286 } 287 } 288