@Shareable @DefaultNull public final class PreferenceDomain extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Constructor and Description |
---|
PreferenceDomain(double min,
double max)
Create a continuous bounded preference domain.
|
PreferenceDomain(double min,
double max,
double prec)
Create a discrete bounded preference domain.
|
Modifier and Type | Method and Description |
---|---|
double |
clampValue(double v)
Clamp a value to this preference domain.
|
void |
clampVector(MutableSparseVector vec) |
boolean |
equals(Object o) |
static PreferenceDomain |
fromString(String spec)
Parse a preference domain from a string specification.
|
double |
getMaximum()
The maximum preference value.
|
double |
getMinimum()
The minimum preference value.
|
double |
getPrecision()
The precision of preference values.
|
int |
hashCode() |
boolean |
hasPrecision()
Query whether this preference domain has a precision.
|
static PreferenceDomainBuilder |
newBuilder()
Create a new preference domain builder.
|
String |
toString() |
public static final long serialVersionUID
public PreferenceDomain(double min, double max, double prec)
min
- The minimum preference value.max
- The maximum preference value.prec
- The preference precision (if 0 or Double.NaN
, the domain
is continuous).public PreferenceDomain(double min, double max)
min
- The minimum preference value.max
- The maximum preference value.public double getMinimum()
public double getMaximum()
public boolean hasPrecision()
true
if the domain has a precision for discrete rating values, false
if it is continuous.public double getPrecision()
hasPrecision()
public double clampValue(double v)
v
- The value to clamp.public void clampVector(MutableSparseVector vec)
@Nonnull public static PreferenceDomain fromString(@Nonnull String spec)
Continuous preference domains are specified as [min, max]
; discrete domains
as min:max[/prec/
. For example, a 0.5-5.0 half-star rating scale is represented
as [0.5, 5.0]/0.5
.
spec
- The string specifying the preference domain.spec
.IllegalArgumentException
- if spec
is not a valid domain specification.public static PreferenceDomainBuilder newBuilder()