Package com.yahoo.search.query.profile
Class DimensionBinding
- java.lang.Object
-
- com.yahoo.search.query.profile.DimensionBinding
-
public class DimensionBinding extends java.lang.Object
An immutable, binding of a list of dimensions to dimension values- Author:
- bratseth
-
-
Field Summary
Fields Modifier and Type Field Description static DimensionBinding
invalidBinding
static DimensionBinding
nullBinding
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DimensionBinding
combineWith(DimensionBinding other)
Combines this binding with another if compatible.DimensionBinding
createFor(java.util.List<java.lang.String> newDimensions)
Returns a binding for a (possibly) new set of variants.static DimensionBinding
createFrom(java.util.List<java.lang.String> dimensions, DimensionValues dimensionValues)
Creates a binding from a variant and a context.static DimensionBinding
createFrom(java.util.List<java.lang.String> dimensions, java.util.Map<java.lang.String,java.lang.String> context)
Creates a binding from a variant and a context.static DimensionBinding
createFrom(java.util.Map<java.lang.String,java.lang.String> values)
boolean
equals(java.lang.Object o)
Two bindings are equal if they contain the same dimensions and the same non-null valuesjava.util.Map<java.lang.String,java.lang.String>
getContext()
Returns a context created from the dimensions and values of thisjava.util.List<java.lang.String>
getDimensions()
Returns a read-only list of the dimensions of this.DimensionValues
getValues()
Returns the values for the dimensions of this.int
hashCode()
boolean
isInvalid()
Returns true if this == invalidBindingboolean
isNull()
Returns true only if this binding is null (contains no values for its dimensions (if any)java.lang.String
toString()
-
-
-
Field Detail
-
nullBinding
public static final DimensionBinding nullBinding
-
invalidBinding
public static final DimensionBinding invalidBinding
-
-
Method Detail
-
createFrom
public static DimensionBinding createFrom(java.util.Map<java.lang.String,java.lang.String> values)
-
createFrom
public static DimensionBinding createFrom(java.util.List<java.lang.String> dimensions, java.util.Map<java.lang.String,java.lang.String> context)
Creates a binding from a variant and a context. Any of the arguments may be null.
-
createFrom
public static DimensionBinding createFrom(java.util.List<java.lang.String> dimensions, DimensionValues dimensionValues)
Creates a binding from a variant and a context. Any of the arguments may be null.
-
createFor
public DimensionBinding createFor(java.util.List<java.lang.String> newDimensions)
Returns a binding for a (possibly) new set of variants. Variants may be null, but not bindings
-
getDimensions
public java.util.List<java.lang.String> getDimensions()
Returns a read-only list of the dimensions of this. This value is undefined if this isNull()
-
getContext
public java.util.Map<java.lang.String,java.lang.String> getContext()
Returns a context created from the dimensions and values of this
-
getValues
public DimensionValues getValues()
Returns the values for the dimensions of this. This value is undefined if this isEmpty() This array is always of the same length as the length of the dimension list - missing elements are represented as nulls. This is never null but may be empty.
-
isNull
public boolean isNull()
Returns true only if this binding is null (contains no values for its dimensions (if any)
-
combineWith
public DimensionBinding combineWith(DimensionBinding other)
Combines this binding with another if compatible. Two bindings are incompatible if- They contain a different value for the same key, or
- They contain the same pair of dimensions in a different order
- Returns:
- the combined binding, or the special invalidBinding if these two bindings are incompatible
-
isInvalid
public boolean isInvalid()
Returns true if this == invalidBinding
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Two bindings are equal if they contain the same dimensions and the same non-null values- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-