NOTE: needs to be duplicated logic due to Java erasure of generic types
347620
public List<Post> getPosts() {
        Gson gson = gsonParser();
        JsonObject object = (JsonObject) response;
        List<Post> l = gson.fromJson(object.get("posts"), new TypeToken<List<Post>>() {}.getType());
        for (Post e : l) { e.setClient(client); }
        return l;
    }
653000
protected void privateDuplicate(TupleComparatorBase<T> toClone) {
		// copy fields and serializer factories
		this.keyPositions = toClone.keyPositions;

		this.serializers = new TypeSerializer[toClone.serializers.length];
		for (int i = 0; i < toClone.serializers.length; i++) {
			this.serializers[i] = toClone.serializers[i].duplicate();
		}

		this.comparators = new TypeComparator[toClone.comparators.length];
		for (int i = 0; i < toClone.comparators.length; i++) {
			this.comparators[i] = toClone.comparators[i].duplicate();
		}

		this.normalizedKeyLengths = toClone.normalizedKeyLengths;
		this.numLeadingNormalizableKeys = toClone.numLeadingNormalizableKeys;
		this.normalizableKeyPrefixLen = toClone.normalizableKeyPrefixLen;
		this.invertNormKey = toClone.invertNormKey;
	}
649730
@Override
   public ValueAndDeclaredType traverse(final Object toTraverse, final String type, final boolean onlyToParent,
            final String... names)
   {
      // Traverse through names (if any)

      if ((names == null) || (names.length == 0))
      {
         // If no names, no parent

         if (onlyToParent)
         {
            return new ValueAndDeclaredType(null, null);
         }

         return new ValueAndDeclaredType(null, type);
      }

      String traverseDeclaredType = type;

      for (int loop = 0, length = names.length; loop < length; loop++)
      {
         if (onlyToParent && (loop >= (length - 1)))
         {
            return new ValueAndDeclaredType(null, traverseDeclaredType);
         }

         String name = names[loop];
         Property property = getProperties(traverseDeclaredType).get(name);

         if ((property == null) || !property.isReadable())
         {
            return new ValueAndDeclaredType(null, null);
         }

         traverseDeclaredType = property.getType();
      }

      return new ValueAndDeclaredType(null, traverseDeclaredType);
   }
1303086
static LeafNodeDupMutable convert(@NotNull ILeafNode ln, @NotNull BTreeMutable mainTree) {

        final boolean isLeafNodeDup = ln.isDup();
        if (isLeafNodeDup && ln instanceof LeafNodeDupMutable) {
            return (LeafNodeDupMutable) ln;
        }

        // wrapper tree that doesn't allow duplicates
        final BTreeDupMutable dupTree = isLeafNodeDup ?
                ((LeafNodeDup) ln).getTreeCopyMutable() :
                new BTreeDupMutable(
                        new BTreeEmpty(mainTree.getLog(), mainTree.getBalancePolicy(), false, mainTree.getStructureId()),
                        ln.getKey()
                );
        dupTree.mainTree = mainTree;
        return convert(ln, mainTree, dupTree);
    }
320321
private String genericTypeAsString(GenericsType genericsType, boolean showRedirect) {
        String ret = genericsType.getName();
        if (genericsType.getUpperBounds() != null) {
            ret += " extends ";
            for (int i = 0; i < genericsType.getUpperBounds().length; i++) {
                ClassNode classNode = genericsType.getUpperBounds()[i];
                if (classNode.equals(this)) {
                    ret += classNode.getName();
                } else {
                    ret += classNode.toString(showRedirect);
                }
                if (i + 1 < genericsType.getUpperBounds().length) ret += " & ";
            }
        } else if (genericsType.getLowerBound() !=null) {
            ClassNode classNode = genericsType.getLowerBound();
            if (classNode.equals(this)) {
                ret += " super " + classNode.getName();
            } else {
                ret += " super " + classNode;
            }
        }
        return ret;
    }
1072208
public static <T> SameType<T> of(TreeDef<T> treeDef, T expected, T actual) {
		return of(treeDef, expected, treeDef, actual).mapToSame(Function.identity(), Function.identity());
	}
