StarRating

Added in 1.0.0
Deprecated in 1.3.0

public final class StarRating implements Rating


A class for rating expressed as the number of stars.

Summary

Public constructors

StarRating(@IntRange(from = 1) int maxStars)

Creates a unrated StarRating instance with maxStars.

StarRating(@IntRange(from = 1) int maxStars, float starRating)

Creates a StarRating instance with maxStars and the given integer or fractional number of stars.

Public methods

boolean
int

Returns the max stars.

float

Returns the star-based rating value.

int
boolean

Returns whether there is a rating value available.

String

Public constructors

StarRating

Added in 1.0.0
Deprecated in 1.3.0
public StarRating(@IntRange(from = 1) int maxStars)

Creates a unrated StarRating instance with maxStars. If maxStars is not a positive integer, it will throw IllegalArgumentException.

Parameters
@IntRange(from = 1) int maxStars

a range of this star rating from 0.0f to maxStars

StarRating

Added in 1.0.0
Deprecated in 1.3.0
public StarRating(@IntRange(from = 1) int maxStars, float starRating)

Creates a StarRating instance with maxStars and the given integer or fractional number of stars. Non integer values can for instance be used to represent an average rating value, which might not be an integer number of stars. If maxStars is not a positive integer or starRating has invalid value, it will throw IllegalArgumentException.

Parameters
@IntRange(from = 1) int maxStars

the maximum number of stars which this rating can have.

float starRating

a number ranging from 0.0f to maxStars

Public methods

equals

public boolean equals(Object obj)

getMaxStars

Added in 1.0.0
Deprecated in 1.3.0
public int getMaxStars()

Returns the max stars.

Returns
int

a max number of stars for this star rating.

getStarRating

Added in 1.0.0
Deprecated in 1.3.0
public float getStarRating()

Returns the star-based rating value.

Returns
float

a rating value greater or equal to 0.0f, or a negative value if it is unrated.

hashCode

public int hashCode()

isRated

Added in 1.0.0
Deprecated in 1.3.0
public boolean isRated()

Returns whether there is a rating value available.

Returns
boolean

true if there is an available rating value.

toString

public String toString()