Given two types, returns true if the first can be viewed as the second.
NOTE that <code>canMean()</code> is orthogonal to <code>ofType()</code>.
761809
public static boolean canMean( int actual, int preferred ) {

        if( actual == preferred ) {
            return true;
        }

        switch( preferred ) {

            case SYNTH_PARAMETER_DECLARATION:
            case IDENTIFIER:
                switch( actual ) {
                    case IDENTIFIER:
                    case KEYWORD_DEF:
                    case KEYWORD_DEFMACRO:
                    case KEYWORD_CLASS:
                    case KEYWORD_INTERFACE:
                    case KEYWORD_MIXIN:
                        return true;
                }
                break;

            case SYNTH_CLASS:
            case SYNTH_INTERFACE:
            case SYNTH_MIXIN:
            case SYNTH_METHOD:
            case SYNTH_PROPERTY:
                return actual == IDENTIFIER;

            case SYNTH_LIST:
            case SYNTH_MAP:
                return actual == LEFT_SQUARE_BRACKET;

            case SYNTH_CAST:
                return actual == LEFT_PARENTHESIS;

            case SYNTH_BLOCK:
            case SYNTH_CLOSURE:
                return actual == LEFT_CURLY_BRACE;

            case SYNTH_LABEL:
                return actual == COLON;

            case SYNTH_VARIABLE_DECLARATION:
                return actual == IDENTIFIER;
        }

        return false;
    }
230400
@Pure
	protected boolean isSubTypeOf(EObject context, JvmTypeReference subType, JvmTypeReference superType) {
		if (isTypeReference(superType) && isTypeReference(subType)) {
			StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context);
			LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false);
			LightweightTypeReference reference = factory.toLightweightReference(subType);
			return reference.isSubtypeOf(superType.getType());
		}
		return false;
	}
1087307
public boolean isAssignableFrom(JvmType type) {
		if (type == null) {
			throw new IllegalArgumentException("type may not be null");
		}
		LightweightTypeReference other = getOwner().toPlainTypeReference(type);
		boolean result = isAssignableFrom(other);
		return result;
	}
740482
boolean checkUnionEquivalenceHelper(UnionType that, EquivalenceMethod eqMethod, EqCache eqCache) {
    List<JSType> thatAlternates = that.getAlternates();
    if (eqMethod == EquivalenceMethod.IDENTITY && alternates.size() != thatAlternates.size()) {
      return false;
    }
    for (int i = 0; i < thatAlternates.size(); i++) {
      JSType thatAlternate = thatAlternates.get(i);
      if (!hasAlternate(thatAlternate, eqMethod, eqCache)) {
        return false;
      }
    }
    return true;
  }
1363876
public boolean isSameType( ImageType o ) {
		if( family != o.family )
			return false;
		if( dataType != o.dataType)
			return false;
		if( numBands != o.numBands )
			return false;
		return true;
	}
1223457
public static boolean canAccept(String headerValue, boolean strict, String type) {
    if(headerValue != null && type != null)  {
      String availableTypes[] = headerValue.split(",");
      for(String availableType : availableTypes) {
        String typeParams[] = availableType.split(";");
        double qValue = 1.0d;
        if(typeParams.length > 0) {
          for(int i=1; i<typeParams.length; i++) {
            if(typeParams[i].trim().startsWith("q=")) {
              String qString = typeParams[i].substring(2).trim();
              if(qString.matches("\\A\\d+(\\.\\d*){0,1}\\Z")){
                qValue = Double.parseDouble(qString);
                break;
              } 
            }
          }
        }
        boolean matches = false;
        if(typeParams[0].equals("*") || typeParams[0].equals("*/*")) {
          matches = true;
        } else {
          matches = hasMatch(typeParams, type);
        }
        if(qValue == 0 && matches) {
          return false;
        } else if(matches){
          return true;
        }
      }
    }
    return !strict;
  }
1244071
private static boolean isAssignableFrom(TypeVariable<?> type1, TypeVariable<?> type2) {
        if (type1.equals(type2)) {
            return true;
        }
        // if a type variable extends another type variable, it cannot declare other bounds
        if (type2.getBounds()[0] instanceof TypeVariable<?>) {
            return isAssignableFrom(type1, (TypeVariable<?>) type2.getBounds()[0]);
        }
        return false;
    }
137100
public boolean equal(final Object o1,
                         final Object o2) {
        if ( o1 instanceof InternalFactHandle ) {
            return ((InternalFactHandle) o1).getId() == ((InternalFactHandle) o2).getId();
        }
        Object left = o1;
        final InternalFactHandle handle = ((InternalFactHandle) o2);

        if ( left == handle.getObject() ) {
            return true;
        } else if ( handle.getTraitType() == TraitTypeEnum.WRAPPED_TRAITABLE ) {
            return left == ( (CoreWrapper) handle.getObject() ).getCore();
        } else {
            return false;
        }
    }
720325
public final boolean isAssignableFrom(SoyType srcType) {
    // Handle unions generically.  A type is assignable from a union if it is assignable from _all_
    // memebers.
    if (srcType instanceof UnionType) {
      // By construction union types are guaranteed
      // 1. not to be empty
      // 2. not to contain union types
      UnionType asUnion = (UnionType) srcType;
      for (SoyType member : asUnion.getMembers()) {
        if (!doIsAssignableFromNonUnionType(member)) {
          return false;
        }
      }
      return true;
    } else {
      return doIsAssignableFromNonUnionType(srcType);
    }
  }
