Class B2JsonObjectHandler<T>

  • All Implemented Interfaces:
    B2JsonTypeHandler<T>

    public class B2JsonObjectHandler<T>
    extends B2JsonTypeHandlerWithDefaults<T>
    (De)serializes Java objects based on field annotations.

    See doc comment on B2Json for annotation requirements.

    • Method Detail

      • getHandledType

        public java.lang.reflect.Type getHandledType()
        Description copied from interface: B2JsonTypeHandler
        What class does this handle?
        Returns:
      • serialize

        public void serialize​(T obj,
                              B2JsonOptions options,
                              B2JsonWriter out)
                       throws java.io.IOException,
                              B2JsonException
        Serializes the object, adding all fields to the JSON.

        Optional fields are always present, and set to null/0 when not present.

        The type name field for a member of a union type is added alphabetically in sequence, if needed.

        Throws:
        java.io.IOException
        B2JsonException
      • deserializeUrlParam

        public T deserializeUrlParam​(java.lang.String urlValue)
                              throws B2JsonException
        Description copied from interface: B2JsonTypeHandler
        When an API is called with GET, this is used to deserialize one of the values.
        Throws:
        B2JsonException
      • deserializeFromFieldNameToValueMap

        public T deserializeFromFieldNameToValueMap​(java.util.Map<java.lang.String,​java.lang.Object> fieldNameToValue,
                                                    B2JsonOptions options)
                                             throws B2JsonException
        Throws:
        B2JsonException
      • defaultValueForOptional

        public T defaultValueForOptional()
        Description copied from interface: B2JsonTypeHandler
        Returns the default value to use when an optional field is not present.
      • isStringInJson

        public boolean isStringInJson()
        Description copied from interface: B2JsonTypeHandler
        Does this type look like a string in JSON?
      • isBuiltInZeroableType

        public static boolean isBuiltInZeroableType​(java.lang.Class<?> type)
      • isZero

        public static boolean isZero​(java.lang.Object value)