Package com.yahoo.search.query.profile
Class DimensionValues
- java.lang.Object
-
- com.yahoo.search.query.profile.DimensionValues
-
- All Implemented Interfaces:
java.lang.Comparable<DimensionValues>
public class DimensionValues extends java.lang.Object implements java.lang.Comparable<DimensionValues>
An immutable set of dimension values. Note that this may contain more or fewer values than needed given a set of dimensions. Any missing values are treated as null.- Author:
- bratseth
-
-
Field Summary
Fields Modifier and Type Field Description static DimensionValues
empty
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>
asContext(java.util.List<java.lang.String> dimensions)
int
compareTo(DimensionValues other)
Implements the sort order of this which is based on specificity where dimensions to the left are more significant: -1 is returned if this is more specific than other, 1 is returned if other is more specific than this, 0 is returned if none is more specific than the other.static DimensionValues
createFrom(java.lang.String[] values)
boolean
equals(java.lang.Object o)
java.lang.String
get(int index)
Returns the string at the given index, or null if it has no value at this indexjava.lang.String[]
getValues()
Returns a copy of the values in this in an arrayint
hashCode()
boolean
isEmpty()
boolean
isMoreSpecificThan(DimensionValues other)
Helper method which uses compareTo to return whether this is most specificboolean
matches(DimensionValues givenValues)
Returns true if this is has the same value every place it has a value as the given values.int
size()
Returns the number of values in this (some of which may be null)java.lang.String
toString()
-
-
-
Field Detail
-
empty
public static final DimensionValues empty
-
-
Method Detail
-
createFrom
public static DimensionValues createFrom(java.lang.String[] values)
-
matches
public boolean matches(DimensionValues givenValues)
Returns true if this is has the same value every place it has a value as the given values.
-
compareTo
public int compareTo(DimensionValues other)
Implements the sort order of this which is based on specificity where dimensions to the left are more significant: -1 is returned if this is more specific than other, 1 is returned if other is more specific than this, 0 is returned if none is more specific than the other.Note: This ordering is not consistent with equals - it returns 0 when the same dimensions are set, regardless of what they are set to.
- Specified by:
compareTo
in interfacejava.lang.Comparable<DimensionValues>
-
isMoreSpecificThan
public boolean isMoreSpecificThan(DimensionValues other)
Helper method which uses compareTo to return whether this is most specific
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isEmpty
public boolean isEmpty()
-
asContext
public java.util.Map<java.lang.String,java.lang.String> asContext(java.util.List<java.lang.String> dimensions)
-
get
public java.lang.String get(int index)
Returns the string at the given index, or null if it has no value at this index
-
size
public int size()
Returns the number of values in this (some of which may be null)
-
getValues
public java.lang.String[] getValues()
Returns a copy of the values in this in an array
-
-