Class TorqueCondition<T>
java.lang.Object
org.texastorque.torquelib.control.TorqueCondition<T>
A replacement for the if else statments to check for conditions
that determine the object to pass to a consumer function.
Is about 30-50% slower than using chained if else statements,
but can be more readable.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
If the internal value is not null, pass it to a consumer function.final TorqueCondition<T>
A wrapper forTorqueCondition#checkIfElse()
, checks a condition and sets the value if the internal value has yet to be set (else if logic).final TorqueCondition<T>
A value to set if the value has yet to be set (else logic).final TorqueCondition<T>
checkElseIf
(boolean condition, T value) Checks a condition and sets the value if the internal value has yet to be set (else if logic).final TorqueCondition<T>
Checks a condition and sets the value regardless (if logic).final T
get()
Get the internal value.static final void
final TorqueCondition<T>
reset()
Resets the conditional chain.static final <T> TorqueCondition<T>
start()
Creates a new chainable instance of the condition.static final <T> TorqueCondition<T>
start
(boolean condition, T value) Creates a new chainable instance of the condition and checks a condition to determine if it should set the value.
-
Constructor Details
-
TorqueCondition
public TorqueCondition()
-
-
Method Details
-
start
Creates a new chainable instance of the condition.- Type Parameters:
T
- The type of the determined value.- Returns:
- A new conditional chain.
-
reset
Resets the conditional chain.- Returns:
- The conditional chain.
-
check
A wrapper forTorqueCondition#checkIfElse()
, checks a condition and sets the value if the internal value has yet to be set (else if logic).- Parameters:
condition
- The condition.value
- The value.- Returns:
- The conditional chain.
-
start
Creates a new chainable instance of the condition and checks a condition to determine if it should set the value.- Type Parameters:
T
- The type of the determined value.- Parameters:
condition
- The condition.value
- The value.- Returns:
- The conditional chain.
-
checkIf
Checks a condition and sets the value regardless (if logic).- Parameters:
condition
- The condition.value
- The value.- Returns:
- The conditional chain.
-
checkElseIf
Checks a condition and sets the value if the internal value has yet to be set (else if logic).- Parameters:
condition
- The condition.value
- The value.- Returns:
- The conditional chain.
-
checkElse
A value to set if the value has yet to be set (else logic).- Parameters:
condition
- The condition.value
- The value.- Returns:
- The conditional chain.
-
get
Get the internal value.- Returns:
- The internal value.
-
and
If the internal value is not null, pass it to a consumer function.- Parameters:
consumer
- The consumer function.
-
main
- Throws:
Exception
-