Class ConditionFactory.KeyCondition
- java.lang.Object
-
- org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.KeyCondition
-
- All Implemented Interfaces:
Condition,Condition.TagCondition
- Enclosing class:
- ConditionFactory
public static class ConditionFactory.KeyCondition extends java.lang.Object implements Condition.TagCondition
KeyCondition represent one of the following conditions in either the link or the primitive context:
["a label"] PRIMITIVE: the primitive has a tag "a label" LINK: the parent is a relation and it has at least one member with the role "a label" referring to the child [!"a label"] PRIMITIVE: the primitive doesn't have a tag "a label" LINK: the parent is a relation but doesn't have a member with the role "a label" referring to the child ["a label"?] PRIMITIVE: the primitive has a tag "a label" whose value evaluates to a true-value LINK: not supported ["a label"?!] PRIMITIVE: the primitive has a tag "a label" whose value evaluates to a false-value LINK: not supported- See Also:
ConditionFactory.KeyRegexpCondition
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.mappaint.mapcss.Condition
Condition.Context, Condition.TagCondition
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringlabelThe key name.ConditionFactory.KeyMatchTypematchTypeDescribes how to match the label against the key.booleannegateResultIf we should negate the result of the match.
-
Constructor Summary
Constructors Constructor Description KeyCondition(java.lang.String label, boolean negateResult, ConditionFactory.KeyMatchType matchType)Creates a new KeyCondition
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplies(Tagged osm)Checks if the condition applies in the givenTaggedelement.TagasTag(Tagged p)Get the matched key and the corresponding value.private java.util.function.Predicate<java.lang.String>keyPredicate()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.gui.mappaint.mapcss.Condition.TagCondition
applies
-
-
-
-
Field Detail
-
label
public final java.lang.String label
The key name.
-
negateResult
public final boolean negateResult
If we should negate the result of the match.
-
matchType
public final ConditionFactory.KeyMatchType matchType
Describes how to match the label against the key.- See Also:
ConditionFactory.KeyMatchType
-
-
Constructor Detail
-
KeyCondition
public KeyCondition(java.lang.String label, boolean negateResult, ConditionFactory.KeyMatchType matchType)
Creates a new KeyCondition- Parameters:
label- The key name (or regexp) to use.negateResult- If we should negate the result.,matchType- The match type.
-
-
Method Detail
-
applies
public boolean applies(Tagged osm)
Description copied from interface:ConditionChecks if the condition applies in the givenTaggedelement.- Specified by:
appliesin interfaceCondition- Specified by:
appliesin interfaceCondition.TagCondition- Parameters:
osm- The tagged to check.- Returns:
trueif the condition applies.
-
keyPredicate
private java.util.function.Predicate<java.lang.String> keyPredicate()
-
asTag
public Tag asTag(Tagged p)
Get the matched key and the corresponding value.WARNING: This ignores
negateResult.- Specified by:
asTagin interfaceCondition.TagCondition- Parameters:
p- The primitive to get the value from.- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-