public class Capacity extends Object
Note that this assumes the the values of each capacity dimension can be added up and subtracted
| Modifier and Type | Class and Description |
|---|---|
static class |
Capacity.Builder
Builder that builds Capacity
|
| Modifier and Type | Method and Description |
|---|---|
static Capacity |
addup(Capacity cap1,
Capacity cap2)
Adds up two capacities, i.e.
|
static Capacity |
copyOf(Capacity capacity)
Makes a deep copy of Capacity.
|
static double |
divide(Capacity numerator,
Capacity denominator)
Divides every dimension of numerator capacity by the corresponding dimension of denominator capacity,
, and averages each quotient.
|
boolean |
equals(Object o) |
int |
get(int index)
Returns value of capacity-dimension with specified index.
|
int |
getNuOfDimensions()
Returns the number of specified capacity dimensions.
|
int |
hashCode() |
static Capacity |
invert(Capacity cap2invert)
Returns the inverted capacity, i.e.
|
boolean |
isGreaterOrEqual(Capacity toCompare)
Returns true if this capacity is greater or equal than the capacity toCompare
|
boolean |
isLessOrEqual(Capacity toCompare)
Returns true if this capacity is less or equal than the capacity toCompare, i.e.
|
static Capacity |
max(Capacity cap1,
Capacity cap2)
Return the maximum, i.e.
|
static Capacity |
min(Capacity cap1,
Capacity cap2) |
static Capacity |
subtract(Capacity cap,
Capacity cap2subtract)
Subtracts cap2subtract from cap and returns the resulting Capacity.
|
String |
toString() |
public static Capacity addup(Capacity cap1, Capacity cap2)
Note that this assumes that capacity dimension can be added up.
cap1 - capacity to be added upcap2 - capacity to be added upNullPointerException - if one of the args is nullpublic static Capacity subtract(Capacity cap, Capacity cap2subtract)
cap - capacity to be subtracted fromcap2subtract - capacity to subtractNullPointerException - if one of the args is nullIllegalStateException - if number of capacityDimensions of cap1 and cap2 are different (i.e. cap1.getNuOfDimension() != cap2.getNuOfDimension()).public static Capacity invert(Capacity cap2invert)
cap2invert - capacity to be invertedNullPointerException - if one of the args is nullpublic static double divide(Capacity numerator, Capacity denominator)
If both nominator.get(i) and denominator.get(i) equal to 0, dimension i is ignored.
If both capacities are have only dimensions with dimensionVal=0, it returns 0.0
numerator - the numeratordenominator - the denominatorIllegalStateException - if numerator.get(i) != 0 and denominator.get(i) == 0public static Capacity copyOf(Capacity capacity)
capacity - capacity to be copiedpublic int getNuOfDimensions()
public int get(int index)
If capacity dimension does not exist, it returns 0 (rather than IndexOutOfBoundsException).
index - dimension index of the capacity value to be retrievedpublic boolean isLessOrEqual(Capacity toCompare)
toCompare - the capacity to compareNullPointerException - if one of the args is nullpublic boolean isGreaterOrEqual(Capacity toCompare)
toCompare - the capacity to compareNullPointerException - if one of the args is nullpublic static Capacity max(Capacity cap1, Capacity cap2)
cap1 - first capacity to comparecap2 - second capacity to compareCopyright © 2013–2019. All rights reserved.