Class RankableObjectWithFields

    • Constructor Detail

      • RankableObjectWithFields

        public RankableObjectWithFields​(Object obj,
                                        long count,
                                        Object... otherFields)
    • Method Detail

      • from

        public static RankableObjectWithFields from​(Tuple tuple)
        Construct a new instance based on the provided Tuple.

        This method expects the object to be ranked in the first field (index 0) of the provided tuple, and the number of occurrences of the object (its count) in the second field (index 1). Any further fields in the tuple will be extracted and tracked, too. These fields can be accessed via getFields().

        Parameters:
        tuple -
        Returns:
        new instance based on the provided tuple
      • getCount

        public long getCount()
        Specified by:
        getCount in interface Rankable
      • getFields

        public List<Object> getFields()
        Get fields.
        Returns:
        an immutable list of any additional data fields of the object (may be empty but will never be null)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • copy

        public Rankable copy()
        Note: We do not defensively copy the wrapped object and any accompanying fields. We do guarantee, however, do return a defensive (shallow) copy of the List object that is wrapping any accompanying fields.
        Specified by:
        copy in interface Rankable
        Returns:
        a defensive copy