Class Getter


  • public final class Getter
    extends java.lang.Object
    This is the Property Path API that can be used to build null-safe getters evaluating a specific property path.

    This library can be used to build get-chains easier. If you have a lot of optional fields in a large Java Bean object graph you normally have to implement null checks whenever accessing an optional field. This library performs this null checks so a property path can be written like a.getB().getC(). The return value of getB() does not have to be checked for null.

    A property path is a chain of get-calls. If a getter returns null the property path does not have a value. The same is true for lists and maps that are either null or do not contain a specified index or key. The null-checks are performed by the library an must not be implemented in the property path.

    This is the entry point of the builder API.

    Important information

    Once the builder creates a Get instance, this instance can and should be reused. This library creates proxy classes which is a time consuming operation that is only neccessary once. So cache the Get instance as long as possible.

    • Constructor Summary

      Constructors 
      Constructor Description
      Getter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <I,​O>
      GetBuilder<I>
      newFor​(java.lang.Class<I> startType)
      Creates a builder of a property path for the specified type.
      • Methods inherited from class java.lang.Object

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

      • Getter

        public Getter()
    • Method Detail

      • newFor

        public static <I,​O> GetBuilder<I> newFor​(java.lang.Class<I> startType)
        Creates a builder of a property path for the specified type.
        Parameters:
        startType - The type to evaluate a property path on.
        Returns:
        Returns a builder for further configuration.