Class MultiValueResolutionDecision
- java.lang.Object
-
- org.openstreetmap.josm.gui.conflict.tags.MultiValueResolutionDecision
-
public class MultiValueResolutionDecision extends Object
Represents a decision for a conflict due to multiple possible value for a tag.- Since:
- 2008
-
-
Field Summary
Fields Modifier and Type Field Description private static String[]
SUMMABLE_KEYS
private TagCollection
tags
the collection of tags for which a decision is neededprivate MultiValueDecisionType
type
the type of decisionprivate String
value
the selected value iftype
isMultiValueDecisionType.KEEP_ONE
-
Constructor Summary
Constructors Constructor Description MultiValueResolutionDecision()
constructorMultiValueResolutionDecision(TagCollection tags)
Creates a new decision for the tag collectiontags
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyTo(Collection<? extends OsmPrimitive> primitives)
Applies this resolution to a collection of primitivesvoid
applyTo(OsmPrimitive primitive)
Applies the resolution to anOsmPrimitive
protected void
autoDecide()
Tries to find the best decision based on the current values.Command
buildChangeCommand(Collection<? extends OsmPrimitive> primitives)
Builds a change command for applying this resolution to a collection of primitivesCommand
buildChangeCommand(OsmPrimitive primitive)
Builds a change command for applying this resolution to a primitiveboolean
canKeepAll()
Replies true, if this resolution has more than 1 possible non-empty valuesboolean
canKeepNone()
Replies true if the empty value is a possible value in this resolutionboolean
canSumAllNumeric()
Replies true, if summing all numeric values is a possible value in this resolutionString
getChosenValue()
Replies the chosen valueMultiValueDecisionType
getDecisionType()
Replies the type of the resolutionString
getKey()
Replies the key of the tag to be resolved by this resolutionTag
getResolution()
Replies a tag representing the current resolution.List<String>
getValues()
Replies the list of possible, non empty valuesboolean
isDecided()
Replies true if this resolution is decidedvoid
keepAll()
Apply the decision to keep all valuesvoid
keepNone()
Apply the decision to keep no valuevoid
keepOne(String value)
Apply the decision to keep exactly one valuevoid
setNew(String value)
sets a new value for thisvoid
sumAllNumeric()
Apply the decision to sum all numeric valuesvoid
undecide()
marks this as undecided
-
-
-
Field Detail
-
type
private MultiValueDecisionType type
the type of decision
-
tags
private final TagCollection tags
the collection of tags for which a decision is needed
-
value
private String value
the selected value iftype
isMultiValueDecisionType.KEEP_ONE
-
SUMMABLE_KEYS
private static final String[] SUMMABLE_KEYS
-
-
Constructor Detail
-
MultiValueResolutionDecision
public MultiValueResolutionDecision()
constructor
-
MultiValueResolutionDecision
public MultiValueResolutionDecision(TagCollection tags)
Creates a new decision for the tag collectiontags
. All tags must have the same key.- Parameters:
tags
- the tags. Must not be null.- Throws:
IllegalArgumentException
- if tags is nullIllegalArgumentException
- if there are more than one keysIllegalArgumentException
- if tags is empty
-
-
Method Detail
-
autoDecide
protected final void autoDecide()
Tries to find the best decision based on the current values.
-
keepNone
public void keepNone()
Apply the decision to keep no value
-
keepAll
public void keepAll()
Apply the decision to keep all values
-
sumAllNumeric
public void sumAllNumeric()
Apply the decision to sum all numeric values- Since:
- 7743
-
keepOne
public void keepOne(String value)
Apply the decision to keep exactly one value- Parameters:
value
- the value to keep- Throws:
IllegalArgumentException
- if value is nullIllegalStateException
- if value is not in the list of known values for this tag
-
setNew
public void setNew(String value)
sets a new value for this- Parameters:
value
- the new value
-
undecide
public void undecide()
marks this as undecided
-
getChosenValue
public String getChosenValue()
Replies the chosen value- Returns:
- the chosen value
- Throws:
IllegalStateException
- if this resolution is not yet decided
-
getValues
public List<String> getValues()
Replies the list of possible, non empty values- Returns:
- the list of possible, non empty values
-
getKey
public String getKey()
Replies the key of the tag to be resolved by this resolution- Returns:
- the key of the tag to be resolved by this resolution
-
canKeepNone
public boolean canKeepNone()
Replies true if the empty value is a possible value in this resolution- Returns:
- true if the empty value is a possible value in this resolution
-
canKeepAll
public boolean canKeepAll()
Replies true, if this resolution has more than 1 possible non-empty values- Returns:
- true, if this resolution has more than 1 possible non-empty values
-
canSumAllNumeric
public boolean canSumAllNumeric()
Replies true, if summing all numeric values is a possible value in this resolution- Returns:
- true, if summing all numeric values is a possible value in this resolution
- Since:
- 7743
-
isDecided
public boolean isDecided()
Replies true if this resolution is decided- Returns:
- true if this resolution is decided
-
getDecisionType
public MultiValueDecisionType getDecisionType()
Replies the type of the resolution- Returns:
- the type of the resolution
-
applyTo
public void applyTo(OsmPrimitive primitive)
Applies the resolution to anOsmPrimitive
- Parameters:
primitive
- the primitive- Throws:
IllegalStateException
- if this resolution is not resolved yet
-
applyTo
public void applyTo(Collection<? extends OsmPrimitive> primitives)
Applies this resolution to a collection of primitives- Parameters:
primitives
- the collection of primitives- Throws:
IllegalStateException
- if this resolution is not resolved yet
-
buildChangeCommand
public Command buildChangeCommand(OsmPrimitive primitive)
Builds a change command for applying this resolution to a primitive- Parameters:
primitive
- the primitive- Returns:
- the change command
- Throws:
IllegalArgumentException
- if primitive is nullIllegalStateException
- if this resolution is not resolved yet
-
buildChangeCommand
public Command buildChangeCommand(Collection<? extends OsmPrimitive> primitives)
Builds a change command for applying this resolution to a collection of primitives- Parameters:
primitives
- the collection of primitives- Returns:
- the change command
- Throws:
IllegalArgumentException
- if primitives is nullIllegalStateException
- if this resolution is not resolved yet
-
getResolution
public Tag getResolution()
Replies a tag representing the current resolution. Null, if this resolution is not resolved yet.- Returns:
- a tag representing the current resolution. Null, if this resolution is not resolved yet
-
-