java.lang.Object
ru.cg.webbpm.studio.subsystems.page_designer.serialization.impl.adapter.AdapterUtils

public class AdapterUtils extends Object
Author:
krylov
  • Constructor Details

    • AdapterUtils

      public AdapterUtils()
  • Method Details

    • oneOf

      public static <T> T oneOf(T o1, T o2)
      Optimized version of oneOf(Object[]) for two arguments
    • oneOf

      public static <T> T oneOf(T o1, T o2, T o3)
      Optimized version of oneOf(Object[]) for three arguments
    • oneOf

      @SafeVarargs public static <T> T oneOf(T... values)
      Returns first non-null of passed values
      Parameters:
      values - list of values to check
      Returns:
      first non-null value, or null if all values are null
    • toSortedMap

      public static <T, K, U> Collector<T,?,Map<K,U>> toSortedMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper)
    • ifDiffer

      public static <B, T> T ifDiffer(Function<B,T> getter, B object, B proto)
      Returns null if prototype isn't null and the value equals prototype value, otherwise returns value
      Type Parameters:
      B - bean type
      T - value type
      Parameters:
      getter - getter for value
      object - a bean
      proto - nullable bean's prototype
      Returns:
      either object value or null
    • nullIfEmpty

      public static <K, V> Map<K,V> nullIfEmpty(Map<K,V> map)
      Checks if map is empty, returns null if it is
      Parameters:
      map - map to check
      Returns:
      map provided, or null if it's empty
    • nullIfEmpty

      public static <V> Collection<V> nullIfEmpty(Collection<V> collection)
      Checks if collection is empty, returns null if it is
      Parameters:
      collection - collection to check
      Returns:
      collection provided, or null if it's empty
    • isEmpty

      public static boolean isEmpty(XmlPropertyValue value)
    • isEmpty

      public static boolean isEmpty(XmlArrayItem arrayItem)
    • isEmpty

      public static boolean isEmpty(PropertyValue value)
    • safeCall

      public static <O, T> T safeCall(O object, Function<O,T> getter)
      returns getter value if value provided is not null, or null otherwise (imitates Kotlin ?. operator)
      Parameters:
      object - nullable object
      getter - value getter
      Returns:
      getter value, or null if object is null