Validates if input class is of type input.

@param clazz
class

@return true, if it is a date field class.
776857
private boolean isDate(Class clazz)
    {
        return clazz.isAssignableFrom(Date.class) || clazz.isAssignableFrom(java.sql.Date.class)
                || clazz.isAssignableFrom(Timestamp.class) || clazz.isAssignableFrom(Time.class)
                || clazz.isAssignableFrom(Calendar.class);
    }
1331477
private static boolean isDesignerClass(Class<?> type) {
        return Stream.of(type.getDeclaredFields()).anyMatch(field -> TestDesigner.class.isAssignableFrom(field.getType()));
    }
558959
private boolean isPolymorphicType(Class<?> clazz) {
    return polymorphicTypes.stream().anyMatch(polymorphicType -> polymorphicType.getConfigClass() == clazz);
  }
120144
private ValidationResult isValidClassForType(Class<?> clazz, SoyType type) {
    // Exit early if the class is primitive and the type is nullable -- that's not allowed.
    // Then remove null from the type.  This allows us to accept precise params for nullable
    // types, e.g, for int|null we can allow IntegerData (which will be passed as 'null').
    if (SoyTypes.isNullable(type) && Primitives.allPrimitiveTypes().contains(clazz)) {
      return ValidationResult.forNullToPrimitive(type);
    }
    // Also exit early if the type is a VE, since those aren't allowed as params.
    if (SoyTypes.isKindOrUnionOfKind(type, SoyType.Kind.VE)
        || SoyTypes.isKindOrUnionOfKind(type, SoyType.Kind.VE_DATA)) {
      return ValidationResult.ve(type);
    }

    ImmutableSet<Class<?>> expectedClasses = null;
    GenericDescriptor expectedDescriptor = null;
    type = SoyTypes.tryRemoveNull(type);
    switch (type.getKind()) {
      case ANY:
      case UNKNOWN:
        expectedClasses = UNKNOWN_TYPES;
        break;
      case ATTRIBUTES:
      case CSS:
      case HTML:
      case URI:
      case TRUSTED_RESOURCE_URI:
      case JS:
        expectedClasses = SANITIZED_TYPES;
        break;
      case BOOL:
        expectedClasses = BOOL_TYPES;
        break;
      case FLOAT:
        expectedClasses = FLOAT_TYPES;
        break;
      case INT:
        expectedClasses = INT_TYPES;
        break;
      case LEGACY_OBJECT_MAP:
        expectedClasses = LEGACY_OBJECT_MAP_TYPES;
        break;
      case LIST:
        expectedClasses = LIST_TYPES;
        break;
      case MAP:
        expectedClasses = MAP_TYPES;
        break;
      case RECORD:
        expectedClasses = RECORD_TYPES;
        break;
      case STRING:
        expectedClasses = STRING_TYPES;
        break;
      case NULL:
        expectedClasses = NULL_TYPES;
        break;
      case PROTO:
        expectedClasses = PROTO_TYPES;
        expectedDescriptor = ((SoyProtoType) type).getDescriptor();
        break;
      case PROTO_ENUM:
        expectedClasses = PROTO_ENUM_TYPES;
        expectedDescriptor = ((SoyProtoEnumType) type).getDescriptor();
        break;
      case UNION:
        // number is a special case, it should work for double and NumberData
        if (type.equals(SoyTypes.NUMBER_TYPE)) {
          expectedClasses = NUMBER_TYPES;
          break;
        }
        // If this is a union, make sure the type is valid for every member.
        // If the type isn't valid for any member, then there's no guarantee this will work
        // for an arbitrary template at runtime.
        ValidationResult result = ValidationResult.valid();
        for (SoyType member : ((UnionType) type).getMembers()) {
          result.merge(isValidClassForType(clazz, member));
        }
        return result;
      case VE:
      case VE_DATA:
        throw new IllegalStateException("This should have been caught above");
      case ERROR:
        throw new IllegalStateException("Cannot have error type from function signature");
    }

    checkState(expectedClasses != null, "expectedClass not set!");
    if (expectedClasses.contains(clazz)) {
      return ValidationResult.valid();
    }
    ImmutableSet<String> expectedDescriptorNames = ImmutableSet.of();
    if (expectedDescriptor instanceof Descriptor) {
      expectedDescriptorNames =
          ImmutableSet.of(JavaQualifiedNames.getClassName((Descriptor) expectedDescriptor));
      if (matchesProtoDescriptor(Message.class, clazz, expectedDescriptor)) {
        return ValidationResult.valid();
      }
    }
    if (expectedDescriptor instanceof EnumDescriptor) {
      expectedDescriptorNames =
          ImmutableSet.of(JavaQualifiedNames.getClassName((EnumDescriptor) expectedDescriptor));
      if (clazz.isEnum()
          && matchesProtoDescriptor(ProtocolMessageEnum.class, clazz, expectedDescriptor)) {
        return ValidationResult.valid();
      }
    }
    // If none of the above conditions match, we failed.
    return ValidationResult.invalid(
        Stream.concat(
                expectedClasses.stream().map(Class::getName), expectedDescriptorNames.stream())
            .collect(toImmutableSet()));
  }
