Interface PropertyAccessor


  • public interface PropertyAccessor
    Used to get and set object properties based on an xpath expression.
    Author:
    Justin Deoliveira, The Open Planning Project
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean canHandle​(Object object, String xpath, Class<?> target)
      Determines if the property accessor can handle the property denoted by xpath.
      <T> T get​(Object object, String xpath, Class<T> target)
      Accesses a property of object via xpath expression.
      <T> void set​(Object object, String xpath, T value, Class<T> target)
      Sets a property of object via xpath expression.
    • Method Detail

      • canHandle

        boolean canHandle​(Object object,
                          String xpath,
                          Class<?> target)
        Determines if the property accessor can handle the property denoted by xpath.

        Can be used to perform checks against schema to ensure that the propery accessor will actually work with the provided instance.

        Parameters:
        object - The target object.
        xpath - An xpath expression denoting a property of the target object.
        Returns:
        true if the property can be accessed, otherwise false
      • get

        <T> T get​(Object object,
                  String xpath,
                  Class<T> target)
           throws IllegalArgumentException
        Accesses a property of object via xpath expression.

        #canHandle(Object, String) should be called before calling this method to ensure that the property can be safely accessed.

        Parameters:
        object - The target object.
        xpath - An xpath expression denoting a property of the target object.
        target - Target context we intend to access (often null or Geometry.class)
        Returns:
        The property, which might be null
        Throws:
        IllegalArgumentException - In the even that xpath is not supported.
      • set

        <T> void set​(Object object,
                     String xpath,
                     T value,
                     Class<T> target)
              throws IllegalArgumentException
        Sets a property of object via xpath expression.

        #canHandle(Object, String) should be called before calling this method to ensure that the property can be safely accessed.

        Parameters:
        object - The target object.
        xpath - An xpath expression denoting a property of the target object.
        value - The new value to set
        target - The target context we intend to update (often null or Geometry.class)
        Throws:
        IllegalArgumentException - In the even that xpath is not supported.