Package 

Class ErrorMap

  • All Implemented Interfaces:

    
    public final class ErrorMap
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      ErrorMap(Integer size)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit addError(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 Boolean hasErrors() Tests whether this ErrorMap contains any errors.
      final ObjectNode toJson()
      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.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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
        }