924026
public static boolean isPrimitive(Class<?> aClass)
	{
		if(aClass == null)
			return false;
		
		String className = aClass.getName();
		return className.matches("(float|char|short|double|int|long|byte|boolean|(java.lang.(Long|Integer|String|Float|Double|Short|Byte|Boolean)))");
		
	}
627955
private <X> void validate(Class<X> clazz, boolean isEmbeddable)
    {
        final String mappedSuperClazzErrMsg = "Class:" + clazz
                + "is annotated with @MappedSuperClass and @Entity not allowed";
        final String embeddableClazzErrMsg = "Class:" + clazz + "is annotated with @Embeddable and @Entity not allowed";
        if (clazz.isAnnotationPresent(Entity.class))
        {
            throw new MetamodelLoaderException(isEmbeddable ? embeddableClazzErrMsg : mappedSuperClazzErrMsg);
        }
    }
660057
public static boolean isParseable(Class<?> clazz) {

        boolean parseable = false;
        parseable = parseable || (clazz.equals(byte.class));
        parseable = parseable || (clazz.equals(Byte.class));
        parseable = parseable || (clazz.equals(short.class));
        parseable = parseable || (clazz.equals(Short.class));
        parseable = parseable || (clazz.equals(int.class));
        parseable = parseable || (clazz.equals(Integer.class));
        parseable = parseable || (clazz.equals(long.class));
        parseable = parseable || (clazz.equals(Long.class));
        parseable = parseable || (clazz.equals(float.class));
        parseable = parseable || (clazz.equals(Float.class));
        parseable = parseable || (clazz.equals(double.class));
        parseable = parseable || (clazz.equals(Double.class));
        parseable = parseable || (clazz.equals(boolean.class));
        parseable = parseable || (clazz.equals(Boolean.class));
        parseable = parseable || (clazz.equals(char.class));
        parseable = parseable || (clazz.equals(Character.class));
        parseable = parseable || (clazz.equals(String.class));
        parseable = parseable || (clazz.equals(Date.class));
        parseable = parseable || (clazz.equals(CmsUUID.class));
        return parseable;
    }
166261
public function validate($input): bool
    {
        if ($input instanceof DateTime) {
            return true;
        }

        if (!\is_string($input)) {
            return false;
        }

        if (null === $this->format) {
            return false !== strtotime($input);
        }

        $dateFromFormat = DateTime::createFromFormat($this->format, $input);

        return $dateFromFormat
            && $input === date($this->format, $dateFromFormat->getTimestamp());
    }
481447
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
        boolean result = false;
        if (field != null) {
            result = field.isAnnotationPresent(annotationClass);
        }
        if (!result && setter != null) {
            result = setter.isAnnotationPresent(annotationClass);
        }
        if (!result && getter != null) {
            result = getter.isAnnotationPresent(annotationClass);
        }
        return result;
    }
1163594
public static Object str2TargetClass(String strField, Class<?> clazz) {
        if (null == strField || "".equals(strField))
            return null;
        if ((Long.class == clazz) || (long.class == clazz)) {
            strField = matchDoneBigDecimal(strField);
            strField = RegularUtils.converNumByReg(strField);
            return Long.parseLong(strField);
        }
        if ((Integer.class == clazz) || (int.class == clazz)) {
            strField = matchDoneBigDecimal(strField);
            strField = RegularUtils.converNumByReg(strField);
            return Integer.parseInt(strField);
        }
        if ((Float.class == clazz) || (float.class == clazz)) {
            strField = matchDoneBigDecimal(strField);
            return Float.parseFloat(strField);
        }
        if ((Double.class == clazz) || (double.class == clazz)) {
            strField = matchDoneBigDecimal(strField);
            return Double.parseDouble(strField);
        }
        if ((Character.class == clazz) || (char.class == clazz)) {
            return strField.toCharArray()[0];
        }
        if ((Boolean.class == clazz) || (boolean.class == clazz)) {
            return Boolean.parseBoolean(strField);
        }
        if (Date.class == clazz) {
            return DateUtils.str2DateUnmatch2Null(strField);
        }
        return strField;
    }
997930
public static<T extends ParamValidator> T getValidator(Class<T> clazz, boolean required) {

        List<ParamValidator> validators = validatorsMap.get(clazz);
        if (validators != null) {

            if (required) {
                return (T)validators.get(0);
            }

            return (T)validators.get(1);
        }

        return null;
    }
