@FunctionalInterface public interface VariableAmount
| Modifier and Type | Interface and Description |
|---|---|
static class |
VariableAmount.BaseAndAddition
Represents a base amount with a random addition, the final amount will be
the base amount plus a random amount between zero (inclusive) and the
addition (exclusive).
|
static class |
VariableAmount.BaseAndVariance
Represents a base amount with a variance, the final amount will be the
base amount plus or minus a random amount between zero (inclusive) and
the variance (exclusive).
|
static class |
VariableAmount.Fixed
Represents a fixed amount, calls to
VariableAmount.Fixed.getAmount(java.util.Random) will always return
the same fixed value. |
static class |
VariableAmount.OptionalAmount
Represents a variable amount which has a base and a chance of varying.
|
| Modifier and Type | Method and Description |
|---|---|
static VariableAmount |
baseWithOptionalAddition(double base,
double addition,
double chance)
Creates a new variable about which has a base and a chance to apply a
random additional amount.
|
static VariableAmount |
baseWithOptionalAddition(double base,
VariableAmount addition,
double chance)
Creates a new variable about which has a base and a chance to apply a
random additional amount.
|
static VariableAmount |
baseWithOptionalVariance(double base,
double variance,
double chance)
Creates a new variable about which has a base and a chance to apply a
random variance.
|
static VariableAmount |
baseWithOptionalVariance(double base,
VariableAmount variance,
double chance)
Creates a new variable about which has a base and a chance to apply a
random variance.
|
static VariableAmount |
baseWithRandomAddition(double base,
double addition)
Creates a new variable amount which has a base and an additional amount.
|
static VariableAmount |
baseWithRandomAddition(double base,
VariableAmount addition)
Creates a new variable amount which has a base and an additional amount.
|
static VariableAmount |
baseWithVariance(double base,
double variance)
Creates a new variable about which has a base and variance.
|
static VariableAmount |
baseWithVariance(double base,
VariableAmount variance)
Creates a new variable about which has a base and variance.
|
static VariableAmount |
fixed(double value)
Creates a new 'fixed' variable amount, calls to
getAmount(java.util.Random) will
always return the fixed value. |
default double |
getAmount()
Gets an instance of the variable amount using the thread's
ThreadLocalRandom instance. |
double |
getAmount(Random random)
Gets an instance of the variable amount depending on the given random
object.
|
default int |
getFlooredAmount()
Gets the amount as if from
getAmount() but floored to the
nearest integer equivalent. |
default int |
getFlooredAmount(Random random)
Gets the amount as if from
getAmount(Random) but floored to the
nearest integer equivalent. |
static VariableAmount |
range(double min,
double max)
Creates a new variable amount which return values between the given min
(inclusive) and max (exclusive).
|
@Nonnull static VariableAmount fixed(double value)
getAmount(java.util.Random) will
always return the fixed value.value - The fixed value@Nonnull static VariableAmount range(double min, double max)
min - The minimum of the range (inclusive)max - The maximum of the range (exclusive)@Nonnull static VariableAmount baseWithVariance(double base, double variance)
base - The base valuevariance - The variance@Nonnull static VariableAmount baseWithVariance(double base, @Nonnull VariableAmount variance)
base - The base valuevariance - The variance@Nonnull static VariableAmount baseWithRandomAddition(double base, double addition)
base - The base valueaddition - The additional amount@Nonnull static VariableAmount baseWithRandomAddition(double base, @Nonnull VariableAmount addition)
base - The base valueaddition - The additional amount@Nonnull static VariableAmount baseWithOptionalVariance(double base, double variance, double chance)
base - The base valuevariance - The variancechance - The chance to apply the variance@Nonnull static VariableAmount baseWithOptionalVariance(double base, @Nonnull VariableAmount variance, double chance)
base - The base valuevariance - The variancechance - The chance to apply the variance@Nonnull static VariableAmount baseWithOptionalAddition(double base, double addition, double chance)
base - The base valueaddition - The additional amountchance - The chance to apply the additional amount@Nonnull static VariableAmount baseWithOptionalAddition(double base, @Nonnull VariableAmount addition, double chance)
base - The base valueaddition - The additional amountchance - The chance to apply the additional amountdouble getAmount(@Nonnull Random random)
random - The random objectdefault double getAmount()
ThreadLocalRandom instance.default int getFlooredAmount(@Nonnull Random random)
getAmount(Random) but floored to the
nearest integer equivalent.random - The random objectdefault int getFlooredAmount()
getAmount() but floored to the
nearest integer equivalent.Copyright © 2022. All rights reserved.