Use {@link Preconditions} to check for required {@link WorkflowDef} fields, throwing a Runtime exception if
validations fail.

@param def The {@code WorkflowDef} to check.
193170
private void validate(WorkflowDef def) {
        Preconditions.checkNotNull(def, "WorkflowDef object cannot be null");
        Preconditions.checkNotNull(def.getName(), "WorkflowDef name cannot be null");
    }
491233
public static int checkPreconditionI(
    final int value,
    final ContractIntConditionType condition)
    throws PreconditionViolationException
  {
    return checkPreconditionI(
      value, condition.predicate(), condition.describer());
  }
678774
private void validateClusterNameOfWorkflowInstance( long woinRefNum ){
        WorkflowInstance woin = workflowInstanceService.find( woinRefNum );
        String clusterName = config.getClusterName();
        if( !ObjectUtils.equals( clusterName, woin.getClusterName() ) ){
            throw new IllegalArgumentException( "The workflow instance " + woinRefNum + " is not executed by this cluster " + clusterName );
        }
    }
832461
private void checkId(FieldDescriptorDef fieldDef, String checkLevel) throws ConstraintException
    {
        if (CHECKLEVEL_NONE.equals(checkLevel))
        {
            return;
        }

        String id = fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_ID);

        if ((id != null) && (id.length() > 0))
        {
            try
            {
                Integer.parseInt(id);
            }
            catch (NumberFormatException ex)
            {
                throw new ConstraintException("The id attribute of field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" is not a valid number");
            }
        }
    }
71703
public void retryLastFailedTask(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        stub.retryWorkflow(WorkflowServicePb.RetryWorkflowRequest.newBuilder()
                .setWorkflowId(workflowId)
                .build()
        );
    }
697427
@SuppressWarnings("unchecked")
	private static ValidationFail performFieldValidations(Context context, FieldInfo fieldInfo, View view) {
		// first, we need to check if condition is not applied for all validations on field
		if (fieldInfo.condition != null && fieldInfo.condition.validationAnnotation().equals(Condition.class)) {
			// condition is applied to all validations on field
			boolean evaluation = evaluateCondition(view, fieldInfo.condition);
			if (! evaluation) {
				// go to next field
				return null;
			}
		}

		// field validations
		for (ValidationInfo valInfo : fieldInfo.validationInfoList) {
			final Annotation annotation = valInfo.annotation;
			if (fieldInfo.condition != null && fieldInfo.condition.validationAnnotation().equals(annotation.annotationType())) {
				boolean evaluation = evaluateCondition(view, fieldInfo.condition);

				if (! evaluation) {
					// continue to next annotation
					continue;
				}
			}
			final IFieldAdapter adapter = FieldAdapterFactory.getAdapterForField(view, annotation);
			if (adapter == null) {
				throw new NoFieldAdapterException(view, annotation);
			}

			final Object value = adapter.getFieldValue(annotation, view);
			final boolean isValid = valInfo.validator.validate(annotation, value);

			if (! isValid) {
				final String message = valInfo.validator.getMessage(context, annotation, value);
				final int order = valInfo.validator.getOrder(annotation);

				// no more validations on this field
				return new ValidationFail(view, message, order);
			}
		}
		return null;
	}
401598
private boolean validateProcessInstance(ProcessInstance processInst) {
        Integer status = processInst.getStatusCode();
        if (WorkStatus.STATUS_CANCELLED.equals(status)) {
            logger.info("ProcessInstance has been cancelled. ProcessInstanceId = " + processInst.getId());
            return false;
        } else if (WorkStatus.STATUS_COMPLETED.equals(status)) {
            logger.info("ProcessInstance has been completed. ProcessInstanceId = " + processInst.getId());
            return false;
        } else return true;
    }
337678
private boolean checkZoneRequirement(HashMap<Integer, Integer> requiredRepFactor, int zoneId) {
        if(requiredRepFactor.containsKey(zoneId)) {
            if(requiredRepFactor.get(zoneId) == 0) {
                return false;
            } else {
                requiredRepFactor.put(zoneId, requiredRepFactor.get(zoneId) - 1);
                return true;
            }
        }
        return false;

    }
591960
public boolean validateSF(SF sf, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(sf, diagnostics, context);
	}
