Class JsonViewWrapper

java.lang.Object
com.kosdev.kos.commons.util.json.JsonViewWrapper
Direct Known Subclasses:
ReasonData

public class JsonViewWrapper extends Object
An object wrapper that applies a custom view to the object being wrapped. This is commonly used when an object like FutureWork or Trouble included additional data but that data needs to be constrained to a view.
Since:
1
Version:
1
  • Constructor Details

    • JsonViewWrapper

      public JsonViewWrapper()
      Create an empty wrapper object that contains no data or json view.
      Since:
      1
    • JsonViewWrapper

      public JsonViewWrapper(Object data, Class<?> view)
      Create a wrapper object that hold the specified data and will serialize the data to json using the specified view class.
      Parameters:
      data - the data to be serialized to json when the wrapper is serialized
      view - the json view to apply to the data during serialization
      Since:
      1
  • Method Details

    • setData

      public void setData(Object data, Class<?> view)
      Convenience method that sets data and view in a single call.
      Parameters:
      data - the data to be serialized to json when the wrapper is serialized
      view - the json view to apply to the data during serialization
      Since:
      1
    • getData

      public Object getData()
    • getView

      public Class<?> getView()
    • setData

      public JsonViewWrapper setData(Object data)
      Returns:
      this .
    • setView

      public JsonViewWrapper setView(Class<?> view)
      Returns:
      this .