463185
@SuppressWarnings("unchecked")
	public static <T extends Throwable> T convertFromOrSuppressedThrowable(Throwable throwable, Class<T> exceptionClass, boolean checkCause) {
		if (throwable == null || exceptionClass == null) {
			return null;
		}
		if (exceptionClass.isAssignableFrom(throwable.getClass())) {
			return (T) throwable;
		}
		if (checkCause) {
			Throwable cause = throwable.getCause();
			if (cause != null && exceptionClass.isAssignableFrom(cause.getClass())) {
				return (T) cause;
			}
		}
		Throwable[] throwables = throwable.getSuppressed();
		if (ArrayUtil.isNotEmpty(throwables)) {
			for (Throwable throwable1 : throwables) {
				if (exceptionClass.isAssignableFrom(throwable1.getClass())) {
					return (T) throwable1;
				}
			}
		}
		return null;
	}
369838
@Override
    public Invoke duplicate() throws IOException, ClassNotFoundException {
        Invoke result = new Invoke();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        writeExternal(oos);
        oos.close();
        byte[] buf = baos.toByteArray();
        baos.close();
        ByteArrayInputStream bais = new ByteArrayInputStream(buf);
        ObjectInputStream ois = new ObjectInputStream(bais);
        result.readExternal(ois);
        ois.close();
        bais.close();
        return result;
    }
48265
@Override
    public <T extends Composite<S>> T copy() {
        try {
            String fullJSON = fullMapper.writeValueAsString(this);
            @SuppressWarnings("unchecked")
            T copy = (T) fullMapper.readValue(fullJSON, getClass());
            return copy;
        } catch (IOException e) {
            throw new RuntimeException("The attempted copy of an object failed.", e);
        }
    }
876907
@SuppressWarnings("unused")
    private // until I can get this to work
    <T extends Throwable> void rethrowCauseOfType(Class<T> type)
        throws Throwable // this should be throws T
    {
        T cause = causeOfType(type);

        // rethrow acts as if its always throwing Throwable, not the subclass.
        if (cause != null) throw cause;
    }
1149293
static <T> Object[] arguments(final Class<T> klass, final T instance,
                                  final Class<?>[] types,
                                  final String[] literals)
            throws ReflectiveOperationException {
        final Object[] arguments = new Object[literals.length];
        for (int i = 0; i < literals.length; i++) {
            if ("null".equals(literals[i])) {
                arguments[i] = null;
                continue;
            }
            if (literals[i].startsWith(":")) {
                final String name = literals[i].substring(1);
                final Field field = field(klass, name);
                if (!field.isAccessible()) {
                    field.setAccessible(true);
                }
                arguments[i] = field.get(instance);
                continue;
            }
            if (types[i] == String.class) {
                arguments[i] = literals[i];
                continue;
            }
            if (types[i].isPrimitive()) {
                types[i] = wrapper(types[i]);
            }
            arguments[i] = types[i]
                    .getMethod("valueOf", String.class)
                    .invoke(null, literals[i]);
        }
        return arguments;
    }
387282
public static ThrowableProto serializeThrowable(Throwable t) {
        final ThrowableProto.Builder builder = ThrowableProto.newBuilder();

        if (t instanceof StatusCauseException) {
            final StatusCauseException statusCause = (StatusCauseException) t;
            builder.setOriginalClassName(statusCause.getOriginalClassName());
            builder.setOriginalMessage(statusCause.getOriginalMessage());
        } else {
            builder.setOriginalClassName(t.getClass().getCanonicalName());
            builder.setOriginalMessage(Strings.nullToEmpty(t.getMessage()));
        }

        for (StackTraceElement element : t.getStackTrace()) {
            builder.addStackTrace(serializeStackTraceElement(element));
        }

        if (t.getCause() != null) {
            builder.setCause(serializeThrowable(t.getCause()));
        }
        return builder.build();
    }
655038
public static <T> T[] copyOf(final T[] original, final int newLength) {
        if (newLength == original.length) {
            return original.clone();
        }

        return (T[]) copyOf(original, newLength, original.getClass());
    }
