Validate that at most one of {@code CheckReturnValue} and {@code CanIgnoreReturnValue} are
applied to a class (or interface or enum).
519031
@Override
  public Description matchClass(ClassTree tree, VisitorState state) {
    if (hasDirectAnnotationWithSimpleName(ASTHelpers.getSymbol(tree), CHECK_RETURN_VALUE)
        && hasDirectAnnotationWithSimpleName(ASTHelpers.getSymbol(tree), CAN_IGNORE_RETURN_VALUE)) {
      return buildDescription(tree).setMessage(String.format(BOTH_ERROR, "class")).build();
    }
    return Description.NO_MATCH;
  }
387160
def _validate(cls, kind):
        """"""
        if kind not in cls._valid_kinds:
            mesg = "'kind' must be one of {}, {}, {}, or {}."
            raise ValueError(mesg.format(*cls._valid_kinds))
        else:
            return kind
537086
final void checkReturnType(TypeElement autoValueClass, ExecutableElement getter) {
    TypeMirror type = getter.getReturnType();
    if (type.getKind() == TypeKind.ARRAY) {
      TypeMirror componentType = ((ArrayType) type).getComponentType();
      if (componentType.getKind().isPrimitive()) {
        warnAboutPrimitiveArrays(autoValueClass, getter);
      } else {
        errorReporter.reportError(
            "An @"
                + simpleAnnotationName
                + " class cannot define an array-valued property unless it is a primitive array",
            getter);
      }
    }
  }
757443
private boolean validateMinValue(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        Long minValue = ((Min) annotate).value();
        if (checkvalidDigitTypes(validationObject.getClass()))
        {
            if ((NumberUtils.toLong(toString(validationObject))) < minValue)
            {

                throwValidationException(((Min) annotate).message());
            }
        }

        return true;
    }
715278
public static <T> ConstraintViolation<T> forReturnValueValidation(final String messageTemplate,
      final Map<String, Object> messageParameters, final Map<String, Object> expressionVariables,
      final String interpolatedMessage, final Class<T> rootBeanClass, final T rootBean,
      final Object leafBeanInstance, final Object value, final Path propertyPath,
      final ConstraintDescriptor<?> constraintDescriptor, final ElementType elementType,
      final Object executableReturnValue, final Object dynamicPayload) {
    return new ConstraintViolationImpl<>(messageTemplate, messageParameters, expressionVariables,
        interpolatedMessage, rootBeanClass, rootBean, leafBeanInstance, value, propertyPath,
        constraintDescriptor, elementType, null, executableReturnValue, dynamicPayload);
  }
887193
def validate(self, instance, value):
        """"""
        if self.cast:
            value = bool(value)
        if not isinstance(value, BOOLEAN_TYPES):
            self.error(instance, value)
        return value
249485
private void checkReturnValue(Decl.FunctionOrMethod d, Environment last) {
		if (d.match(Modifier.Native.class) == null && last != FlowTypeUtils.BOTTOM && d.getReturns().size() != 0) {
			// In this case, code reaches the end of the function or method and,
			// furthermore, that this requires a return value. To get here means
			// that there was no explicit return statement given on at least one
			// execution path.
			syntaxError(d, MISSING_RETURN_STATEMENT);
		}
	}
1097371
protected void validateModelClass(Object model) {
        final Set<ConstraintViolation<Object>> violations = validator.validate(model);

        // in case of an invalid model, we throw a ConstraintViolationException, containing the violations:
        if (!violations.isEmpty()) {
            throw new ConstraintViolationException(
                    new HashSet<>(violations));
        }
    }
602418
function shouldIgnoreValue(propertyInfo, value) {
  return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
}
341213
public static Validator validEnum(Class<? extends Enum> enumClass, Enum... excludes) {
    String[] ex = new String[excludes.length];
    for (int i = 0; i < ex.length; i++) {
      ex[i] = excludes[i].toString();
    }
    return ValidEnum.of(enumClass, ex);
  }
