Checks if given type is java.util.Optional with a generic type parameter.

@param type
@return true if and only if type is a parameterized Optional
189867
public static boolean isOptional(final Type type) {
        if (OPTIONAL_CLASS == null) {
            return false;
        }

        if (!(type instanceof ParameterizedType)) {
            // Either this is no Optional, or it's a raw optional which is useless for us anyway...
            return false;
        }

        return OPTIONAL_CLASS.equals(((ParameterizedType) type).getRawType());
    }
59751
public static boolean isIntrospectable(final Class<?> type) {
        return !isEnumType(type)
                && !isArrayType(type)
                && !(isCollectionType(type) && isJdkBuiltIn(type))
                && !(isMapType(type) && isJdkBuiltIn(type));
    }
1344017
public Boolean checkType(String type) {
    if (mtasPositionType == null) {
      return false;
    } else {
      return mtasPositionType.equals(type);
    }
  }
1337540
public static boolean isInner(final Type type) {
        if (type instanceof ParameterizedType) {
            return ((ParameterizedType) type).getOwnerType() != null;
        }
        final Class<?> actual = GenericsUtils.resolveClassIgnoringVariables(type);
        // interface is always static and can't use outer generics
        return !actual.isInterface() && actual.isMemberClass() && !Modifier.isStatic(actual.getModifiers());
    }
6125
public static @Nonnull Optional<Class> arrayTypeForPrimitive(String primitiveType) {
        if (primitiveType != null) {
            return Optional.ofNullable(PRIMITIVE_ARRAY_MAP.get(primitiveType));
        }
        return Optional.empty();
    }
1201540
public static boolean isOptional(TypeRef type) {
        if (!(type instanceof ClassRef)) {
            return false;
        }

        return JAVA_UTIL_OPTIONAL.equals(((ClassRef)type).getDefinition().getFullyQualifiedName());
    }
689852
public static boolean isPrimitive(Class<?> type) {
		if (type.isPrimitive()) {
			return true;
		}
		// check if wrapper;
		if (PRIMITIVES_TO_WRAPPERS.values().contains(type)) {
			return true;
		}
		return false;
	}
1210795
private boolean isPresent(CobolOptionalType optionalType) {
        if (optionalType.getDependingOn() != null) {
            return getOdoValue(optionalType.getDependingOn()) > 0;
        }
        return true;
    }
344256
static boolean isBivariantType(JSType type) {
    ObjectType objType = type.toObjectType();
    return objType != null
        // && objType.isNativeObjectType()
        && BIVARIANT_TYPES.contains(objType.getReferenceName());
  }
558760
public static Optional<Class> resolveSuperGenericTypeArgument(Class type) {
        try {
            Type genericSuperclass = type.getGenericSuperclass();
            if (genericSuperclass instanceof ParameterizedType) {
                return resolveSingleTypeArgument(genericSuperclass);
            }
            return Optional.empty();
        } catch (NoClassDefFoundError e) {
            return Optional.empty();
        }
    }
855710
protected static boolean typeCheckMethodArgumentWithGenerics(ClassNode parameterType, ClassNode argumentType, boolean lastArg) {
        if (UNKNOWN_PARAMETER_TYPE == argumentType) {
            // called with null
            return !isPrimitiveType(parameterType);
        }
        if (!isAssignableTo(argumentType, parameterType) && !lastArg) {
            // incompatible assignment
            return false;
        }
        if (!isAssignableTo(argumentType, parameterType) && lastArg) {
            if (parameterType.isArray()) {
                if (!isAssignableTo(argumentType, parameterType.getComponentType())) {
                    return false;
                }
            } else {
                return false;
            }
        }
        if (parameterType.isUsingGenerics() && argumentType.isUsingGenerics()) {
            GenericsType gt = GenericsUtils.buildWildcardType(parameterType);
            if (!gt.isCompatibleWith(argumentType)) {
                boolean samCoercion = isSAMType(parameterType) && argumentType.equals(CLOSURE_TYPE);
                if (!samCoercion) return false;
            }
        } else if (parameterType.isArray() && argumentType.isArray()) {
            // verify component type
            return typeCheckMethodArgumentWithGenerics(parameterType.getComponentType(), argumentType.getComponentType(), lastArg);
        } else if (lastArg && parameterType.isArray()) {
            // verify component type, but if we reach that point, the only possibility is that the argument is
            // the last one of the call, so we're in the cast of a vargs call
            // (otherwise, we face a type checker bug)
            return typeCheckMethodArgumentWithGenerics(parameterType.getComponentType(), argumentType, lastArg);
        }
        return true;
    }
1144561
private boolean matches(ParameterizedType requiredType, ParameterizedType beanType) {
        if (!requiredType.getRawType().equals(beanType.getRawType())) {
            return false;
        }
        if (requiredType.getActualTypeArguments().length != beanType.getActualTypeArguments().length) {
            throw new IllegalArgumentException("Invalid argument combination " + requiredType + "; " + beanType);
        }
        for (int i = 0; i < requiredType.getActualTypeArguments().length; i++) {
            if (!parametersMatch(requiredType.getActualTypeArguments()[i], beanType.getActualTypeArguments()[i])) {
                return false;
            }
        }
        return true;
    }
760753
@SuppressWarnings("unchecked")
    public static <T> Optional<T> or(final Optional<T> a, final Optional<? extends T> b) {
        return a.isPresent() ? a : (Optional<T>) b;
    }
766188
public static boolean isNoValueType(Class<?> type) {

        LettuceAssert.notNull(type, "Class must not be null!");

        return findDescriptor(type).map(Descriptor::isNoValue).orElse(false);
    }
506627
public boolean hasConversion(String type) {
		if ((isImplicitSarlTypes() && type.startsWith(IMPLICIT_PACKAGE))
			|| isImplicitJvmTypes()) {
			return true;
		}
		if (this.mapping == null) {
			this.mapping = initMapping();
		}
		return this.mapping.containsKey(type);
	}
299988
public final static boolean isClassType(final Type type) {
        if (type instanceof Class) return true;
        if (type instanceof WildcardType) return false;
        if (type instanceof TypeVariable) return false;
        if (type instanceof GenericArrayType) return isClassType(((GenericArrayType) type).getGenericComponentType());
        if (!(type instanceof ParameterizedType)) return false; //只能是null了
        final ParameterizedType ptype = (ParameterizedType) type;
        if (ptype.getOwnerType() != null && !isClassType(ptype.getOwnerType())) return false;
        if (!isClassType(ptype.getRawType())) return false;
        for (Type t : ptype.getActualTypeArguments()) {
            if (!isClassType(t)) return false;
        }
        return true;
    }
120637
public static boolean isPackageValid(final Class type) {
        boolean res = false;
        if (type != null) {
            final Package packaj = type.getPackage();
            res = !(packaj == null || packaj.getName().startsWith("java"));
        }
        return res;
    }