Percentage
public
final
class
Percentage
extends Object
implements
Comparable<Percentage>
java.lang.Object | |
↳ | android.health.connect.datatypes.units.Percentage |
Represents a value as a percentage, not a fraction - for example 100%, 89.62%, etc.
Summary
Public methods | |
---|---|
int
|
compareTo(Percentage other)
Compares this object with the specified object for order. |
boolean
|
equals(Object object)
Indicates whether some other object is "equal to" this one. |
static
Percentage
|
fromValue(double value)
Creates a Percentage object with the specified value |
double
|
getValue()
Returns the percentage. |
int
|
hashCode()
Returns a hash code value for the object. |
String
|
toString()
Returns a string representation of the object. |
Inherited methods | |
---|---|
Public methods
compareTo
public int compareTo (Percentage other)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Parameters | |
---|---|
other |
Percentage : the object to be compared.
This value cannot be null . |
Returns | |
---|---|
int |
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. |
Throws | |
---|---|
NullPointerException |
if the specified object is null |
ClassCastException |
if the specified object's type prevents it from being compared to this object. |
equals
public boolean equals (Object object)
Indicates whether some other object is "equal to" this one.
Parameters | |
---|---|
object |
Object : the reference object with which to compare. |
Returns | |
---|---|
boolean |
true if this object is the same as the object argument; false
otherwise. |
fromValue
public static Percentage fromValue (double value)
Creates a Percentage object with the specified value
Parameters | |
---|---|
value |
double : value to be set as percentage. The value must be between 0 and 100. |
Returns | |
---|---|
Percentage |
This value cannot be null . |
getValue
public double getValue ()
Returns the percentage. The value is between 0 and 100.
Returns | |
---|---|
double |
hashCode
public int hashCode ()
Returns a hash code value for the object.
Returns | |
---|---|
int |
a hash code value for this object. |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String |
a string representation of the object. |