262450
public List<Project> validate(boolean validateRefs) throws IOException {
        for (Project project : projects) {
            for (ValidationEntry validationEntry : project.validationEntries) {
                MetatypeRoot metatype = validationEntry.parsedMetatype;
                metatype.setMetatypeFileName(validationEntry.fileName);
                metatype.setOcdStats(ocdStats);
                metatype.setNlsKeys(validationEntry.nlsKeys);
                metatype.validate(validateRefs);
                validationEntry.validity = metatype.getValidityState();

                File outputFile = new File(outputPath + "/" + project.name + "/" + validationEntry.fileName + getExtension(validationEntry.fileName));
                outputFile.getParentFile().mkdirs();
                int pass = 0;
                int fail = 0;
                if (!validationEntry.localizationFound) {
                    validationEntry.validity = ValidityState.Failure;
                    fail++;
                } else {
                    pass++;
                }

                fail += metatype.getErrorMessages().size();
                pass += metatype.getWarningMessages().size() + metatype.getInfoMessages().size();

                for (MetatypeDesignate designate : metatype.getDesignates()) {
                    fail += designate.getErrorMessages().size();
                    pass += designate.getWarningMessages().size() + designate.getInfoMessages().size();

                    for (MetatypeObject object : designate.getObjects()) {
                        fail += object.getErrorMessages().size();
                        pass += object.getWarningMessages().size() + object.getInfoMessages().size();

                        MetatypeOcd ocd = object.getMatchingOcd();

                        if (ocd != null) {
                            fail += ocd.getErrorMessages().size();
                            pass += ocd.getWarningMessages().size() + ocd.getInfoMessages().size();

                            for (MetatypeAd ad : ocd.getAds()) {
                                fail += ad.getErrorMessages().size();
                                pass += ad.getWarningMessages().size() + ad.getInfoMessages().size();

                                for (MetatypeAdOption option : ad.getOptions()) {
                                    fail += option.getErrorMessages().size();
                                    pass += option.getWarningMessages().size() + option.getInfoMessages().size();
                                }
                            }
                        }
                    }

                }

                PrintStream junit = new PrintStream(outputFile);
                junit.printf("<testsuite errors=\"%s\" failures=\"%s\" name=\"%s\" tests=\"%s\" time=\"\">%n", "0", fail, project.name, fail + pass);

                if (!validationEntry.localizationFound) {
                    junit.printf("<testcase classname=\"%s\" name=\"%s\">%n", project.name, "localizationFileNotFound");
                    junit.printf("<failure message=\"%s\"><![CDATA[%s]]></failure>%n", "Could not find file " + metatype.getLocalization(), "");
                    junit.printf("</testcase>%n");
                }

                String fileName = validationEntry.fileName;
                processMetatype(project, metatype, fileName, junit);

                for (MetatypeDesignate designate : metatype.getDesignates()) {
                    String pid = designate.getPid();
                    if (pid == null)
                        pid = designate.getFactoryPid();
                    processMetatype(project, designate, fileName + "." + pid, junit);

                    for (MetatypeObject object : designate.getObjects()) {
                        processMetatype(project, object, fileName + "." + pid, junit);

                        MetatypeOcd ocd = object.getMatchingOcd();

                        if (ocd != null) {
                            processMetatype(project, ocd, fileName + "." + pid, junit);

                            for (MetatypeAd ad : ocd.getAds()) {
                                String id = ad.getId();
                                processMetatype(project, ad, fileName + "." + pid + "." + id, junit);

                                for (MetatypeAdOption option : ad.getOptions()) {
                                    processMetatype(project, option, fileName + "." + pid + "." + id + "." + option, junit);
                                }
                            }
                        }
                    }
                }

                junit.printf("</testsuite>%n");

                junit.close();
                String failMsg = (fail > 0) ? "**FAILURE**" : "";
                System.out.println("Metatype validation " + failMsg + " for " + validationEntry.fileName + " written to " + outputFile.getAbsolutePath());
            }
        }

        if (!errors.isEmpty()) {
            throw new IllegalStateException("xml parse errors:\n" + errors);
        }
        return projects;
    }
