Class MiscUtils

java.lang.Object
org.codehaus.mojo.versions.utils.MiscUtils

public class MiscUtils extends Object
Miscellaneous utility class.
  • Method Details

    • filter

      public static <K,V> Map<K,V> filter(Map<K,V> map, Function<V,Boolean> predicate)
      Filters a given map leaving only elements fulfilling a predicate. Does not change the input map, the filtered map is returned as output.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      map - input map to be filtered
      predicate - predicate for element comparison
      Returns:
      map such that every element comforms with the predicate
    • filter

      public static <K,V> Map<K,V> filter(Map<K,V> map, Function<V,Boolean> predicate, BinaryOperator<V> mergeFunction)
      Filters a given map leaving only elements fulfilling a predicate. Does not change the input map, the filtered map is returned as output.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      map - input map to be filtered
      predicate - predicate for element comparison
      mergeFunction - function to resolve collisions between values associated with the same key
      Returns:
      map such that every element comforms with the predicate