Class FunctionUtils

java.lang.Object
cz.masci.springfx.mvci.util.FunctionUtils

public class FunctionUtils extends Object
  • Constructor Details

    • FunctionUtils

      public FunctionUtils()
  • Method Details

    • applyNotNull

      public static <T, V> V applyNotNull(T source, Function<T,V> transform)
         Accepts not null source and applies the transform function on it.
         If the source is null returns null.
       
      Type Parameters:
      T - Type of source object
      V - Type of transformed object
      Parameters:
      source - Source object
      transform - Transformation function
      Returns:
      Transformed value or null
    • applyNotNullElse

      public static <T, V> V applyNotNullElse(T source, Function<T,V> transform, V value)
         Accepts not null source and applies the transform function on it.
         If the source is null returns value.
       
      Type Parameters:
      T - Type of source object
      V - Type of transformed object
      Parameters:
      source - Source object
      transform - Transformation function
      value - Default value if source is null
      Returns:
      Transformed value or default value
    • applyNotNullElseGet

      public static <T, V> V applyNotNullElseGet(T source, Function<T,V> transform, Supplier<V> value)
         Accepts not null source and applies the transform function on it.
         If the source is null returns supplied value.
       
      Type Parameters:
      T - Type of source object
      V - Type of transformed object
      Parameters:
      source - Source object
      transform - Transformation function
      value - Supplier for default value if source is null
      Returns:
      Transformed value or default value