Guava unwrap alternative.

@param type type
@return unwrapped result
550305
public static <T> Class<T> unwrap(Class<T> type) {
        if (type == null) {
            throw new IllegalArgumentException();
        }

        Class<T> unwrapped = (Class<T>) WRAP_TO_PRIMITIVE.get(type);
        return (unwrapped == null) ? type : unwrapped;
    }
460982
public IOException unwrapRemoteException(Class<?>... lookupTypes) {
    if(lookupTypes == null)
      return this;
    for(Class<?> lookupClass : lookupTypes) {
      if(!lookupClass.getName().equals(getClassName()))
        continue;
      try {
        return instantiateException(lookupClass.asSubclass(IOException.class));
      } catch(Exception e) {
        // cannot instantiate lookupClass, just return this
        return this;
      }
    }
    // wrapped up exception is not in lookupTypes, just return this
    return this;
  }
498362
public static<T extends Object> T getWrapper(Class<T> clientType){
        return getWrapper(clientType,generateClientId(clientType));
    }
1364218
@Unstable
    public static String serializeType(Type type)
    {
        if (type == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder();
        if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) type;

            String rawTypeName = getTypeName(parameterizedType.getRawType());

            if (parameterizedType.getOwnerType() != null) {
                if (parameterizedType.getOwnerType() instanceof Class) {
                    sb.append(((Class<?>) parameterizedType.getOwnerType()).getName());
                } else {
                    sb.append(parameterizedType.getOwnerType().toString());
                }

                sb.append('.');


                if (parameterizedType.getOwnerType() instanceof ParameterizedType) {
                    // Find simple name of nested type by removing the
                    // shared prefix with owner.
                    sb.append(rawTypeName.replace(
                        ((Class<?>) ((ParameterizedType) parameterizedType.getOwnerType()).getRawType())
                            .getName() + '$', ""));
                } else {
                    sb.append(rawTypeName);
                }
            } else {
                sb.append(rawTypeName);
            }

            if (parameterizedType.getActualTypeArguments() != null
                && parameterizedType.getActualTypeArguments().length > 0) {
                sb.append(OPEN_GENERIC);

                boolean first = true;
                for (Type typeArgument : parameterizedType.getActualTypeArguments()) {
                    if (!first) {
                        sb.append(", ");
                    }
                    sb.append(getTypeName(typeArgument));
                    first = false;
                }

                sb.append(CLOSE_GENERIC);
            }
        } else {
            sb.append(getTypeName(type));
        }

        return sb.toString();
    }
823316
public static Class unwrapType(Class pType) {
        if (pType == Boolean.class) {
            return Boolean.TYPE;
        }
        else if (pType == Byte.class) {
            return Byte.TYPE;
        }
        else if (pType == Character.class) {
            return Character.TYPE;
        }
        else if (pType == Double.class) {
            return Double.TYPE;
        }
        else if (pType == Float.class) {
            return Float.TYPE;
        }
        else if (pType == Integer.class) {
            return Integer.TYPE;
        }
        else if (pType == Long.class) {
            return Long.TYPE;
        }
        else if (pType == Short.class) {
            return Short.TYPE;
        }

        throw new IllegalArgumentException("Not a primitive wrapper: " + pType);
    }
1133195
@NonNull
  public final GenericType<T> unwrap() {
    if (Primitives.allWrapperTypes().contains(token.getRawType())) {
      return new GenericType<>(token.unwrap());
    }
    return this;
  }
1069881
protected Object coerceToType(Object param, Class<?> type)
            throws Throwable {
        if (type != Object.class)
            param = Types.castObject(param, type, Types.CAST);
        return Primitive.unwrap(param);
    }
1266433
public <T> T unwrap(Class<T> iface)    throws SQLException
    {
        try
        {
            return iface.cast(this);
        }
         catch (ClassCastException cce)
         {
            throw SQLError.get(SQLError.ILLEGAL_ARGUMENT, iface.toString());
        }
    }
863338
public static GraphQLUnmodifiedType unwrapAll(GraphQLType type) {
        while (true) {
            if (isNotWrapped(type)) {
                return (GraphQLUnmodifiedType) type;
            }
            type = unwrapOne(type);
        }
    }
400834
public Object convertResult(final Class<?> type) {
		try {
			if (type.isArray()) {
				return TYPE_MAP.get("array").invoke(this);
			}
			if (!TYPE_MAP.containsKey(type)) {
				return getNext(result);
			}
			return TYPE_MAP.get(type).invoke(this);
		} catch (final Exception e) {
			e.printStackTrace();
			return null;
		}
	}
1165942
public Optional<MapperInstance> getSerializer( JType type ) {
        return Optional.fromNullable( serializers.get( type.getQualifiedSourceName() ) );
    }
366208
@SuppressWarnings ( "unchecked" )
    @Override
    public <T extends Address> T unwrap ( Class<T> type ) {
        if ( this.addr instanceof Address ) {
            return ( (Address) this.addr ).unwrap(type);
        }
        else if ( this.getClass().isAssignableFrom(type) ) {
            return (T) this;
        }
        return null;
    }
835008
public static Object unwrap(final Class<?> type, final Object object) throws Exception {
        if (object == null) {
            return null;
        }
        if (type == null) {
            return object;
        }
        if (Callable.class.equals(type)) {
            assert (object instanceof Callable);
            return ((Callable<?>) object).call();
        }

        if ("java.util.function.Supplier".equals(type.getName())) {
            return findMethodByName(type, "get").invoke(object, (Object[]) null);
        }

        return object;
    }
765232
public static @NonNull Throwable unwrap(final @NonNull Throwable throwable) {
    if(throwable instanceof InvocationTargetException) {
      final /* @Nullable */ Throwable cause = throwable.getCause();
      if(cause != null) {
        return cause;
      }
    }
    return throwable;
  }
297299
public static int scalarIntegralTypeToGL(final JCGLScalarIntegralType type)
  {
    switch (type) {
      case TYPE_BYTE:
        return GL11.GL_BYTE;
      case TYPE_INT:
        return GL11.GL_INT;
      case TYPE_SHORT:
        return GL11.GL_SHORT;
      case TYPE_UNSIGNED_BYTE:
        return GL11.GL_UNSIGNED_BYTE;
      case TYPE_UNSIGNED_INT:
        return GL11.GL_UNSIGNED_INT;
      case TYPE_UNSIGNED_SHORT:
        return GL11.GL_UNSIGNED_SHORT;
    }

    throw new UnreachableCodeException();
  }
412165
public boolean unresolveType(final Class<? extends Entity> type) {
	return resolved.remove(Objects.requireNonNull(type)) != null;
    }
708912
@Factory
    public static <T extends Throwable> Matcher<T> isThrowable(Class<?> type) {
        final Matcher<T> typeMatcher = instanceOf(type);
        return new IsThrowable<>(typeMatcher);
    }