Class DataPath

java.lang.Object
org.jdrupes.vmoperator.util.DataPath

public final class DataPath extends Object
Utility class that supports navigation through arbitrary data structures.
  • Method Details

    • get

      public static <T> Optional<T> get(Object from, Object... selectors)
      Apply the given selectors on the given object and return the value reached.

      Selectors can be if type String or Number. The former are used to access a property of an object, the latter to access an element in an array or a List.

      Depending on the object currently visited, a String can be the key of a Map, the property part of a getter method or the name of a method that has an empty parameter list.

      Type Parameters:
      T - the generic type
      Parameters:
      from - the from
      selectors - the selectors
      Returns:
      the result
    • deepCopy

      public static <T> T deepCopy(T object)
      Attempts to make a as-deep-as-possible copy of the given container.

      New containers will be created for Maps, Lists and Arrays. The method is invoked recursively for the entries/items.

      If invoked with an object that is neither a map, list or array, the methods checks if the object implements Cloneable and if it does, invokes its Object.clone() method. Else the method return the object.

      Type Parameters:
      T - the generic type
      Parameters:
      object - the container
      Returns:
      the t