-
- All Implemented Interfaces:
public final class ErrorMap
-
-
Method Summary
Modifier and Type Method Description final UnitaddError(String key, String msg)Appends an error to this ErrorMap. final Map<String, List<String>>toMap()Extracts a Java Map of errors from this ErrorMap. final BooleanhasErrors()Tests whether this ErrorMap contains any errors. final ObjectNodetoJson()final Unitincompatible(BlastField field, BlastField others)Tests flags that are incompatible with one another and appends errors for both incompatible flags when an entry in others has a non-default value. final Unitrequires(BlastField field1, BlastField field2)Tests a flag that requires another flag to ensure that either the first field is its default value, otherwise both fields are non-default. -
-
Constructor Detail
-
ErrorMap
ErrorMap(Integer size)
-
-
Method Detail
-
addError
final Unit addError(String key, String msg)
Appends an error to this ErrorMap.
- Parameters:
key- Name of the field the given error message relates to.msg- Error message to append.
-
toJson
final ObjectNode toJson()
-
incompatible
final Unit incompatible(BlastField field, BlastField others)
Tests flags that are incompatible with one another and appends errors for both incompatible flags when an entry in others has a non-default value.
If field is its default value, this method does nothing.
errs := ErrorMap() inp_1 := {name: foo, isDefault: false} inp_2 := {name: bar, isDefault: false} errs.incompatible(inp_1, inp_2) errs.toMap == { foo: Incompatible with bar bar: Incompatible with foo }- Parameters:
field- Primary field to test against.others- Other fields to test against.
-
requires
final Unit requires(BlastField field1, BlastField field2)
Tests a flag that requires another flag to ensure that either the first field is its default value, otherwise both fields are non-default.
If the first field is non-default and the second field is default, an error will be appended to this ErrorMap.
errs := ErrorMap() inp_1 := {name: foo, isDefault: false} inp_2 := {name: bar, isDefault: true} errs.requires(inp_1, inp_2) errs.toMap == { foo: Requires bar }
-
-
-
-