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

@param taskDef The {@code TaskDef} to check.
513788
private void validate(TaskDef taskDef) {
        Preconditions.checkNotNull(taskDef, "TaskDef object cannot be null");
        Preconditions.checkNotNull(taskDef.getName(), "TaskDef name cannot be null");
    }
196870
private static <T> void checkPreconditions(final Class<T> type, final TextParser<T> parser) {
        if(type == null) {
            throw new NullPointerException("type is null.");
        }
        
        if(parser == null) {
            throw new NullPointerException("parser is null.");
        }
    }
1012694
public void logTaskFailed(TaskID taskId, String taskType, long time,
                            String error,
                            TaskAttemptID failedDueToAttempt) {
    if (disableHistory) {
      return;
    }

    JobID id = taskId.getJobID();
    if (!this.jobId.equals(id)) {
      throw new RuntimeException("JobId from task: " + id +
                                 " does not match expected: " + jobId);
    }

    if (null != writers) {
      String failedAttempt = failedDueToAttempt == null ?
          "" :
          failedDueToAttempt.toString();
      log(writers, RecordTypes.Task,
          new Keys[]{Keys.TASKID, Keys.TASK_TYPE,
                     Keys.TASK_STATUS, Keys.FINISH_TIME,
                     Keys.ERROR, Keys.TASK_ATTEMPT_ID},
          new String[]{ taskId.toString(),  taskType,
                        Values.FAILED.name(),
                        String.valueOf(time) , error,
                        failedAttempt});
    }
  }
15677
public final void addPrerequisite(final Task<?> task) {
        Logger.v("Task[%s] add prerequisite: Task[%s]", this, task);

        synchronized (mTaskLock) {
            if (!mPrerequisites.contains(task)) {
                mPrerequisites.add(task);
                task.addDependency(this);
            }
        }
    }
185797
@SuppressWarnings("checkstyle:illegalcatch")
  public void beforeTaskStart() throws TaskStartHandlerFailure {
    LOG.log(Level.FINEST, "Sending TaskStart event to the registered event handlers.");
    for (final EventHandler<TaskStart> startHandler : this.taskStartHandlers) {
      try {
        startHandler.onNext(this.taskStart);
      } catch (final Throwable throwable) {
        throw new TaskStartHandlerFailure(startHandler, throwable);
      }
    }
    LOG.log(Level.FINEST, "Done sending TaskStart event to the registered event handlers.");
  }
560068
public static <TResult> Task<TResult> forError(Exception error) {
    bolts.TaskCompletionSource<TResult> tcs = new bolts.TaskCompletionSource<>();
    tcs.setError(error);
    return tcs.getTask();
  }
791435
private void validateApplication(ApplicationDefinition appDef) {
        boolean bSawAgingFreq = false;
        for (String optName : appDef.getOptionNames()) {
            String optValue = appDef.getOption(optName);
            switch (optName) {
            case CommonDefs.OPT_STORAGE_SERVICE:
                assert optValue.equals(this.getClass().getSimpleName());
                break;
                
            case CommonDefs.OPT_AGING_CHECK_FREQ:
                new TaskFrequency(optValue);
                bSawAgingFreq = true;
                break;
                
            case "auto-merge":
                new TaskFrequency(optValue);
                break;

            default:
                throw new IllegalArgumentException("Unknown option for OLAPService application: " + optName);
            }
        }

        for (TableDefinition tableDef : appDef.getTableDefinitions().values()) {
            validateTable(tableDef);
        }
        
        if (!bSawAgingFreq) {
            appDef.setOption(CommonDefs.OPT_AGING_CHECK_FREQ, "1 DAY");
        }
    }
1265744
public boolean shouldExecute(DefaultPostJobDescriptor descriptor) {
    if (!settingsCondition(descriptor)) {
      LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name());
      return false;
    }
    return true;
  }
