Interface Claim


  • public interface Claim
    The Claim class holds the value in a generic way so that it can be recovered in many representations.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <T> T as​(java.lang.Class<T> clazz)
      Get this Claim as a custom type T.
      <T> T[] asArray​(java.lang.Class<T> clazz)
      Get this Claim as an Array of type T.
      java.lang.Boolean asBoolean()
      Get this Claim as a Boolean.
      java.util.Date asDate()
      Get this Claim as a Date.
      java.lang.Double asDouble()
      Get this Claim as a Double.
      default java.time.Instant asInstant()
      Get this Claim as an Instant.
      java.lang.Integer asInt()
      Get this Claim as an Integer.
      <T> java.util.List<T> asList​(java.lang.Class<T> clazz)
      Get this Claim as a List of type T.
      java.lang.Long asLong()
      Get this Claim as an Long.
      java.util.Map<java.lang.String,​java.lang.Object> asMap()
      Get this Claim as a generic Map of values.
      java.lang.String asString()
      Get this Claim as a String.
      boolean isMissing()
      Can be used to verify whether the Claim is found or not.
      boolean isNull()
      Whether this Claim has a null value or not.
    • Method Detail

      • isNull

        boolean isNull()
        Whether this Claim has a null value or not. If the claim is not present, it will return false hence checking isMissing() is advised as well
        Returns:
        whether this Claim has a null value or not.
      • isMissing

        boolean isMissing()
        Can be used to verify whether the Claim is found or not. This will be true even if the Claim has null value associated to it.
        Returns:
        whether this Claim is present or not
      • asBoolean

        java.lang.Boolean asBoolean()
        Get this Claim as a Boolean. If the value isn't of type Boolean or it can't be converted to a Boolean, null will be returned.
        Returns:
        the value as a Boolean or null.
      • asInt

        java.lang.Integer asInt()
        Get this Claim as an Integer. If the value isn't of type Integer or it can't be converted to an Integer, null will be returned.
        Returns:
        the value as an Integer or null.
      • asLong

        java.lang.Long asLong()
        Get this Claim as an Long. If the value isn't of type Long or it can't be converted to a Long, null will be returned.
        Returns:
        the value as an Long or null.
      • asDouble

        java.lang.Double asDouble()
        Get this Claim as a Double. If the value isn't of type Double or it can't be converted to a Double, null will be returned.
        Returns:
        the value as a Double or null.
      • asString

        java.lang.String asString()
        Get this Claim as a String. If the value isn't of type String, null will be returned. For a String representation of non-textual claim types, clients can call toString().
        Returns:
        the value as a String or null if the underlying value is not a string.
      • asDate

        java.util.Date asDate()
        Get this Claim as a Date. If the value can't be converted to a Date, null will be returned.
        Returns:
        the value as a Date or null.
      • asInstant

        default java.time.Instant asInstant()
        Get this Claim as an Instant. If the value can't be converted to an Instant, null will be returned.
        Returns:
        the value as a Date or null.
      • asArray

        <T> T[] asArray​(java.lang.Class<T> clazz)
                 throws JWTDecodeException
        Get this Claim as an Array of type T. If the value isn't an Array, null will be returned.
        Type Parameters:
        T - type
        Parameters:
        clazz - the type class
        Returns:
        the value as an Array or null.
        Throws:
        JWTDecodeException - if the values inside the Array can't be converted to a class T.
      • asList

        <T> java.util.List<T> asList​(java.lang.Class<T> clazz)
                              throws JWTDecodeException
        Get this Claim as a List of type T. If the value isn't an Array, null will be returned.
        Type Parameters:
        T - type
        Parameters:
        clazz - the type class
        Returns:
        the value as a List or null.
        Throws:
        JWTDecodeException - if the values inside the List can't be converted to a class T.
      • asMap

        java.util.Map<java.lang.String,​java.lang.Object> asMap()
                                                              throws JWTDecodeException
        Get this Claim as a generic Map of values.
        Returns:
        the value as instance of Map.
        Throws:
        JWTDecodeException - if the value can't be converted to a Map.
      • as

        <T> T as​(java.lang.Class<T> clazz)
          throws JWTDecodeException
        Get this Claim as a custom type T. This method will return null if isMissing() or isNull() is true
        Type Parameters:
        T - type
        Parameters:
        clazz - the type class
        Returns:
        the value as instance of T.
        Throws:
        JWTDecodeException - if the value can't be converted to a class T.