Class GetAndApplyImpl<I,​O,​T,​E extends java.lang.Exception>

  • All Implemented Interfaces:
    Get<I,​T,​E>, GetAndApply<I,​O,​T,​E>

    public class GetAndApplyImpl<I,​O,​T,​E extends java.lang.Exception>
    extends java.lang.Object
    implements GetAndApply<I,​O,​T,​E>
    • Constructor Summary

      Constructors 
      Constructor Description
      GetAndApplyImpl​(Get<I,​O,​E> getter, java.util.function.Function<O,​T> mapping)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <X> GetAndApply<I,​T,​X,​E> andApply​(java.util.function.Function<T,​X> mapping)
      Specifies a mapping function that is applied if the getter returned a non-null value.
      boolean equals​(java.lang.Object obj)  
      java.util.Optional<T> from​(I object)
      Evaluates the property path on the specified object.
      T fromOrDefault​(I object, T defaultValue)
      Evaluates the property path on the specified object.
      int hashCode()  
      GetWithoutException<I,​T> toJdk8()  
      java.lang.String toPath()  
      java.lang.String toString​(boolean detailed)  
      • Methods inherited from class java.lang.Object

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

      • GetAndApplyImpl

        public GetAndApplyImpl​(Get<I,​O,​E> getter,
                               java.util.function.Function<O,​T> mapping)
    • Method Detail

      • toJdk8

        public GetWithoutException<I,​T> toJdk8()
        Specified by:
        toJdk8 in interface GetAndApply<I,​O,​T,​E extends java.lang.Exception>
        Returns:
        Returns a get access object without the support for generic exceptions. This was introduced to provide a workaround for JDK 8, where a bug led to incorrect exception type inference.
      • from

        public java.util.Optional<T> from​(I object)
                                   throws E extends java.lang.Exception
        Description copied from interface: Get
        Evaluates the property path on the specified object.
        Specified by:
        from in interface Get<I,​O,​T>
        Parameters:
        object - The object to evaluate the property path on.
        Returns:
        Returns the value of the property wrapped in an Optional.
        Throws:
        E - May be thrown by the property path.
        E extends java.lang.Exception
      • fromOrDefault

        public T fromOrDefault​(I object,
                               T defaultValue)
                        throws E extends java.lang.Exception
        Description copied from interface: Get
        Evaluates the property path on the specified object. If a value is present it will be returned, otherwise the specified default value is returned.
        Specified by:
        fromOrDefault in interface Get<I,​O,​T>
        Parameters:
        object - The object to evaluate the property path on.
        defaultValue - The default value to return in case the property path does not have a value.
        Returns:
        If a value is present it will be returned, otherwise the specified default value is returned.
        Throws:
        E - May be thrown by the property path.
        E extends java.lang.Exception
      • andApply

        public <X> GetAndApply<I,​T,​X,​E> andApply​(java.util.function.Function<T,​X> mapping)
        Description copied from interface: Get
        Specifies a mapping function that is applied if the getter returned a non-null value. The mapping function can be used for calculations or type conversions.
        Specified by:
        andApply in interface Get<I,​O,​T>
        Type Parameters:
        X - The new return type of the getter after applying the mapping function.
        Parameters:
        mapping - The mapping function - only applied if the getter has a non-null return value.
        Returns:
        Returns a new object for further configuration.
      • toString

        public java.lang.String toString​(boolean detailed)
        Specified by:
        toString in interface Get<I,​O,​T>
        Returns:
        Returns a detailed string if specified, otherwise a shorter string is returned.
      • toPath

        public java.lang.String toPath()
        Specified by:
        toPath in interface Get<I,​O,​T>
        Returns:
        Returns a JSON-like property path. Example: a.b.cs[0].d
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object