706492
private static void copy(Class<?> toType, Object to, Object... from) {
        int f = 0, fi = 0,
            length = Array.getLength(from[0]),
            total = from.length > 1 ? Array.getLength(to) : length;
        if ( Types.arrayDimensions(to.getClass()) == 1 ) {
            for ( int i = 0; i < total; i++ ) {
                Object value = Array.get(from[f], fi++);
                try {
                    value = Primitive.unwrap(
                            Types.castObject(value, toType, Types.CAST));
                } catch (UtilEvalError e) { /* ignore cast errors */ }
                if ( Byte.TYPE == toType )
                    Array.setByte(to, i, (byte) value);
                else if ( Short.TYPE == toType )
                    Array.setShort(to, i, (short) value);
                else if ( Integer.TYPE == toType )
                    Array.setInt(to, i, (int) value);
                else if ( Long.TYPE == toType )
                    Array.setLong(to, i, (long) value);
                else if ( Float.TYPE == toType )
                    Array.setFloat(to, i, (float) value);
                else if ( Double.TYPE == toType )
                    Array.setDouble(to, i, (double) value);
                else if ( Character.TYPE == toType )
                    Array.setChar(to, i, (char) value);
                else if ( Boolean.TYPE == toType )
                    Array.setBoolean(to, i, (boolean) value);
                else
                    Array.set(to, i, value);

                // concatenate multiple from arrays
                if ( length < total && fi == length && f+1 < from.length ) {
                    length = Array.getLength(from[++f]);
                    fi = 0;
                }
            }
        } else for ( int i = 0; i < total; i++ ) {
            // concatenate multiple from arrays
            if ( length < total && fi == length && f+1 < from.length ) {
                length = Array.getLength(from[++f]);
                fi = 0;
            }

            Object frm = Array.get(from[f], fi++);

            // null dimension example: new Integer[2][]
            if ( null == frm ) {
                Array.set(to, i, null);
                continue;
            }

            Object tto = Array.get(to, i);

            // mixed array lengths in multiple dimensions ex: {{1,2}, {3}}
            if ( Array.getLength(frm) != Array.getLength(tto) )
                Array.set(to, i,
                    tto = Array.newInstance(toType, dimensions(frm)));

            // recurse copy for next array dimension
            copy(toType, tto, frm);
        }
    }
1192908
private static boolean isAssignableFrom(Type from, GenericArrayType to) {
		Type toGenericComponentType = to.getGenericComponentType();
		if (toGenericComponentType instanceof ParameterizedType) {
			Type t = from;
			if (from instanceof GenericArrayType) {
				t = ((GenericArrayType) from).getGenericComponentType();
			} else if (from instanceof Class) {
				Class<?> classType = (Class<?>) from;
				while (classType.isArray()) {
					classType = classType.getComponentType();
				}
				t = classType;
			}
			return isAssignableFrom(t,
					(ParameterizedType) toGenericComponentType,
					new HashMap<String, Type>());
		}
		// No generic defined on "to"; therefore, return true and let other
		// checks determine assignability
		return true;
	}
358286
Type sharpestAccessible(Type originalType) {
        if (originalType.hasTag(ARRAY)) {
            return types.makeArrayType(sharpestAccessible(types.elemtype(originalType)));
        }

        Type type = originalType;
        while (!rs.isAccessible(gen.getAttrEnv(), type.asElement())) {
            type = types.supertype(type);
        }
        return type;
    }
426808
Object toSimpleValue(Class<?> genericType, Object element, TypeAdapters typeAdapters) {
        if (element == null) {
            return null;
        }
        log.info("Convert from " + element.getClass().getName() + " to " + genericType.getName());
        if (genericType.isEnum() && (element instanceof String)) {
            @SuppressWarnings({ "unchecked", "rawtypes" })
            Enum<?> enumValue = Enum.valueOf((Class<? extends Enum>) genericType, (String) element);
            return enumValue;
        }
        Converter converter = SIMPLE_VALUE_CONVERTERS.get(genericType.getName());
        if (converter != null) {
            return converter.convert(element);
        }
        if ((element instanceof String) && (typeAdapters != null)) {
            TypeAdapter<?> adapter = typeAdapters.getTypeAdapter(genericType);
            if (adapter != null) {
                return adapter.deserialize((String) element);
            }
        }
        return element;
    }