Class ParameterizedQuery

  • All Implemented Interfaces:
    Queryable, BsonParcelable

    public class ParameterizedQuery
    extends java.lang.Object
    implements Queryable
    This class contains a query instance to evaluate using the parameters associated to this instance.
    Author:
    javaito
    • Constructor Detail

      • ParameterizedQuery

        public ParameterizedQuery​(Query query)
    • Method Detail

      • getResourceName

        public java.lang.String getResourceName()
        Description copied from interface: Queryable
        Return the resource name.
        Specified by:
        getResourceName in interface Queryable
        Returns:
        Resource name.
      • add

        public final ParameterizedQuery add​(java.lang.Object parameter)
        Add new parameter into the next place.
        Parameters:
        parameter - Parameter to add.
        Returns:
        Returns this instance.
      • set

        public final ParameterizedQuery set​(java.lang.Integer place,
                                            java.lang.Object parameter)
        Add a new parameter in the specific place, if exists a parameter in the indicated place then this parameter is replaced.
        Parameters:
        place - Place to add the parameter.
        parameter - Parameter to add.
        Returns:
        Returns this instance.
      • getParameters

        public java.util.List<java.lang.Object> getParameters()
        Returns a list of parameters into the queryable.
        Returns:
        Unmodifiable list of parameters.
      • getQuery

        public Query getQuery()
        Returns the query associated to the instance.
        Returns:
        Query instance.
      • evaluate

        public final <O> java.util.Collection<O> evaluate​(java.util.Collection<O> dataSource)
        This method evaluate each object of the collection and sort filtered object to create a result add with the object filtered and sorted. If there are order fields added then the result implementation is a TreeSet implementation else the result implementation is a LinkedHashSet implementation in order to guarantee the data order from the source
        Specified by:
        evaluate in interface Queryable
        Type Parameters:
        O - Kind of instances of the data collection.
        Parameters:
        dataSource - Data source to evaluate the query.
        Returns:
        Result add filtered and sorted.
      • evaluate

        public final <O> java.util.Collection<O> evaluate​(java.util.Collection<O> dataSource,
                                                          Queryable.Consumer<O> consumer)
        This method evaluate each object of the collection and sort filtered object to create a result add with the object filtered and sorted. If there are order fields added then the result implementation is a TreeSet implementation else the result implementation is a LinkedHashSet implementation in order to guarantee the data order from the source
        Specified by:
        evaluate in interface Queryable
        Type Parameters:
        O - Kind of instances of the data collection.
        Parameters:
        dataSource - Data source to evaluate the query.
        consumer - Data source consumer.
        Returns:
        Result add filtered and sorted.
      • evaluate

        public final <O> java.util.Collection<O> evaluate​(Queryable.DataSource<O> dataSource)
        This method evaluate each object of the collection and sort filtered object to create a result add with the object filtered and sorted. If there are order fields added then the result implementation is a TreeSet implementation else the result implementation is a LinkedHashSet implementation in order to guarantee the data order from the source
        Specified by:
        evaluate in interface Queryable
        Type Parameters:
        O - Kind of instances of the data collection.
        Parameters:
        dataSource - Data source to evaluate the query.
        Returns:
        Result add filtered and sorted.
      • evaluate

        public final <O> java.util.Collection<O> evaluate​(Queryable.DataSource<O> dataSource,
                                                          Queryable.Consumer<O> consumer)
        This method evaluate each object of the collection and sort filtered object to create a result add with the object filtered and sorted. If there are order fields added then the result implementation is a TreeSet implementation else the result implementation is a LinkedHashSet implementation in order to guarantee the data order from the source
        Specified by:
        evaluate in interface Queryable
        Type Parameters:
        O - Kind of instances of the data collection.
        Parameters:
        dataSource - Data source to evaluate the query.
        consumer - Data source consumer.
        Returns:
        Result add filtered and sorted.
      • toBson

        public org.hcjf.bson.BsonDocument toBson()
        Description copied from interface: BsonParcelable
        Returns the bson representation of the instance.
        Specified by:
        toBson in interface BsonParcelable
        Returns:
        Bson representation.
      • populate

        public <P extends BsonParcelable> P populate​(org.hcjf.bson.BsonDocument document)
        Description copied from interface: BsonParcelable
        Populate the current instance of parcelable with all the information into the bson document.
        Specified by:
        populate in interface BsonParcelable
        Type Parameters:
        P - Expected parcelable type.
        Parameters:
        document - Bson document to populate the parcelable.
        Returns:
        Return the same instance that was populated.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object