@BuiltBy(value=RatingBuilder.class) @DefaultEntityType(value="rating") public class Rating extends AbstractBeanEntity implements Preference, java.io.Serializable
A user rating an item. A rating is an expression of preference, in the form of a real-valued rating, for an item by a user. Ratings are also used to represent un-rate events, if the system supports them; these are represented by a rating value of Double.NaN
.
To create a rating, use RatingBuilder
. The newBuilder()
method will create a rating builder.
Modifier and Type | Class and Description |
---|---|
static class |
Rating.WithTimestamp |
AbstractBeanEntity.BeanAttributeGetter, AbstractBeanEntity.BeanEntityLayout
Modifier and Type | Field and Description |
---|---|
static AttributeSet |
ATTRIBUTES |
static EntityType |
ENTITY_TYPE |
id, type
Modifier and Type | Method and Description |
---|---|
RatingBuilder |
copyBuilder()
Create a new rating builder that will build a copy of this rating.
|
static Rating |
create(long uid,
long iid,
double rating)
Deprecated.
|
static Rating |
create(long uid,
long iid,
double rating,
long ts)
Deprecated.
|
boolean |
equals(java.lang.Object obj) |
long |
getItemId()
Get the ID of the item the preference is for.
|
long |
getTimestamp() |
long |
getUserId()
Get the ID of the user whose preference this is.
|
double |
getValue()
Get the rating value.
|
static RatingBuilder |
newBuilder()
Create a new rating builder.
|
getAttributeNames, getAttributes, getBoolean, getDouble, getInteger, getLong, getTypedAttributeNames, hasAttribute, hasAttribute, makeLayout, maybeGet, maybeGet
asMap, describeTo, get, get, getId, getType, hashCode, toString
public static final EntityType ENTITY_TYPE
public static final AttributeSet ATTRIBUTES
@Deprecated public static Rating create(long uid, long iid, double rating)
EntityFactory.rating(long, long, double)
Create a new rating object with no timestamp.
uid
- The user ID.iid
- The item ID.rating
- The rating value. Cannot be NaN.create(long, long, double, long)
@Deprecated public static Rating create(long uid, long iid, double rating, long ts)
EntityFactory.rating(long, long, double, long)
Create a new rating object.
uid
- The user ID.iid
- The item ID.rating
- The rating value. Cannot be NaN.ts
- The timestamp.java.lang.IllegalArgumentException
- if rating
is NaN.public static RatingBuilder newBuilder()
Create a new rating builder.
@EntityAttribute(value="user") public long getUserId()
Preference
Get the ID of the user whose preference this is.
getUserId
in interface Preference
@EntityAttribute(value="item") public long getItemId()
Preference
Get the ID of the item the preference is for.
getItemId
in interface Preference
public long getTimestamp()
@EntityAttribute(value="rating") public double getValue()
Get the rating value.
getValue
in interface Preference
Double.NaN
if the rating has no value.public RatingBuilder copyBuilder()
Create a new rating builder that will build a copy of this rating.
public boolean equals(java.lang.Object obj)
equals
in class AbstractEntity