377041
function validateReturn (validateReturn) {
    // set default if value passed
    if (defined(validateReturn)) {
        immutable.defaultValidateReturn = validateReturn ? true : false
        // return immutable
        return ImmutableCore
    }
    // return default value
    return immutable.defaultValidateReturn
}
1117147
public static void validateReturnType(Method method, Class<? extends Annotation> annotationType,
                                          Class<?> expectedReturnType) {
        if (!method.getReturnType().equals(expectedReturnType)) {
            throw new BeanCreationException("Method " + method.getName() + " annotated with @"
                  + annotationType.getName() + " must have a return type of "
                  + expectedReturnType.getName());
        }
    }
888481
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EXS_EXCEPTION_SOFTENING_RETURN_FALSE", justification = "No other simple way to determine whether class exists")
    private boolean checkConfusedName(String methodOrVariableName, String signature) {
        try {
            String name = methodOrVariableName.toLowerCase(Locale.ENGLISH);
            if ((name.endsWith("map") || (name.endsWith("set") && !name.endsWith("toset")) || name.endsWith("list") || name.endsWith("queue"))
                    && signature.startsWith("Ljava/util/")) {
                String clsName = SignatureUtils.stripSignature(signature);
                JavaClass cls = Repository.lookupClass(clsName);
                if ((cls.implementationOf(mapInterface) && !name.endsWith("map")) || (cls.implementationOf(setInterface) && !name.endsWith("set"))
                        || ((cls.implementationOf(listInterface) || cls.implementationOf(queueInterface)) && !name.endsWith("list")
                                && !name.endsWith("queue"))) {
                    return true;
                }
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }

        return false;
    }
515267
private void checkInnerClass(ClassDeclaration jclass)
            throws FatalCompileTimeException
    {
        boolean noFormBeanAnnotation = true;
        if (CompilerUtils.getAnnotation(jclass, FORM_BEAN_TAG_NAME, true) != null) {
            noFormBeanAnnotation = false;
        }
        else {
            //
            // check the methods for validatable property annotations that
            // would be processed elsewhere.
            //
            MethodDeclaration[] methods = CompilerUtils.getClassMethods(jclass, null);
            for (int i = 0; i < methods.length && noFormBeanAnnotation; i++) {
                MethodDeclaration method = methods[i];
                if (CompilerUtils.getAnnotation(method, VALIDATABLE_PROPERTY_TAG_NAME) != null) {
                    noFormBeanAnnotation = false;
                }
            }
        }

        if (noFormBeanAnnotation) {
            _formBeanChecker.check(jclass);
        }
    }
572903
@Override
    public void validate() throws InvalidPropertyException {

        final String methodName = "validate";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        final List<String> failedPropsMessages = new ArrayList<String>();

        try {
            final List<PropertyDescriptor> invalidProperties = new ArrayList<PropertyDescriptor>();

            // Busname is required
            if ((null == _busName) || ("".equals(_busName))) {
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE, "Invalid BusName - BusName was "
                                             + _busName);
                }
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_BUSNAME_CWSJR1187"),
                                                                null, null));
                invalidProperties.add(new PropertyDescriptor("busName",
                                JmsJcaActivationSpec.class));
            }

            // Destination required
            if (null == _destination) {
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE,
                                "Invalid Destination - Destination was null");
                }
                failedPropsMessages.add(NLS.getFormattedMessage("INVALID_PROPERTY_DESTINATION_CWSJR1188", null, null));
                invalidProperties.add(new PropertyDescriptor("destination",
                                JmsJcaActivationSpec.class));
            }

            // Check destination type valid
            if (!(QUEUE.equals(_destinationType) || TOPIC
                            .equals(_destinationType))) {
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE,
                                "Invalid Destination Type - We expected a destination type of "
                                                + QUEUE + " or " + TOPIC + " but we got "
                                                + _destinationType);
                }
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_DESTINATION_TYPE_CWSJR1189"),
                                                                new Object[] { QUEUE, TOPIC, _destinationType }, null));
                invalidProperties.add(new PropertyDescriptor("destinationType",
                                JmsJcaActivationSpec.class));
            }

            // Check acknowledge mode valid
            if (!(AUTO_ACKNOWLEDGE.equals(_acknowledgeMode) || DUPS_OK_ACKNOWLEDGE
                            .equals(_acknowledgeMode))) {
                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE,
                                "Invalid Acknowledge Mode - We expected an acknowledge mode of "
                                                + AUTO_ACKNOWLEDGE + " or "
                                                + DUPS_OK_ACKNOWLEDGE + " but we got "
                                                + _acknowledgeMode);
                }
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_ACKNOWLEDGE_MODE_CWSJR1190"),
                                                                new Object[] { AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, _acknowledgeMode },
                                                                null));
                invalidProperties.add(new PropertyDescriptor("acknowledgeMode",
                                JmsJcaActivationSpec.class));
            }

            // Check read ahead valid
            if (!(ApiJmsConstants.READ_AHEAD_DEFAULT.equals(_readAhead)
                  || ApiJmsConstants.READ_AHEAD_ON.equals(_readAhead) || ApiJmsConstants.READ_AHEAD_OFF
                            .equals(_readAhead))) {

                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE,
                                "Invalid ReadAhead - We expected a read ahead of "
                                                + ApiJmsConstants.READ_AHEAD_DEFAULT + ", "
                                                + ApiJmsConstants.READ_AHEAD_ON + " or "
                                                + ApiJmsConstants.READ_AHEAD_OFF
                                                + " but we got " + _readAhead);
                }
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_READ_AHEAD_CWSJR1191"),
                                                                new Object[] { ApiJmsConstants.READ_AHEAD_DEFAULT,
                                                                              ApiJmsConstants.READ_AHEAD_ON,
                                                                              ApiJmsConstants.READ_AHEAD_OFF,
                                                                              _acknowledgeMode },
                                                                null));
                invalidProperties.add(new PropertyDescriptor("readAhead",
                                JmsJcaActivationSpec.class));
            }

            // For queues ...
            if (QUEUE.equals(_destinationType)) {
                if (!(_destination instanceof JmsQueue)) {
                    if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                        SibTr.debug(this, TRACE,
                                    "Invalid Destination - We expect a destination object to be a "
                                                    + JmsQueue.class.getName()
                                                    + " but we got "
                                                    + _destination == null ? "null" : _destination.getClass().getName());
                    }
                    failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_QUEUE_CWSJR1192"),
                                                                    new Object[] { JmsQueue.class.getName(), _destination == null ? "null" : _destination.getClass().getName() },
                                                                    null));
                    invalidProperties.add(new PropertyDescriptor("destination",
                                    JmsJcaActivationSpec.class));
                }
            }

            // For topics ...
            if (TOPIC.equals(_destinationType)) {

                if (!(_destination instanceof JmsTopic)) {
                    if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                        SibTr.debug(this, TRACE,
                                    "Invalid Destination - We expect a destination object to be a "
                                                    + JmsTopic.class.getName()
                                                    + " but we got "
                                                    + _destination == null ? "null" : _destination.getClass().getName());
                    }
                    failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_TOPIC_CWSJR1193"),
                                                                    new Object[] { JmsTopic.class.getName(), _destination == null ? "null" : _destination.getClass().getName() },
                                                                    null));
                    invalidProperties.add(new PropertyDescriptor("destination",
                                    JmsJcaActivationSpec.class));
                }

                // ... check subscription durability valid
                if (!(DURABLE.equals(_subscriptionDurability) || DURABLE_SHARED.equals(_subscriptionDurability) ||
                      NON_DURABLE.equals(_subscriptionDurability) || NON_DURABLE_SHARED.equals(_subscriptionDurability))) {
                    if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                        SibTr.debug(this, TRACE,
                                    "Invalid subscriptionDurability - We expect a value of "
                                                    + DURABLE + " or " + DURABLE_SHARED + " or " + NON_DURABLE + " or " + NON_DURABLE_SHARED
                                                    + " but we got "
                                                    + _subscriptionDurability);
                    }
                    failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_SUBDUR_CWSJR1194"),
                                                                    new Object[] { DURABLE, DURABLE_SHARED, NON_DURABLE, NON_DURABLE_SHARED, _subscriptionDurability },
                                                                    null));
                    invalidProperties.add(new PropertyDescriptor(
                                    "subscriptionDurability",
                                    JmsJcaActivationSpec.class));
                }

                if (DURABLE.equals(_subscriptionDurability)) {
                    // ... check client ID set
                    if ((null == _clientId) || ("".equals(_clientId))) {
                        failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_CLIENTID_CWSJR1183"),
                                                                        null, null));
                        invalidProperties.add(new PropertyDescriptor(
                                        "clientId", JmsJcaActivationSpec.class));
                    }

                }
                // For durable(and shared non durable) topic subscriptions ...
                if (DURABLE.equals(_subscriptionDurability) ||
                    DURABLE_SHARED.equals(_subscriptionDurability) ||
                    NON_DURABLE_SHARED.equals(_subscriptionDurability)) {
                    // ... check client ID set
                    if ((null == _clientId) || ("".equals(_clientId))) {
                        failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_CLIENTID_CWSJR1183"),
                                                                        null, null));
                        invalidProperties.add(new PropertyDescriptor(
                                        "clientId", JmsJcaActivationSpec.class));
                    }

                    // durableSubscriptionHome is populated at the connectionImpl 
                    // or the ConnectionProxy for liberty.Hence the check is removed

                    // ... check subscription name set
                    if ((null == _subscriptionName)
                        || ("".equals(_subscriptionName))) {

                        failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_SUBNAME_CWSJR1196"),
                                                                        null, null));
                        invalidProperties
                                        .add(new PropertyDescriptor("subscriptionName",
                                                        JmsJcaActivationSpec.class));

                    }

                }
            }

            // Check maximum concurrency greater than zero
            if ((null == _maxConcurrency) || (_maxConcurrency.intValue() < 1)) {
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_MAXCONC_CWSJR1198"),
                                                                null, null));
                invalidProperties.add(new PropertyDescriptor("maxConcurrency",
                                JmsJcaActivationSpec.class));
            }

            // Check maximum batch size greater than zero
            if ((null == _maxBatchSize) || (_maxBatchSize.intValue() < 1)) {
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_MAXBATCH_CWSJR1199"),
                                                                null, null));
                invalidProperties.add(new PropertyDescriptor("maxBatchSize",
                                JmsJcaActivationSpec.class));
            }

            // Check share data source with CMP is set - since this defaults to a value at
            // initialisation time this should never be encountered
            if (null == _shareDataSourceWithCMP) {
                failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_SHARECMP_CWSJR1200"),
                                                                null, null));
                invalidProperties.add(new PropertyDescriptor(
                                "shareDataSourceWithCMP", JmsJcaActivationSpec.class));
            }

            /**
             * For the target set of properties, use the defaults if none specified
             */
            if ("".equals(_target)) {

                _target = JmsraConstants.DEFAULT_TARGET;

            }

            // Target type must be one of the predefined values
            if ((null == _targetType) || ("".equals(_targetType))) {

                _targetType = JmsraConstants.DEFAULT_TARGET_TYPE;

            } else {

                if (!((ApiJmsConstants.TARGET_TYPE_BUSMEMBER.equals(_targetType)) ||
                      (ApiJmsConstants.TARGET_TYPE_ME.equals(_targetType)) || (ApiJmsConstants.TARGET_TYPE_CUSTOM.equals(_targetType)))) {

                    failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_TARGET_TYPE_CWSJR1180"),
                                                                    new Object[] { ApiJmsConstants.TARGET_TYPE_BUSMEMBER,
                                                                                  ApiJmsConstants.TARGET_TYPE_ME,
                                                                                  ApiJmsConstants.TARGET_TYPE_CUSTOM,
                                                                                  _targetType },
                                                                    null));
                    invalidProperties.add(new PropertyDescriptor(
                                    "targetType",
                                    JmsJcaActivationSpec.class));

                }

            }

            // Target significance must be one of the predefined values
            if ((null == _targetSignificance) || ("".equals(_targetSignificance))) {

                _targetSignificance = JmsraConstants.DEFAULT_TARGET_SIGNIFICANCE;

            } else {

                if (!((ApiJmsConstants.TARGET_SIGNIFICANCE_PREFERRED.equals(_targetSignificance)) || (ApiJmsConstants.TARGET_SIGNIFICANCE_REQUIRED.equals(_targetSignificance)))) {

                    failedPropsMessages.add(NLS.getFormattedMessage(("INVALID_PROPERTY_TARGET_SIGNIFICANCE_CWSJR1179"),
                                                                    new Object[] { ApiJmsConstants.TARGET_SIGNIFICANCE_PREFERRED,
                                                                                  ApiJmsConstants.TARGET_SIGNIFICANCE_REQUIRED,
                                                                                  _targetSignificance },
                                                                    null));
                    invalidProperties.add(new PropertyDescriptor(
                                    "targetSignificance",
                                    JmsJcaActivationSpec.class));

                }

            }

            // If we have any invalid properties, throw an
            // InvalidPropertyException
            if (!invalidProperties.isEmpty()) {

                final PropertyDescriptor[] invalidPropertyArray = invalidProperties
                                .toArray(new PropertyDescriptor[invalidProperties
                                                .size()]);
                // Commented out in 284561 since we are now using failedPropsMessages instead
/*
 * final List propertyNames = new ArrayList();
 * 
 * for (int i = 0; i < invalidPropertyArray.length; i++) {
 * propertyNames.add(invalidPropertyArray[i].getDisplayName());
 * }
 */

                if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                    SibTr.debug(this, TRACE, "Invalid properties found:",
                                failedPropsMessages);
                }

                final InvalidPropertyException exc = new InvalidPropertyException(
                                NLS.getFormattedMessage(
                                                        ("INVALID_PROPERTIES_CWSJR1181"),
                                                        new Object[] { failedPropsMessages }, null));
                exc.setInvalidPropertyDescriptors(invalidPropertyArray);
                throw exc;
            }

        } catch (final IntrospectionException exception) {

            FFDCFilter.processException(exception, CLASS_NAME + "."
                                                   + methodName, FFDC_PROBE_1, this);

            SibTr.exception(this, TRACE, exception);

            throw new RuntimeException(NLS.getFormattedMessage(
                                                               ("EXCEPTION_RECEIVED_CWSJR1185"),
                                                               new Object[] { exception }, null), exception);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
216144
public void validate(Object o)
    {
        Matcher m = m_pattern.matcher(String.valueOf(o));
        if (!m.matches())
        {
            String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(), String.valueOf(o) });
            throw new ValidationException(message);
        }
    }
