com.vaadin.shared.ui.dnd.criteria.

Class Criterion

  • All Implemented Interfaces:

    Serializable

    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:

    Serialized Form

    • 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 compared

        value - 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 compared

        operator - comparison operator

        value - 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 compared

        operator - comparison operator

        value - 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

      • setKey

        public void setKey​(String key)

        Sets the key of the payload to be compared.

        Parameters:

        key - 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

      • setValue

        public void setValue​(String value)

        Sets the value of the payload to be compared.

        Parameters:

        value - 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

      • setValueType

        public void setValueType​(Payload.ValueType valueType)

        Sets the type of the payload value to be compared.

        Parameters:

        valueType - type of the payload to be compared

      • getOperator

        public ComparisonOperator getOperator()

        Gets the comparison operator.

        Returns:

        operator to be used when comparing payload value with criterion

      • setOperator

        public void setOperator​(ComparisonOperator operator)

        Sets the comparison operator.

        Parameters:

        operator - comparison operator

      • 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 against

        Returns:

        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