538700
private void check(Class clazz) {

        final Constructor<?>[] constructors = clazz.getDeclaredConstructors();

        if (constructors.length > 1) {
            throw new AssertionError(clazz + " has more than one constructor");
        }

        final Constructor<?> constructor = constructors[0];

        constructor.setAccessible(true);

        if (!Modifier.isPrivate(constructor.getModifiers())) {
            throw new AssertionError("Constructor of " + clazz + " must be private");
        }

        final Class<?>[] parameterTypes = constructor.getParameterTypes();

        if (parameterTypes.length > 0) {
            if (expectedParameters == null) {
                throw new AssertionError(clazz + " has non-default constructor with some parameters");
            } else {
                if (!Arrays.equals(parameterTypes, expectedParameters)) {
                    throw new AssertionError("Expected constructor with parameters " + getReadableClassesOutput(expectedParameters) + " but found constructor with parameters " + getReadableClassesOutput(parameterTypes));
                } else {
                    return;
                }
            }
        }

        try {
            constructor.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException("Can not instantiate instance of " + clazz, e);
        } catch (IllegalAccessException e) {
            // Fixed by setAccessible(true)
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            final Throwable cause = e.getCause();

            // It's okay case if we expect some exception from this constructor
            if (expectedTypeOfException != null || expectedExceptionMessage != null) {
                if (expectedTypeOfException != null && !expectedTypeOfException.equals(cause.getClass())) {
                    throw new IllegalStateException("For " + clazz + " expected exception of type = " + expectedTypeOfException + ", but was exception of type = " + e.getCause().getClass());
                }

                if (expectedExceptionMessage != null && !expectedExceptionMessage.equals(cause.getMessage())) {
                    throw new IllegalStateException("For " + clazz + " expected exception message = '" + expectedExceptionMessage + "', but was = '" + cause.getMessage() + "'", e.getCause());
                }

                // Everything is okay
            } else {
                throw new IllegalStateException("For " + clazz + " no exception was expected", e);
            }
        } catch (IllegalArgumentException e) {
            throw new RuntimeException("Looks like constructor of " + clazz + " is not default", e);
        }
    }
963610
private boolean validateFuture(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        int res = 0;

        if (validationObject.getClass().isAssignableFrom(java.util.Date.class))
        {
            Date today = new Date();
            Date futureDate = (Date) validationObject;

            res = futureDate.compareTo(today);
        }
        else if (validationObject.getClass().isAssignableFrom(java.util.Calendar.class))
        {

            Calendar cal = Calendar.getInstance();
            Calendar futureDate = (Calendar) validationObject;
            res = futureDate.compareTo(cal);

        }
        // else
        // {
        // //ruleExceptionHandler(((Future) annotate).message());
        // throw new RuleValidationException(((Future)
        // annotate).message());
        // }
        if (res <= 0)
        {
            throwValidationException(((Future) annotate).message());
        }

        return true;
    }
150787
public static boolean isObjectType(Class<?> cls) {
        FieldType fieldType = TYPE_MAPPING.get(cls);
        if (fieldType != null) {
            return false;
        }

        return true;
    }
38328
public static boolean isSimpleValueType(Class<?> clazz) {
		return isBasicType(clazz) //
				|| clazz.isEnum() //
				|| CharSequence.class.isAssignableFrom(clazz) //
				|| Number.class.isAssignableFrom(clazz) //
				|| Date.class.isAssignableFrom(clazz) //
				|| clazz.equals(URI.class) //
				|| clazz.equals(URL.class) //
				|| clazz.equals(Locale.class) //
				|| clazz.equals(Class.class);//
	}
1243259
public boolean isMatch(ZonedDateTime date) {
        // Issue #200: Truncating the date to the least granular precision supported by different cron systems.
        // For Quartz, it's seconds while for Unix & Cron4J it's minutes.
        final boolean isSecondGranularity = cronDefinition.containsFieldDefinition(SECOND);
        if (isSecondGranularity) {
            date = date.truncatedTo(SECONDS);
        } else {
            date = date.truncatedTo(ChronoUnit.MINUTES);
        }

        final Optional<ZonedDateTime> last = lastExecution(date);
        if (last.isPresent()) {
            final Optional<ZonedDateTime> next = nextExecution(last.get());
            if (next.isPresent()) {
                return next.get().equals(date);
            } else {
                boolean everythingInRange = false;
                try {
                    everythingInRange = dateValuesInExpectedRanges(nextClosestMatch(date), date);
                } catch (final NoSuchValueException ignored) {
                    // Why is this ignored?
                }
                try {
                    everythingInRange = dateValuesInExpectedRanges(previousClosestMatch(date), date);
                } catch (final NoSuchValueException ignored) {
                    // Why is this ignored?
                }
                return everythingInRange;
            }
        }
        return false;
    }
133175
private boolean validatePast(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        int res = 0;

        if (validationObject.getClass().isAssignableFrom(java.util.Date.class))
        {
            Date today = new Date();
            Date pastDate = (Date) validationObject;

            res = pastDate.compareTo(today);
        }
        else if (validationObject.getClass().isAssignableFrom(java.util.Calendar.class))
        {

            Calendar cal = Calendar.getInstance();
            Calendar pastDate = (Calendar) validationObject;
            res = pastDate.compareTo(cal);

        }
        // else
        // {
        // ruleExceptionHandler(((Past) annotate).message());
        // }
        if (res >= 0)
        {
            throwValidationException(((Past) annotate).message());
        }

        return true;
    }