246887
public boolean shouldInvalidate (Object id, int sourceOfInvalidation, int causeOfInvalidation) {
    	boolean retVal = true;
        if (preInvalidationListenerCount > 0) {
        	// In external implementation, catch any exceptions and process
        	try {
        		retVal = currentPreInvalidationListener.shouldInvalidate(id, sourceOfInvalidation, causeOfInvalidation);
        	}
        	catch (Throwable t) {
        		com.ibm.ws.ffdc.FFDCFilter.processException(t, "com.ibm.ws.cache.DCEventSource.shouldInvalidate", "120", this);
        		if (tc.isDebugEnabled()) {
            		Tr.debug(tc, "Exception thrown in shouldInvalidate method of PreInvalidationListener\n" + t.toString());
            	}
        	}
        }
        
        return retVal; //invalidate
    }
753554
public void runDecider(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        stub.decideWorkflow(WorkflowServicePb.DecideWorkflowRequest.newBuilder()
                .setWorkflowId(workflowId)
                .build()
        );
    }
986653
@SuppressWarnings("checkstyle:npathcomplexity")
    @Override
    public int doFilter(EventFilter filter, Data dataKey, Object oldValue, Object dataValue, EntryEventType eventType,
                        String mapNameOrNull) {
        if (filter instanceof MapPartitionLostEventFilter) {
            return FILTER_DOES_NOT_MATCH;
        }

        // the order of the following ifs is important!
        // QueryEventFilter is instance of EntryEventFilter
        if (filter instanceof EventListenerFilter) {
            if (!filter.eval(eventType.getType())) {
                return FILTER_DOES_NOT_MATCH;
            } else {
                filter = ((EventListenerFilter) filter).getEventFilter();
            }
        }
        if (filter instanceof TrueEventFilter) {
            return eventType.getType();
        }
        if (filter instanceof QueryEventFilter) {
            return processQueryEventFilter(filter, eventType, dataKey, oldValue, dataValue, mapNameOrNull)
                    ? eventType.getType() : FILTER_DOES_NOT_MATCH;
        }
        if (filter instanceof EntryEventFilter) {
            return processEntryEventFilter(filter, dataKey) ? eventType.getType() : FILTER_DOES_NOT_MATCH;
        }
        throw new IllegalArgumentException("Unknown EventFilter type = [" + filter.getClass().getCanonicalName() + "]");
    }
342238
private boolean checkValueConstraints(int requiredType, String[] constraints, Value value)
   {
      ValueConstraintsMatcher constrMatcher =
         new ValueConstraintsMatcher(constraints, locationFactory, dataManager, nodeTypeDataManager);

      try
      {
         return constrMatcher.match(((BaseValue)value).getInternalData(), requiredType);
      }
      catch (RepositoryException e1)
      {
         return false;
      }
   }
118132
private boolean checkCondition(TestContext context) {
        if (conditionExpression != null) {
            return conditionExpression.evaluate(context);
        }

        // replace dynamic content with each iteration
        String conditionString = context.replaceDynamicContentInString(condition);
        if (ValidationMatcherUtils.isValidationMatcherExpression(conditionString)) {
            try {
                ValidationMatcherUtils.resolveValidationMatcher("iteratingCondition", "", conditionString, context);
                return true;
            } catch (AssertionError e) {
                return false;
            }
        }

        return BooleanExpressionParser.evaluate(conditionString);
    }
44685
private static void checkPreconditions(final String dateFormat, final Locale locale) {
		if( dateFormat == null ) {
			throw new NullPointerException("dateFormat should not be null");
		} else if( locale == null ) {
			throw new NullPointerException("locale should not be null");
		}
	}
1292142
public static boolean onCheckValidationConstraints(Field attribute)
    {
        // / Checks if attribute contains any validation constraint enabled
        return attribute.isAnnotationPresent(AssertFalse.class) || attribute.isAnnotationPresent(AssertTrue.class)
                || attribute.isAnnotationPresent(DecimalMax.class) || attribute.isAnnotationPresent(DecimalMin.class)
                || attribute.isAnnotationPresent(Digits.class) || attribute.isAnnotationPresent(Future.class)
                || attribute.isAnnotationPresent(Max.class) || attribute.isAnnotationPresent(Min.class)
                || attribute.isAnnotationPresent(NotNull.class) || attribute.isAnnotationPresent(Null.class)
                || attribute.isAnnotationPresent(Past.class) || attribute.isAnnotationPresent(Pattern.class)
                || attribute.isAnnotationPresent(Size.class);

    }