Class SerializedObjectBuilder


  • public class SerializedObjectBuilder
    extends java.lang.Object
    Helper class that helps gson serializers make JsonObject instances and avoid serializing null fields where omitting them would make for a cleaner serialized object.
    • Constructor Summary

      Constructors 
      Constructor Description
      SerializedObjectBuilder​(com.inductiveautomation.ignition.common.gson.JsonSerializationContext context)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.Boolean value, java.lang.Boolean defaultValue)
      Add the boolean if it is not null and not equal to its default value.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.Integer value)
      Add the integer value if it is not null.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.Integer value, java.lang.Integer defaultValue)
      Add the integer value if it is not null and not equal to its default value.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.Object value)
      Add the given value if it is not null.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.Object value, java.lang.Object defaultValue)
      Add the given value if it is not null and not equal to the provided default.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.String value)
      Add the string value if it is not null.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.lang.String value, java.lang.String defaultValue)
      Add the string value if it is not null and not equal to its default value.
      SerializedObjectBuilder add​(java.lang.String fieldName, java.util.Collection<?> collection)
      Adds the given collection only if it is non-null and non-empty
      <T> SerializedObjectBuilder add​(java.lang.String fieldName, T value, java.util.function.Predicate<T> predicate)
      Add the given value if it is not null and it passes the given predicate.
      com.inductiveautomation.ignition.common.gson.JsonObject build()  
      • Methods inherited from class java.lang.Object

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

      • SerializedObjectBuilder

        public SerializedObjectBuilder​(com.inductiveautomation.ignition.common.gson.JsonSerializationContext context)
    • Method Detail

      • add

        public <T> SerializedObjectBuilder add​(java.lang.String fieldName,
                                               T value,
                                               java.util.function.Predicate<T> predicate)
        Add the given value if it is not null and it passes the given predicate.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.String value)
        Add the string value if it is not null.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.String value,
                                           java.lang.String defaultValue)
        Add the string value if it is not null and not equal to its default value.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.Boolean value,
                                           java.lang.Boolean defaultValue)
        Add the boolean if it is not null and not equal to its default value.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.Integer value,
                                           java.lang.Integer defaultValue)
        Add the integer value if it is not null and not equal to its default value.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.Integer value)
        Add the integer value if it is not null.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.Object value)
        Add the given value if it is not null.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.lang.Object value,
                                           java.lang.Object defaultValue)
        Add the given value if it is not null and not equal to the provided default.
      • add

        public SerializedObjectBuilder add​(java.lang.String fieldName,
                                           java.util.Collection<?> collection)
        Adds the given collection only if it is non-null and non-empty
      • build

        public com.inductiveautomation.ignition.common.gson.JsonObject build()