+
+ @SuppressWarnings("unchecked")
+ public static Collection<ITreeTableCell> getTreeTableCell(IJSONObject object) {
+ try {
+ Object treeTableCells = object.getValue("tableCells");
+ if (treeTableCells instanceof String) {
+ String tableCellsS = (String) treeTableCells;
+ if (tableCellsS.length() == 0)
+ return Collections.emptyList();
+ }
+ if (treeTableCells != null) {
+ return (List<ITreeTableCell>) treeTableCells;
+ } else {
+ return Collections.emptyList();
+ }
+ } catch (ClassCastException e) {
+ e.printStackTrace();
+ }
+ return Collections.emptyList();
+ }
+
+ public static final boolean equalObjects(Object oldValue, Object newValue) {
+ if (newValue != null) {
+ if (newValue.getClass().isArray()) {
+ return arrayEquals(newValue, oldValue);
+ } else {
+ return newValue.equals(oldValue);
+ }
+ } else
+ return oldValue == null;
+ }
+
+
+ /**
+ * @param av1 an array (guaranteed)
+ * @param av2 any object
+ * @return <code>true</code> if the two arrays are equal
+ */
+ private static final boolean arrayEquals(Object av1, Object av2) {
+ if (av2 == null)
+ return false;
+ Class<?> c1 = av1.getClass().getComponentType();
+ Class<?> c2 = av2.getClass().getComponentType();
+ if (c2 == null || !c1.equals(c2))
+ return false;
+ boolean p1 = c1.isPrimitive();
+ boolean p2 = c2.isPrimitive();
+ if (p1 != p2)
+ return false;
+ if (!p1)
+ return Arrays.equals((Object[]) av1, (Object[]) av2);
+ if (boolean.class.equals(c1))
+ return Arrays.equals((boolean[]) av1, (boolean[]) av2);
+ else if (byte.class.equals(c1))
+ return Arrays.equals((byte[]) av1, (byte[]) av2);
+ else if (int.class.equals(c1))
+ return Arrays.equals((int[]) av1, (int[]) av2);
+ else if (long.class.equals(c1))
+ return Arrays.equals((long[]) av1, (long[]) av2);
+ else if (float.class.equals(c1))
+ return Arrays.equals((float[]) av1, (float[]) av2);
+ else if (double.class.equals(c1))
+ return Arrays.equals((double[]) av1, (double[]) av2);
+ throw new RuntimeException("Unsupported objects for equality testing ." + av1 + " vs. " + av2);
+
+ }
+
+