Class QueryProfileVariants

  • All Implemented Interfaces:
    com.yahoo.component.provider.Freezable, Cloneable

    public class QueryProfileVariants
    extends Object
    implements com.yahoo.component.provider.Freezable, Cloneable
    This class represent a set of query profiles virtually - rather than storing and instantiating each profile this structure represents explicitly only the values set in the various virtual profiles. The set of virtual profiles are defined by a set of dimensions. Values may be set for any point in this multi-dimensional space, and may also be set for any regular hyper-region by setting values for any point in certain of these dimensions. The set of virtual profiles defined by this consists of all the combinations of dimension points for which one or more values is set in this, as well as any possible less specified regions.

    A set of virtual profiles are always owned by a single profile, which is also their parent in the inheritance hierarchy.

    Author:
    bratseth
    • Constructor Detail

      • QueryProfileVariants

        public QueryProfileVariants​(String[] dimensions,
                                    QueryProfile owner)
        Creates a set of virtual query profiles which may return varying values over the set of dimensions given. Each dimension is a name for which a key-value may be supplied in the context properties on lookup time to influence the value returned.
      • QueryProfileVariants

        public QueryProfileVariants​(List<String> dimensions,
                                    QueryProfile owner)
        Creates a set of virtual query profiles which may return varying values over the set of dimensions given. Each dimension is a name for which a key-value may be supplied in the context properties on lookup time to influence the value returned.
        Parameters:
        dimensions - the dimension names this may vary over. The list gets owned by this, so it must not be further modified from outside). This will not modify the list.
    • Method Detail

      • freeze

        public void freeze()
        Irreversibly prevents any further modifications to this
        Specified by:
        freeze in interface com.yahoo.component.provider.Freezable
      • isFrozen

        public boolean isFrozen()
        Specified by:
        isFrozen in interface com.yahoo.component.provider.Freezable
      • get

        public Object get​(String name,
                          QueryProfileType type,
                          boolean allowQueryProfileResult,
                          DimensionBinding dimensionBinding)
        Returns the most specific matching value of a name for a given set of canonical dimension values.
        Parameters:
        name - the name to return the best matching value of
        dimensionBinding - the dimension bindings to use in this
      • inherit

        public void inherit​(QueryProfile profile,
                            DimensionValues dimensionValues)
        Inherits a particular profile in a variant of this
      • set

        public void set​(String fieldName,
                        DimensionValues dimensionValues,
                        Object value)
        Sets a value to this
        Parameters:
        fieldName - the name of the field to set. This cannot be a compound (dotted) name
        dimensionValues - the dimension values for which this value applies
        value - the value to set
      • setOverridable

        public void setOverridable​(String fieldName,
                                   boolean overridable,
                                   DimensionValues dimensionValues)
        Makes a value unoverridable in a given context.
      • getDimensions

        public List<String> getDimensions()
        Returns the dimensions over which the virtual profiles in this may return different values. Each dimension is a name for which a key-value may be supplied in the context properties on lookup time to influence the value returned. The dimensions may not be modified - the returned list is always read only.
      • getVariants

        public List<QueryProfileVariant> getVariants()
        Returns all the variants of this, sorted by specificity. This is content as declared. The returned list is always unmodifiable.
      • ensureNotFrozen

        protected void ensureNotFrozen()
        Throws an IllegalStateException if this is frozen
      • getVariant

        public QueryProfileVariant getVariant​(DimensionValues dimensionValues,
                                              boolean create)
        Returns the query profile variant having exactly the given dimensions, and creates it if create is set and it is missing
        Parameters:
        dimensionValues - the dimension values
        create - whether or not to create the variant if missing
        Returns:
        the profile variant, or null if not found and create is false