280381
public boolean validation() throws ParallelTaskInvalidException {

        ParallelTask task = new ParallelTask();
        targetHostMeta = new TargetHostMeta(targetHosts);

        task = new ParallelTask(requestProtocol, concurrency, httpMeta,
                targetHostMeta, sshMeta, tcpMeta, udpMeta, pingMeta, null, responseContext,
                 replacementVarMapNodeSpecific,
                replacementVarMap, requestReplacementType, config);
        boolean valid = false;

        try {
            valid = task.validateWithFillDefault();
        } catch (ParallelTaskInvalidException e) {
            logger.info("task is invalid " + e);
        }

        return valid;

    }
1713
public void removeTaskFromQueue(String taskType, String taskId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");
        Preconditions.checkArgument(StringUtils.isNotBlank(taskId), "Task id cannot be blank");

        delete("tasks/queue/{taskType}/{taskId}", taskType, taskId);
    }
515035
public TaskDef getTaskDef(String taskType) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");
        return getForEntity("metadata/taskdefs/{tasktype}", null, TaskDef.class, taskType);
    }
849627
public boolean validation() throws ParallelTaskInvalidException {

        if (this.commandLine == null) {
            throw new ParallelTaskInvalidException(
                    "commandSshLine is null for ssh");
        }
        if (this.sshLoginType == null) {
            throw new ParallelTaskInvalidException(
                    "sshLoginType is null for ssh");
        }

        if (this.userName == null) {
            throw new ParallelTaskInvalidException("userName is null for ssh. "
                    + "UserName is required for both key/password based login");
        }


        if (this.sshLoginType == SshLoginType.PASSWORD && password == null) {
            throw new ParallelTaskInvalidException(
                    "use password but it is null for ssh");
        }
        if (this.sshLoginType == SshLoginType.KEY
                && this.privKeyRelativePath == null) {
            throw new ParallelTaskInvalidException(
                    "use public key but private key path is null for ssh");
        }

        if (this.sshLoginType == SshLoginType.KEY
                && this.privKeyUsePassphrase && this.passphrase == null) {
            throw new ParallelTaskInvalidException(
                    "use public key and also with private key passphrase but it is null for ssh");
        }

        return true;

    }
846651
function checkPreconditions(options) {
    if (!options) {
        throw Error("'options' must be specified!");
    }

    if (!(options.modules instanceof Array)) {
        throw Error("'options.modules' must be an array!");
    }

    // If the modules array is empty, immediately call the onComplete() if it exists
    if (!options.modules.length) {
        if (options.onComplete) {
            invokeOnComplete(options);
        }

        return false;
    }

    return true;
}
1073481
protected void invokePreconditions() {
    MethodContractHandle h =
        contracts.getMethodHandle(ContractKind.PRE, methodName, methodDesc, 0);
    if (h == null) {
      return;
    }

    MethodNode contractMethod = injectContractMethod(h);
    if (!statik) {
      loadThis();
    }
    loadArgs();
    invokeContractMethod(contractMethod);
  }
1361854
public TaskDef getTaskDef(String taskType) {
        Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");
        return protoMapper.fromProto(
                stub.getTask(MetadataServicePb.GetTaskRequest.newBuilder()
                        .setTaskType(taskType)
                        .build()
                ).getTask()
        );
    }
500666
private static void checkPreconditions(final Class<?> jodaClass,
			final String pattern) {
		if (jodaClass == null) {
			throw new NullPointerException("jodaClass should not be null");
		} else if (pattern == null) {
			throw new NullPointerException("pattern should not be null");
		}
	}
894603
public void check(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
    {
        ensureElementClassRef(collDef, checkLevel);
        checkInheritedForeignkey(collDef, checkLevel);
        ensureCollectionClass(collDef, checkLevel);
        checkProxyPrefetchingLimit(collDef, checkLevel);
        checkOrderby(collDef, checkLevel);
        checkQueryCustomizer(collDef, checkLevel);
    }