Class QueryParameter


  • public class QueryParameter
    extends Object
    Holds information (name, type and value) about a single parameter to a query.
    Version:
    2.9
    Author:
    Nicklas
    Last modified
    $Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
    • Field Detail

      • name

        private final String name
      • permanent

        private final boolean permanent
      • type

        private Type type
      • itemType

        private Item itemType
    • Constructor Detail

      • QueryParameter

        public QueryParameter​(String name)
        Create a new empty non-permanent query parameter.
        Parameters:
        name - The name of the parameter
      • QueryParameter

        public QueryParameter​(String name,
                              boolean permanent,
                              Type type,
                              Object value)
        Create a new query parameter.
        Parameters:
        name - The name of the parameter
        permanent - If the parameter should be permanent or not. A permanent parameter can't change it's value
        type - The type of value
        value - The value
    • Method Detail

      • getName

        public String getName()
        Get the name of the parameter.
      • isPermanent

        public boolean isPermanent()
        Check if the parameter is a permanent parameter. A permanent paramer can't be changed.
      • getType

        public Type getType()
        Get the type of the parameter.
      • setType

        public void setType​(Type type)
        Changes the type of the parameter. Ignored if the parameter is permanent. Also sets the getItemType() value to null.
        Parameters:
        type - The new type
      • getValue

        public Object getValue()
        Get the value of the parameter.
      • setValue

        public void setValue​(Object value)
        Change the value of the parameter. Ignored if the parameter is permanent.
        Parameters:
        value - The new value
      • getItemType

        public Item getItemType()
        The parameter should be an entity of the given item type.
        Returns:
        An Item object or null
        Since:
        2.17
      • setItemType

        public void setItemType​(Item itemType)
        Changes the type of the parameter. Ignored if the parameter is permanent. Also sets the getType() value to null.
        Parameters:
        itemType - The new type
        Since:
        2.17
      • validateValue

        public void validateValue()
        Validate the parameter value using the type information if it has been provided. Null values are always accepted. If no type or item type has been set the value is also always accepted. The value can be either a single value or a collection of values. If a type has been set the value is validated with Type.isCorrectType(Object). If an item type has been set it is checked that the value is an instance of the given item type.
        Since:
        2.17
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object