@Beta public interface FailureCollector
ValidationFailure
s.Modifier and Type | Method and Description |
---|---|
default ValidationFailure |
addFailure(String message,
String correctiveAction)
Add a validation failure to this failure collector.
|
default ValidationException |
getOrThrowException()
Throws validation exception if there are any failures that are added to the failure collector through
addFailure(String, String) . |
default List<ValidationFailure> |
getValidationFailures()
Get list of validation failures.
|
default ValidationFailure addFailure(String message, @Nullable String correctiveAction)
ValidationFailure.Cause
s.
For example,
failureCollector.addFailure("message", "action").withConfigProperty("configProperty");
message
- failure messagecorrectiveAction
- corrective actionUnsupportedOperationException
- if the implementation does not override this methoddefault ValidationException getOrThrowException() throws ValidationException
addFailure(String, String)
.
If no failures are added to the collector, it will return a ValidationException
with empty failure list.
String someMethod() { switch (someVar) { // cases } // if control comes here, it means failure failureCollector.addFailure(...); // throw validation exception so that compiler knows that exception is being thrown which eliminates the need to // have a statement that returns null towards the end of this method throw failureCollector.getOrThrowException(); }
ValidationException
if no failures were added to the collectorValidationException
- exception indicating validation failuresUnsupportedOperationException
- if the implementation does not override this methoddefault List<ValidationFailure> getValidationFailures()
Copyright © 2020 Cask Data, Inc. Licensed under the Apache License, Version 2.0.