MapFilter

See javadoc - uk.gov.gchq.koryphe.impl.function.MapFilter

Available since Koryphe version 1.6.0

A Function which applies the given predicates to the keys and/or values

Examples

Filter on keys

MapFilter with key predicate

Java
JSON
Full JSON
Python
final MapFilter keyFilter = new MapFilter().keyPredicate(
        new StringContains("a")
);
{
  "class" : "MapFilter",
  "keyPredicate" : {
    "class" : "StringContains",
    "value" : "a",
    "ignoreCase" : false
  }
}
{
  "class" : "uk.gov.gchq.koryphe.impl.function.MapFilter",
  "keyPredicate" : {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.StringContains",
    "value" : "a",
    "ignoreCase" : false
  }
}
g.MapFilter( 
  key_predicate=g.StringContains( 
    value="a", 
    ignore_case=False 
  ) 
)

Input type:

java.util.Map

Example inputs:

Input TypeInputResult TypeResult
java.util.HashMap{giraffe=0, cat=3, dog=2}java.util.HashMap{giraffe=0, cat=3}

Filter on values

MapFilter with value predicate

Java
JSON
Full JSON
Python
final MapFilter valueFilter = new MapFilter().valuePredicate(
        new IsMoreThan(10)
);
{
  "class" : "MapFilter",
  "valuePredicate" : {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : 10
  }
}
{
  "class" : "uk.gov.gchq.koryphe.impl.function.MapFilter",
  "valuePredicate" : {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan",
    "orEqualTo" : false,
    "value" : 10
  }
}
g.MapFilter( 
  value_predicate=g.IsMoreThan( 
    value=10, 
    or_equal_to=False 
  ) 
)

Input type:

java.util.Map

Example inputs:

Input TypeInputResult TypeResult
java.util.HashMap{Pizza=30, Casserole=4, Steak=12}java.util.HashMap{Pizza=30, Steak=12}

Filter on both

MapFilter with key-value Predicate

Java
JSON
Full JSON
Python
final MapFilter keyValueFilter = new MapFilter()
        .keyValuePredicate(new AreEqual());
{
  "class" : "MapFilter",
  "keyValuePredicate" : {
    "class" : "AreEqual"
  }
}
{
  "class" : "uk.gov.gchq.koryphe.impl.function.MapFilter",
  "keyValuePredicate" : {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.AreEqual"
  }
}
g.MapFilter( 
  key_value_predicate=g.AreEqual() 
)

Input type:

java.util.Map

Example inputs:

Input TypeInputResult TypeResult
java.util.HashMap{1=2, 3=3, 6=4}java.util.HashMap{3=3}

results matching ""

    No results matching ""