252054
private void validateMethod(Method method, CallbackType callbackType) {
    int modifiers = method.getModifiers();
    if (!Modifier.isPublic(modifiers)) {
      String message = String.format("Method %s in class %s must be public", method.getName(),
          method.getDeclaringClass().getName());
      throw new EntityManagerException(message);
    }
    if (Modifier.isStatic(modifiers)) {
      String message = String.format("Method %s in class %s must not be static", method.getName(),
          method.getDeclaringClass().getName());
      throw new EntityManagerException(message);
    }
    if (Modifier.isAbstract(modifiers)) {
      String message = String.format("Method %s in class %s must not be abstract", method.getName(),
          method.getDeclaringClass().getName());
      throw new EntityManagerException(message);
    }
    Class<?>[] parameters = method.getParameterTypes();
    if (parameters.length != 0) {
      String pattern = "Method %s in class %s is not a valid %s callback method. Method must not "
          + "have any parameters. ";
      String message = String.format(pattern, method.getName(),
          method.getDeclaringClass().getName(), callbackType);
      throw new EntityManagerException(message);
    }
    if (method.getReturnType() != void.class) {
      String message = String.format("Method %s in class %s must have a return type of %s",
          method.getName(), method.getDeclaringClass().getName(), void.class.getName());
      throw new EntityManagerException(message);
    }
  }