com.vaadin.shared.ui.dnd.criteria.
Class Criterion
- java.lang.Object
-
- com.vaadin.shared.ui.dnd.criteria.Criterion
-
All Implemented Interfaces:
public class Criterion extends Object implements Serializable
Stores parameters for the drag and drop acceptance criterion defined using the criteria API.
When data is dragged over a drop target, the value here is compared to the payload added in DropTargetExtension with same key and value type.
Since:
8.1
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
Criterion.Match
Declares whether all or any of the given criteria should match when compared against the payload.
-
Constructor Summary
Constructors Constructor and Description Criterion(String key, ComparisonOperator operator, double value)
Creates a criterion object.
Criterion(String key, ComparisonOperator operator, int value)
Creates a criterion object.
Criterion(String key, String value)
Creates a criterion object with the default comparison operator
ComparisonOperator.EQUALS
.
-
Method Summary
All Methods Modifier and Type Method and Description String
getKey()
Gets the key of the payload to be compared.
ComparisonOperator
getOperator()
Gets the comparison operator.
String
getValue()
Gets the value of the payload to be compared.
Payload.ValueType
getValueType()
Gets the type of the payload value to be compared.
boolean
resolve(Collection<Payload> payloadCollection)
Compares this criterion's value to the given payload's value and returns whether the result matches the criterion's operator.
-
-
-
Constructor Detail
-
Criterion
public Criterion(String key, String value)
Creates a criterion object with the default comparison operator
ComparisonOperator.EQUALS
.Parameters:
key
- key of the payload to be comparedvalue
- value of the payload to be compared
-
Criterion
public Criterion(String key, ComparisonOperator operator, int value)
Creates a criterion object.
Parameters:
key
- key of the payload to be comparedoperator
- comparison operatorvalue
- value of the payload to be compared
-
Criterion
public Criterion(String key, ComparisonOperator operator, double value)
Creates a criterion object.
Parameters:
key
- key of the payload to be comparedoperator
- comparison operatorvalue
- value of the payload to be compared
-
-
Method Detail
-
getKey
public String getKey()
Gets the key of the payload to be compared.
Returns:
key of the payload to be compared
-
getValue
public String getValue()
Gets the value of the payload to be compared.
Returns:
value of the payload to be compared
-
getValueType
public Payload.ValueType getValueType()
Gets the type of the payload value to be compared.
Returns:
type of the payload value to be compared
-
getOperator
public ComparisonOperator getOperator()
Gets the comparison operator.
Returns:
operator to be used when comparing payload value with criterion
-
resolve
public boolean resolve(Collection<Payload> payloadCollection)
Compares this criterion's value to the given payload's value and returns whether the result matches the criterion's operator. The comparison is done with the payload whose key and value type match the criterion's key and value type.
Parameters:
payloadCollection
- collection of payloads to compare the criterion againstReturns:
false
if there exists a payload in the collection with the same key and value type and it doesn't match the criterion,true
otherwise
-
-