Class FacetBuckets

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<FacetBucket>, java.util.function.Consumer<FacetBucket>
    Direct Known Subclasses:
    FacetResponse

    public class FacetBuckets
    extends java.lang.Object
    implements java.util.function.Consumer<FacetBucket>, java.io.Externalizable, java.lang.Cloneable, java.lang.Iterable<FacetBucket>
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      FacetBuckets()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void accept​(FacetBucket bucket)
      Consumer implementation that adds all consumed buckets.
      void add​(FacetBucket bucket)
      Add a bucket.
      void addAll​(java.lang.Iterable<FacetBucket> value)
      Add all buckets in value.
      protected static java.lang.StringBuilder addAttribute​(java.lang.StringBuilder buffer, java.lang.String name, long value)  
      protected static java.lang.StringBuilder addAttribute​(java.lang.StringBuilder buffer, java.lang.String name, java.lang.Object value)  
      protected static java.lang.StringBuilder addAttribute​(java.lang.StringBuilder buffer, java.util.Map.Entry<java.lang.String,​java.lang.Object> entry)  
      void addAttributes​(java.lang.Iterable<java.util.Map.Entry<java.lang.String,​java.lang.Object>> value)
      Add all attributes in value.
      protected void addAttributes​(java.lang.StringBuilder buffer)  
      java.lang.Iterable<java.util.Map.Entry<java.lang.String,​java.lang.Object>> attributes()  
      void clear()
      Remove all buckets from this response.
      FacetBuckets clone()  
      protected static java.lang.Object coerce​(java.lang.Number value)  
      protected static java.lang.Object coerce​(java.lang.Object value)  
      boolean contains​(java.util.function.Predicate<FacetBucket> predicate)
      Returns true if a bucket matching predicate exists.
      boolean containsBucket​(java.lang.String label)
      Returns true if a bucket with the given label exists..
      void ensureCapacity​(int capacity)
      Ensure capacity of buckets without additional reallocation.
      boolean equals​(java.lang.Object other)
      void forEach​(java.util.function.Consumer<? super FacetBucket> consumer)  
      FacetBucket get​(int index)
      Get the FacetBucket at index.
      java.lang.Object getAttribute​(java.lang.String name)
      Get an attribute by name.
      boolean getAttribute​(java.lang.String name, boolean defaultValue)
      Get a boolean attribute by name, returning defaultValue if unset.
      double getAttribute​(java.lang.String name, double defaultValue)
      Get a double attribute by name, returning defaultValue if unset.
      int getAttribute​(java.lang.String name, int defaultValue)
      Get an int attribute by name, returning defaultValue if unset.
      long getAttribute​(java.lang.String name, long defaultValue)
      Get a long attribute by name, returning defaultValue if unset.
      java.lang.String getAttribute​(java.lang.String name, java.lang.String defaultValue)
      Get a String attribute by name, returning defaultValue if unset.
      java.util.Date getAttribute​(java.lang.String name, java.util.Date defaultValue)
      Get a Date attribute by name, returning defaultValue if unset.
      BaseTypesMap<java.lang.String,​java.lang.Object> getAttributes()
      Get extended attributes.
      FacetBucket getBucket​(java.lang.String label)
      Gets a Bucket with the given label.
      java.lang.String getDisplayName()
      Get the display name for the field that generated these buckets.
      java.lang.String getField()
      Get the field used to generate these buckets.
      protected java.lang.String getFilterField()
      Get the field to use for filtering buckets.
      java.lang.String getName()
      Get the name of the FacetRequest used to generate these buckets.
      FacetStatistics getStatistics()
      Get the statistics for this response.
      protected FacetStatistics getStatistics​(long defaultCount)
      Deecode FacetStatistics from attributes.
      int hashCode()  
      java.util.Iterator<FacetBucket> iterator()  
      void readExternal​(java.io.ObjectInput in)  
      void removeAttribute​(java.lang.String name)  
      FacetBucket removeLast()
      Remove and return the last FacetBucket.
      void setAttribute​(java.lang.String name, java.lang.Object value)  
      void setAttributes​(java.util.Map<java.lang.String,​java.lang.Object> value)
      Set extended attributes.
      void setDisplayName​(java.lang.String value)
      Set the display name for the field that generated these buckets.
      void setField​(java.lang.String value)
      Set the field used to generate these buckets.
      void setName​(java.lang.String value)
      Set the name of the FacetRequest used to generate these buckets.
      void setStatistics​(FacetStatistics value)  
      int size()
      Get the number of buckets.
      void sort​(java.util.Comparator<FacetBucket> c)
      Sort the buckets according to c.
      java.lang.String toString()
      void writeExternal​(java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.function.Consumer

        andThen
      • Methods inherited from interface java.lang.Iterable

        spliterator
    • Constructor Detail

      • FacetBuckets

        public FacetBuckets()
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name of the FacetRequest used to generate these buckets.
      • setName

        public void setName​(java.lang.String value)
        Set the name of the FacetRequest used to generate these buckets.
      • getField

        public java.lang.String getField()
        Get the field used to generate these buckets.
      • setField

        public void setField​(java.lang.String value)
        Set the field used to generate these buckets.
      • getFilterField

        protected java.lang.String getFilterField()
        Get the field to use for filtering buckets.
      • getDisplayName

        public java.lang.String getDisplayName()
        Get the display name for the field that generated these buckets.
      • setDisplayName

        public void setDisplayName​(java.lang.String value)
        Set the display name for the field that generated these buckets.
      • get

        public FacetBucket get​(int index)
        Get the FacetBucket at index.
      • iterator

        public java.util.Iterator<FacetBucket> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<FacetBucket>
      • forEach

        public void forEach​(java.util.function.Consumer<? super FacetBucket> consumer)
        Specified by:
        forEach in interface java.lang.Iterable<FacetBucket>
      • contains

        public boolean contains​(java.util.function.Predicate<FacetBucket> predicate)
        Returns true if a bucket matching predicate exists.
      • add

        public void add​(FacetBucket bucket)
        Add a bucket.
      • addAll

        public void addAll​(java.lang.Iterable<FacetBucket> value)
        Add all buckets in value.
      • accept

        public void accept​(FacetBucket bucket)
        Consumer implementation that adds all consumed buckets.
        Specified by:
        accept in interface java.util.function.Consumer<FacetBucket>
      • ensureCapacity

        public void ensureCapacity​(int capacity)
        Ensure capacity of buckets without additional reallocation.
      • sort

        public void sort​(java.util.Comparator<FacetBucket> c)
        Sort the buckets according to c.
      • clear

        public void clear()
        Remove all buckets from this response.
      • containsBucket

        public boolean containsBucket​(java.lang.String label)
        Returns true if a bucket with the given label exists..

        Warning: this method performs a linear scan of all buckets and may require generating display values for all buckets during scan.

      • getBucket

        public FacetBucket getBucket​(java.lang.String label)
        Gets a Bucket with the given label.

        Warning: this method performs a linear scan of all buckets and may require generating display values for all buckets during scan.

      • size

        public int size()
        Get the number of buckets.
      • attributes

        public java.lang.Iterable<java.util.Map.Entry<java.lang.String,​java.lang.Object>> attributes()
      • getStatistics

        public FacetStatistics getStatistics()
        Get the statistics for this response.
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Get an attribute by name.
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String name,
                                             java.lang.String defaultValue)
        Get a String attribute by name, returning defaultValue if unset.
      • getAttribute

        public boolean getAttribute​(java.lang.String name,
                                    boolean defaultValue)
        Get a boolean attribute by name, returning defaultValue if unset.
      • getAttribute

        public int getAttribute​(java.lang.String name,
                                int defaultValue)
        Get an int attribute by name, returning defaultValue if unset.
      • getAttribute

        public long getAttribute​(java.lang.String name,
                                 long defaultValue)
        Get a long attribute by name, returning defaultValue if unset.
      • getAttribute

        public double getAttribute​(java.lang.String name,
                                   double defaultValue)
        Get a double attribute by name, returning defaultValue if unset.
      • getAttribute

        public java.util.Date getAttribute​(java.lang.String name,
                                           java.util.Date defaultValue)
        Get a Date attribute by name, returning defaultValue if unset.
      • getAttributes

        public BaseTypesMap<java.lang.String,​java.lang.Object> getAttributes()
        Get extended attributes.
      • setAttributes

        public void setAttributes​(java.util.Map<java.lang.String,​java.lang.Object> value)
        Set extended attributes.
      • removeAttribute

        public void removeAttribute​(java.lang.String name)
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.Object value)
      • addAttributes

        public void addAttributes​(java.lang.Iterable<java.util.Map.Entry<java.lang.String,​java.lang.Object>> value)
        Add all attributes in value.

        Will replace any existing attributes with the same name.

      • coerce

        protected static java.lang.Object coerce​(java.lang.Object value)
      • coerce

        protected static java.lang.Object coerce​(java.lang.Number value)
      • clone

        public FacetBuckets clone()
        Overrides:
        clone in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • toString

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

        protected void addAttributes​(java.lang.StringBuilder buffer)
      • addAttribute

        protected static java.lang.StringBuilder addAttribute​(java.lang.StringBuilder buffer,
                                                              java.lang.String name,
                                                              long value)
      • addAttribute

        protected static java.lang.StringBuilder addAttribute​(java.lang.StringBuilder buffer,
                                                              java.util.Map.Entry<java.lang.String,​java.lang.Object> entry)
      • addAttribute

        protected static java.lang.StringBuilder addAttribute​(java.lang.StringBuilder buffer,
                                                              java.lang.String name,
                                                              java.lang.Object value)
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException