public static void checkTask(Task task) { // Check required fields assertNotNull(task.getStatus(), String.format(NOT_NULL_OBJECT_FMT, "Status", "Task")); assertTrue( Task.Status.ALL.contains(task.getStatus()), String.format( REQUIRED_VALUE_OBJECT_FMT, "Status", "Task", task.getStatus(), Iterables.toString(Task.Status.ALL))); // Check optional fields // NOTE operation cannot be checked // NOTE operationName cannot be checked // NOTE startTime cannot be checked // NOTE endTime cannot be checked // NOTE expiryTimecannot be checked ReferenceType<?> owner = task.getOwner(); if (owner != null) checkReferenceType(owner); Error error = task.getError(); if (error != null) checkError(error); ReferenceType<?> user = task.getUser(); if (user != null) checkReferenceType(user); ReferenceType<?> org = task.getOrg(); if (org != null) checkReferenceType(org); Integer progress = task.getProgress(); if (progress != null) checkProgress(progress); // NOTE params cannot be checked // Check parent type checkEntityType(task); }
public Builder fromTask(Task in) { return fromEntityType(in) .error(in.getError()) .org(in.getOrg()) .progress(in.getProgress()) .status(in.getStatus()) .operation(in.getOperation()) .operationName(in.getOperationName()); }