Package com.google.android.exoplayer2

## Class StarRating

- java.lang.Object
- - com.google.android.exoplayer2.Rating
  - - com.google.android.exoplayer2.StarRating

- All Implemented Interfaces:
    `Bundleable`

      public final class StarRating
      extends Rating

  A rating expressed as a fractional number of stars.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Bundleable

      `Bundleable.Creator<T extends Bundleable>`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static Bundleable.Creator<StarRating>` | `CREATOR` | Object that can restore a `StarRating` from a `Bundle`.

    - ### Fields inherited from class com.google.android.exoplayer2.Rating

      `RATING_UNSET`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `StarRating​(int maxStars)` | Creates a unrated instance with `maxStars`.
    `StarRating​(int maxStars, float starRating)` | Creates a rated instance with `maxStars` and the given fractional number of stars.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `equals​(Object obj)` |
    `int` | `getMaxStars()` | Returns the maximum number of stars.
    `float` | `getStarRating()` | Returns the fractional number of stars of this rating.
    `int` | `hashCode()` |
    `boolean` | `isRated()` | Whether the rating exists or not.
    `Bundle` | `toBundle()` | Returns a `Bundle` representing the information stored in this object.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CREATOR

          public static final Bundleable.Creator<StarRating> CREATOR

      Object that can restore a `StarRating` from a `Bundle`.

  - ### Constructor Detail

    - #### StarRating

          public StarRating​(@IntRange(from=1L)
                            int maxStars)

      Creates a unrated instance with `maxStars`. If `maxStars` is not a positive integer, it will throw an `IllegalArgumentException`.
      Parameters:
        `maxStars` - The maximum number of stars this rating can have.

    - #### StarRating

          public StarRating​(@IntRange(from=1L)
                            int maxStars,
                            @FloatRange(from=0.0)
                            float starRating)

      Creates a rated instance with `maxStars` and the given fractional number of stars. Non-integer values may be used to represent an average rating value. If `maxStars` is not a positive integer or `starRating` is out of range, it will throw an `IllegalArgumentException`.
      Parameters:
        `maxStars` - The maximum number of stars this rating can have.
        `starRating` - A fractional number of stars of this rating from `0f` to `maxStars`.

  - ### Method Detail

    - #### isRated

          public boolean isRated()

      Description copied from class: `Rating`
      Whether the rating exists or not.
      Specified by:
        `isRated` in class `Rating`

    - #### getMaxStars

          @IntRange(from=1L)
          public int getMaxStars()

      Returns the maximum number of stars. Must be a positive number.

    - #### getStarRating

          public float getStarRating()

      Returns the fractional number of stars of this rating. Will range from `0f` to `maxStars`, or `Rating.RATING_UNSET` if unrated.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals​(@Nullable
                                Object obj)

      Overrides:
        `equals` in class `Object`

    - #### toBundle

          public Bundle toBundle()

      Description copied from interface: `Bundleable`
      Returns a `Bundle` representing the information stored in this object.