Class JsSpecs


  • public final class JsSpecs
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static JsSpec any​(java.util.function.Predicate<JsValue> predicate)
      returns a spec that conforms any value that is evaluated to true on the predicate.
      static JsArraySpec array​(java.util.function.Predicate<JsValue> predicate)
      non-nullable array, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOf​(JsObjSpec spec)
      A required and none nullable spec that specifies an array of objects that conform the given spec
      static JsArraySpec arrayOfBoolSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of booleans that satisfies the given predicate
      static JsArraySpec arrayOfDec​(java.util.function.Predicate<java.math.BigDecimal> predicate)
      non-nullable array of decimal numbers, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfDecSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of decimal numbers that satisfies the given predicate
      static JsArraySpec arrayOfInt​(java.util.function.IntPredicate predicate)
      non-nullable array of integer numbers, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfIntegral​(java.util.function.Predicate<java.math.BigInteger> predicate)
      non-nullable array of integral numbers, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfIntegralSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of integral numbers that satisfies the given predicate
      static JsArraySpec arrayOfIntSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of numbers that satisfies the given predicate
      static JsArraySpec arrayOfLong​(java.util.function.LongPredicate predicate)
      non-nullable array of long numbers, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfLongSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of long numbers that satisfies the given predicate
      static JsArraySpec arrayOfNumber​(java.util.function.Predicate<JsNumber> predicate)
      non-nullable array of numbers, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfNumberSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of numbers that satisfies the given predicate
      static JsArraySpec arrayOfObj​(java.util.function.Predicate<JsObj> predicate)
      non-nullable array of objects, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfObjSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of objects that satisfies the given predicate
      static JsArraySpec arrayOfStr​(java.util.function.Predicate<java.lang.String> predicate)
      non-nullable array of strings, where each element of the array satisfies the given predicate
      static JsArraySpec arrayOfStrSuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array of strings that satisfies the given predicate
      static JsArraySpec arraySuchThat​(java.util.function.Predicate<JsArray> predicate)
      non-nullable array that satisfies the given predicate
      static JsSpec binary​(java.util.function.Predicate<byte[]> predicate)
      non-nullable json object that satisfies the given predicate
      static JsSpec cons​(JsValue value)
      a required and non nullable spec that specifies a constant
      static JsSpec decimal​(java.util.function.Predicate<java.math.BigDecimal> predicate)
      non-nullable decimal number that satisfies the given predicate
      static JsSpec instant​(java.util.function.Predicate<java.time.Instant> predicate)
      non-nullable json object that satisfies the given predicate
      static JsSpec integer​(java.util.function.IntPredicate predicate)
      non-nullable integer number that satisfies the given predicate
      static JsSpec integral​(java.util.function.Predicate<java.math.BigInteger> predicate)
      non-nullable integral number that satisfies the given predicate
      static JsSpec longInteger​(java.util.function.LongPredicate predicate)
      non-nullable long number that satisfies the given predicate
      static JsSpec number​(java.util.function.Predicate<JsNumber> predicate)
      non-nullable number that satisfies the given predicate
      static JsSpec obj​(java.util.function.Predicate<JsObj> predicate)
      non-nullable json object that satisfies the given predicate
      static <O extends JsValue>
      JsSpec
      oneOf​(java.util.List<O> cons)  
      static JsSpec str​(java.util.function.Predicate<java.lang.String> predicate)
      non-nullable string that satisfies the given predicate
      static JsTupleSpec tuple​(JsSpec spec, JsSpec... others)
      returns a tuple spec.
      • Methods inherited from class java.lang.Object

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

      • any

        public static final JsSpec any
        spec that is conformed by any value
      • str

        public static final JsSpec str
        non-nullable string
      • number

        public static final JsSpec number
        non-nullable number
      • bool

        public static final JsSpec bool
        non-nullable boolean
      • decimal

        public static final JsSpec decimal
        non-nullable decimal number
      • integral

        public static final JsSpec integral
        non-nullable integral number
      • longInteger

        public static final JsSpec longInteger
        non-nullable long number
      • integer

        public static final JsSpec integer
        non-nullable integer number
      • TRUE

        public static final JsSpec TRUE
        true constant spec
      • FALSE

        public static final JsSpec FALSE
        false constant spec
      • obj

        public static final JsSpec obj
        non-nullable json object spec
      • array

        public static final JsArraySpec array
        non-nullable array spec
      • binary

        public static final JsSpec binary
        non-nullable array spec
      • instant

        public static final JsSpec instant
        non-nullable array spec
      • arrayOfLong

        public static final JsArraySpec arrayOfLong
        non-nullable array of long numbers spec
      • arrayOfInt

        public static final JsArraySpec arrayOfInt
        non-nullable array of integer numbers spec
      • arrayOfStr

        public static final JsArraySpec arrayOfStr
        non-nullable array of strings spec
      • arrayOfBool

        public static final JsArraySpec arrayOfBool
        non-nullable array of booleans spec
      • arrayOfDec

        public static final JsArraySpec arrayOfDec
        non-nullable array of decimal numbers spec
      • arrayOfNumber

        public static final JsArraySpec arrayOfNumber
        non-nullable array of numbers spec
      • arrayOfIntegral

        public static final JsArraySpec arrayOfIntegral
        non-nullable array of integral numbers spec
      • arrayOfObj

        public static final JsArraySpec arrayOfObj
        non-nullable array of objects spec
    • Method Detail

      • arrayOf

        public static JsArraySpec arrayOf​(JsObjSpec spec)
        A required and none nullable spec that specifies an array of objects that conform the given spec
        Parameters:
        spec - the given spec that every object in the array has to conform
        Returns:
        a spec
      • cons

        public static JsSpec cons​(JsValue value)
        a required and non nullable spec that specifies a constant
        Parameters:
        value - the constant
        Returns:
        a spec
      • str

        public static JsSpec str​(java.util.function.Predicate<java.lang.String> predicate)
        non-nullable string that satisfies the given predicate
        Parameters:
        predicate - the predicate
        Returns:
        a JsSpec
      • number

        public static JsSpec number​(java.util.function.Predicate<JsNumber> predicate)
        non-nullable number that satisfies the given predicate
        Parameters:
        predicate - the predicate
        Returns:
        a JsSpec
      • arrayOfIntSuchThat

        public static JsArraySpec arrayOfIntSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of numbers that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • arrayOfDec

        public static JsArraySpec arrayOfDec​(java.util.function.Predicate<java.math.BigDecimal> predicate)
        non-nullable array of decimal numbers, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each decimal number of the array is tested on
        Returns:
        an array spec
      • arrayOfDecSuchThat

        public static JsArraySpec arrayOfDecSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of decimal numbers that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • arrayOfIntegral

        public static JsArraySpec arrayOfIntegral​(java.util.function.Predicate<java.math.BigInteger> predicate)
        non-nullable array of integral numbers, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each integral number of the array is tested on
        Returns:
        an array spec
      • arrayOfIntegralSuchThat

        public static JsArraySpec arrayOfIntegralSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of integral numbers that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • arrayOfNumber

        public static JsArraySpec arrayOfNumber​(java.util.function.Predicate<JsNumber> predicate)
        non-nullable array of numbers, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each number of the array is tested on
        Returns:
        an array spec
      • arrayOfNumberSuchThat

        public static JsArraySpec arrayOfNumberSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of numbers that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • arrayOfObj

        public static JsArraySpec arrayOfObj​(java.util.function.Predicate<JsObj> predicate)
        non-nullable array of objects, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each object of the array is tested on
        Returns:
        an array spec
      • arrayOfObjSuchThat

        public static JsArraySpec arrayOfObjSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of objects that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • integer

        public static JsSpec integer​(java.util.function.IntPredicate predicate)
        non-nullable integer number that satisfies the given predicate
        Parameters:
        predicate - the predicate the integer is tested on
        Returns:
        a spec
      • arrayOfStrSuchThat

        public static JsArraySpec arrayOfStrSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of strings that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • array

        public static JsArraySpec array​(java.util.function.Predicate<JsValue> predicate)
        non-nullable array, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each value of the array is tested on
        Returns:
        an array spec
      • arrayOfLong

        public static JsArraySpec arrayOfLong​(java.util.function.LongPredicate predicate)
        non-nullable array of long numbers, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each long number of the array is tested on
        Returns:
        an array spec
      • arrayOfBoolSuchThat

        public static JsArraySpec arrayOfBoolSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of booleans that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • longInteger

        public static JsSpec longInteger​(java.util.function.LongPredicate predicate)
        non-nullable long number that satisfies the given predicate
        Parameters:
        predicate - the predicate the long is tested on
        Returns:
        a spec
      • decimal

        public static JsSpec decimal​(java.util.function.Predicate<java.math.BigDecimal> predicate)
        non-nullable decimal number that satisfies the given predicate
        Parameters:
        predicate - the predicate the decimal is tested on
        Returns:
        a spec
      • integral

        public static JsSpec integral​(java.util.function.Predicate<java.math.BigInteger> predicate)
        non-nullable integral number that satisfies the given predicate
        Parameters:
        predicate - the predicate the integral number is tested on
        Returns:
        a spec
      • arrayOfStr

        public static JsArraySpec arrayOfStr​(java.util.function.Predicate<java.lang.String> predicate)
        non-nullable array of strings, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each string of the array is tested on
        Returns:
        an array spec
      • any

        public static JsSpec any​(java.util.function.Predicate<JsValue> predicate)
        returns a spec that conforms any value that is evaluated to true on the predicate. When the type is not specified by the spec, positive numbers are parsed as Long by default, which has to be taken into account in order to define any condition.
        Parameters:
        predicate - the predicate
        Returns:
        a spec
      • binary

        public static JsSpec binary​(java.util.function.Predicate<byte[]> predicate)
        non-nullable json object that satisfies the given predicate
        Parameters:
        predicate - the predicate the json object is tested on
        Returns:
        a spec
      • instant

        public static JsSpec instant​(java.util.function.Predicate<java.time.Instant> predicate)
        non-nullable json object that satisfies the given predicate
        Parameters:
        predicate - the predicate the json object is tested on
        Returns:
        a spec
      • obj

        public static JsSpec obj​(java.util.function.Predicate<JsObj> predicate)
        non-nullable json object that satisfies the given predicate
        Parameters:
        predicate - the predicate the json object is tested on
        Returns:
        a spec
      • arrayOfLongSuchThat

        public static JsArraySpec arrayOfLongSuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array of long numbers that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • arraySuchThat

        public static JsArraySpec arraySuchThat​(java.util.function.Predicate<JsArray> predicate)
        non-nullable array that satisfies the given predicate
        Parameters:
        predicate - the predicate the array is tested on
        Returns:
        an array spec
      • arrayOfInt

        public static JsArraySpec arrayOfInt​(java.util.function.IntPredicate predicate)
        non-nullable array of integer numbers, where each element of the array satisfies the given predicate
        Parameters:
        predicate - the predicate each integer number of the array is tested on
        Returns:
        an array spec
      • tuple

        public static JsTupleSpec tuple​(JsSpec spec,
                                        JsSpec... others)
        returns a tuple spec. Each nth-element of the tuple is specified by the nth given spec
        Parameters:
        spec - the spec of the first element
        others - the rest of specs
        Returns:
        a spec
      • oneOf

        public static <O extends JsValueJsSpec oneOf​(java.util.List<O> cons)