297152
def is_one_of(obj, types):
    """"""
    for type_ in types:
        if isinstance(obj, type_):
            return True
    return False
1248591
Type binaryPromotion(Type t1, Type t2) {
        Type unboxedT1 = types.unboxedTypeOrType(t1);
        Type unboxedT2 = types.unboxedTypeOrType(t2);

        if (unboxedT1.isNumeric() && unboxedT2.isNumeric()) {
            if (unboxedT1.hasTag(TypeTag.DOUBLE) || unboxedT2.hasTag(TypeTag.DOUBLE)) {
                return syms.doubleType;
            } else if (unboxedT1.hasTag(TypeTag.FLOAT) || unboxedT2.hasTag(TypeTag.FLOAT)) {
                return syms.floatType;
            } else if (unboxedT1.hasTag(TypeTag.LONG) || unboxedT2.hasTag(TypeTag.LONG)) {
                return syms.longType;
            } else {
                return syms.intType;
            }
        } else if (types.isSameType(unboxedT1, unboxedT2)) {
            return unboxedT1;
        } else {
            return syms.objectType;
        }
    }
233705
@GwtIncompatible("incompatible method")
    private static boolean arrayMemberEquals(final Class<?> componentType, final Object o1, final Object o2) {
        if (componentType.isAnnotation()) {
            return annotationArrayMemberEquals((Annotation[]) o1, (Annotation[]) o2);
        }
        if (componentType.equals(Byte.TYPE)) {
            return Arrays.equals((byte[]) o1, (byte[]) o2);
        }
        if (componentType.equals(Short.TYPE)) {
            return Arrays.equals((short[]) o1, (short[]) o2);
        }
        if (componentType.equals(Integer.TYPE)) {
            return Arrays.equals((int[]) o1, (int[]) o2);
        }
        if (componentType.equals(Character.TYPE)) {
            return Arrays.equals((char[]) o1, (char[]) o2);
        }
        if (componentType.equals(Long.TYPE)) {
            return Arrays.equals((long[]) o1, (long[]) o2);
        }
        if (componentType.equals(Float.TYPE)) {
            return Arrays.equals((float[]) o1, (float[]) o2);
        }
        if (componentType.equals(Double.TYPE)) {
            return Arrays.equals((double[]) o1, (double[]) o2);
        }
        if (componentType.equals(Boolean.TYPE)) {
            return Arrays.equals((boolean[]) o1, (boolean[]) o2);
        }
        return Arrays.equals((Object[]) o1, (Object[]) o2);
    }
14867
public static boolean isAllAssignableFrom(Class<?>[] types1, Class<?>[] types2) {
		if (ArrayUtil.isEmpty(types1) && ArrayUtil.isEmpty(types2)) {
			return true;
		}
		if (null == types1 || null == types2) {
			// 任何一个为null不相等（之前已判断两个都为null的情况）
			return false;
		}
		if (types1.length != types2.length) {
			return false;
		}

		Class<?> type1;
		Class<?> type2;
		for (int i = 0; i < types1.length; i++) {
			type1 = types1[i];
			type2 = types2[i];
			if (isBasicType(type1) && isBasicType(type2)) {
				// 原始类型和包装类型存在不一致情况
				if (BasicType.unWrap(type1) != BasicType.unWrap(type2)) {
					return false;
				}
			} else if (false == type1.isAssignableFrom(type2)) {
				return false;
			}
		}
		return true;
	}
396539
public static boolean isAssignableFrom(TypeReference<?> from, TypeReference<?> to) {
		if (from == null) {
			return false;
		}

		if (to.equals(from)) {
			return true;
		}

		if (to.getType() instanceof Class) {
			return to.getRawType().isAssignableFrom(from.getRawType());
		} else if (to.getType() instanceof ParameterizedType) {
			return isAssignableFrom(from.getType(), (ParameterizedType) to
					.getType(), new HashMap<String, Type>());
		} else if (to.getType() instanceof GenericArrayType) {
			return to.getRawType().isAssignableFrom(from.getRawType())
					&& isAssignableFrom(from.getType(), (GenericArrayType) to
							.getType());
		} else {
			throw new AssertionError("Unexpected Type : " + to);
		}
	}
615408
public static boolean canConvert(Class from, Class to) {
	// Identity Conversions
	if (from == to) return true;

	// Widening Primitive Conversion
	if (from == byte.class) {
	    return to == short.class || to == int.class || to == long.class || to == float.class || to == double.class;
	}
	if (from == short.class) {
	    return to == int.class || to == long.class || to == float.class || to == double.class;
	}
	if (from == char.class) {
	    return to == int.class || to == long.class || to == float.class || to == double.class;
	}
	if (from == int.class) {
	    return to == long.class || to == float.class || to == double.class;
	}
	if (from == long.class) {
	    return to == float.class || to == double.class;
	}
	if (from == float.class) {
	    return to == double.class;
	}
	return false;
    }
273685
public boolean isUnifiableWith(SyntacticCategory other) {
    Map<Integer, String> myAssignedVariables = Maps.newHashMap();
    Map<Integer, String> otherAssignedVariables = Maps.newHashMap();
    Map<Integer, Integer> variableRelabeling = Maps.newHashMap();

    // System.err.println("unifying: " + this + " " + other);
    return isUnifiableWith(other, myAssignedVariables, otherAssignedVariables, variableRelabeling); 
  }
297978
private static boolean isAssignableFrom(GenericArrayType type1, Class<?> type2) {
        return type2.isArray() && isAssignableFrom(Reflections.getRawType(type1.getGenericComponentType()), type2.getComponentType());
    }