1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ********************************************************************** 6 * Copyright (c) 2002-2014, Google, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 ********************************************************************** 9 * Author: Mark Davis 10 ********************************************************************** 11 */ 12 package ohos.global.icu.impl; 13 14 import java.util.Objects; 15 16 import ohos.global.icu.util.Freezable; 17 18 19 /** 20 * @hide exposed on OHOS 21 */ 22 @SuppressWarnings({ "unchecked", "rawtypes" }) 23 public class Row<C0, C1, C2, C3, C4> implements java.lang.Comparable, Cloneable, 24 Freezable<Row<C0, C1, C2, C3, C4>>{ 25 protected Object[] items; 26 protected volatile boolean frozen; 27 28 /** 29 * Convenience Methods 30 */ of(C0 p0, C1 p1)31 public static <C0, C1> R2<C0,C1> of(C0 p0, C1 p1) { 32 return new R2<>(p0,p1); 33 } of(C0 p0, C1 p1, C2 p2)34 public static <C0, C1, C2> R3<C0,C1,C2> of(C0 p0, C1 p1, C2 p2) { 35 return new R3<>(p0,p1,p2); 36 } of(C0 p0, C1 p1, C2 p2, C3 p3)37 public static <C0, C1, C2, C3> R4<C0,C1,C2,C3> of(C0 p0, C1 p1, C2 p2, C3 p3) { 38 return new R4<>(p0,p1,p2,p3); 39 } of(C0 p0, C1 p1, C2 p2, C3 p3, C4 p4)40 public static <C0, C1, C2, C3, C4> R5<C0,C1,C2,C3,C4> of(C0 p0, C1 p1, C2 p2, C3 p3, C4 p4) { 41 return new R5<>(p0,p1,p2,p3,p4); 42 } 43 44 /** 45 * @hide exposed on OHOS 46 */ 47 public static class R2<C0, C1> extends Row<C0, C1, C1, C1, C1> { R2(C0 a, C1 b)48 public R2(C0 a, C1 b) { 49 items = new Object[] {a, b}; 50 } 51 } 52 /** 53 * @hide exposed on OHOS 54 */ 55 public static class R3<C0, C1, C2> extends Row<C0, C1, C2, C2, C2> { R3(C0 a, C1 b, C2 c)56 public R3(C0 a, C1 b, C2 c) { 57 items = new Object[] {a, b, c}; 58 } 59 } 60 /** 61 * @hide exposed on OHOS 62 */ 63 public static class R4<C0, C1, C2, C3> extends Row<C0, C1, C2, C3, C3> { R4(C0 a, C1 b, C2 c, C3 d)64 public R4(C0 a, C1 b, C2 c, C3 d) { 65 items = new Object[] {a, b, c, d}; 66 } 67 } 68 /** 69 * @hide exposed on OHOS 70 */ 71 public static class R5<C0, C1, C2, C3, C4> extends Row<C0, C1, C2, C3, C4> { R5(C0 a, C1 b, C2 c, C3 d, C4 e)72 public R5(C0 a, C1 b, C2 c, C3 d, C4 e) { 73 items = new Object[] {a, b, c, d, e}; 74 } 75 } 76 set0(C0 item)77 public Row<C0, C1, C2, C3, C4> set0(C0 item) { 78 return set(0, item); 79 } get0()80 public C0 get0() { 81 return (C0) items[0]; 82 } set1(C1 item)83 public Row<C0, C1, C2, C3, C4> set1(C1 item) { 84 return set(1, item); 85 } get1()86 public C1 get1() { 87 return (C1) items[1]; 88 } set2(C2 item)89 public Row<C0, C1, C2, C3, C4> set2(C2 item) { 90 return set(2, item); 91 } get2()92 public C2 get2() { 93 return (C2) items[2]; 94 } set3(C3 item)95 public Row<C0, C1, C2, C3, C4> set3(C3 item) { 96 return set(3, item); 97 } get3()98 public C3 get3() { 99 return (C3) items[3]; 100 } set4(C4 item)101 public Row<C0, C1, C2, C3, C4> set4(C4 item) { 102 return set(4, item); 103 } get4()104 public C4 get4() { 105 return (C4) items[4]; 106 } 107 set(int i, Object item)108 protected Row<C0, C1, C2, C3, C4> set(int i, Object item) { 109 if (frozen) { 110 throw new UnsupportedOperationException("Attempt to modify frozen object"); 111 } 112 items[i] = item; 113 return this; 114 } 115 116 @Override hashCode()117 public int hashCode() { 118 int sum = items.length; 119 for (Object item : items) { 120 sum = sum*37 + Utility.checkHash(item); 121 } 122 return sum; 123 } 124 125 @Override equals(Object other)126 public boolean equals(Object other) { 127 if (other == null) { 128 return false; 129 } 130 if (this == other) { 131 return true; 132 } 133 try { 134 Row<C0, C1, C2, C3, C4> that = (Row<C0, C1, C2, C3, C4>)other; 135 if (items.length != that.items.length) { 136 return false; 137 } 138 int i = 0; 139 for (Object item : items) { 140 if (!Objects.equals(item, that.items[i++])) { 141 return false; 142 } 143 } 144 return true; 145 } catch (Exception e) { 146 return false; 147 } 148 } 149 150 @Override compareTo(Object other)151 public int compareTo(Object other) { 152 int result; 153 Row<C0, C1, C2, C3, C4> that = (Row<C0, C1, C2, C3, C4>)other; 154 result = items.length - that.items.length; 155 if (result != 0) { 156 return result; 157 } 158 int i = 0; 159 for (Object item : items) { 160 result = Utility.checkCompare(((Comparable)item), ((Comparable)that.items[i++])); 161 if (result != 0) { 162 return result; 163 } 164 } 165 return 0; 166 } 167 168 @Override toString()169 public String toString() { 170 StringBuilder result = new StringBuilder("["); 171 boolean first = true; 172 for (Object item : items) { 173 if (first) { 174 first = false; 175 } else { 176 result.append(", "); 177 } 178 result.append(item); 179 } 180 return result.append("]").toString(); 181 } 182 183 @Override isFrozen()184 public boolean isFrozen() { 185 return frozen; 186 } 187 188 @Override freeze()189 public Row<C0, C1, C2, C3, C4> freeze() { 190 frozen = true; 191 return this; 192 } 193 194 @Override clone()195 public Object clone() { 196 if (frozen) return this; 197 try { 198 Row<C0, C1, C2, C3, C4> result = (Row<C0, C1, C2, C3, C4>) super.clone(); 199 items = items.clone(); 200 return result; 201 } catch (CloneNotSupportedException e) { 202 return null; 203 } 204 } 205 206 @Override cloneAsThawed()207 public Row<C0, C1, C2, C3, C4> cloneAsThawed() { 208 try { 209 Row<C0, C1, C2, C3, C4> result = (Row<C0, C1, C2, C3, C4>) super.clone(); 210 items = items.clone(); 211 result.frozen = false; 212 return result; 213 } catch (CloneNotSupportedException e) { 214 return null; 215 } 216 } 217 } 218 219