Class ObjectViewer

java.lang.Object
org.apache.juneau.objecttools.ObjectViewer
All Implemented Interfaces:
ObjectTool<ViewArgs>

public final class ObjectViewer extends Object implements ObjectTool<ViewArgs>
POJO model viewer.

This class is designed to extract properties from collections of maps or beans.

Example:

MyBean[] arrayOfBeans = ...; ObjectViewer viewer = ObjectViewer.create(); // Returns the 'foo' and 'bar' properties extracted into a list of maps. List<Map> result = viewer.run(arrayOfBeans, "foo,bar");

The tool can be used against the following data types:

  • Arrays/collections of maps or beans.
  • Singular maps or beans.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static ObjectViewer create()
      Static creator.
      Returns:
      A new ObjectViewer object.
    • run

      public List<Map> run(Object input, String args)
      Runs this viewer on the specified collection or array of objects.
      Parameters:
      input - The input. Must be an array or collection.
      args - The view args. See ViewArgs for format.
      Returns:
      The extracted properties from the collection of objects.
    • runSingle

      public Map runSingle(Object input, String args)
      Runs this viewer on a singleton object.
      Parameters:
      input - The input. Must be a singleton object.
      args - The view args. See ViewArgs for format.
      Returns:
      The extracted properties from the object.
    • run

      public Object run(BeanSession session, Object input, ViewArgs args)
      Description copied from interface: ObjectTool
      Converts the specified input to some other output.
      Specified by:
      run in interface ObjectTool<ViewArgs>
      Parameters:
      session - The current bean session.
      input - The input POJO.
      args - The arguments.
      Returns:
      The output POJO.