Package org.texastorque.torquelib.util
Class TorqueUtil
java.lang.Object
org.texastorque.torquelib.util.TorqueUtil
Miscellaneous and uncatagorized static functions used throughout the codebase.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
static final class
static final class
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
Splits a camel case string into title case.static final <T> T
conditionalApply
(boolean use, T value, Function<T, T> function) Apply or don't modify a value based on a condition using a transforming function.static final <T> void
enumeratedFor
(Iterable<T> iterable, BiConsumer<Integer, T> f) Enumerated For (enumeratedFor) is a class that *trys* to implement similar functionality to Python: for i, element in enumerate(iterable): doSomething(i, element) in the form:enumeratedFor(iterable, (i, element) -> { doSomething(i, element); }); So not that much more verbose, but you do have to specify type! static final <T> void
enumeratedFor
(T[] array, BiConsumer<Integer, T> f) A wrapper for enumeratedFor that supports static arrays.static final void
Kills the program and writes an error message with a printf style in red.static final StackTraceElement
getStackTraceElement
(int level) Get a stack trace element.static final String
group
(int leading, int trailing, double... values) Appends doubles like an ordered pair in parenthesis.static final void
Automatically kills the program and displays that this method is unimplemented to the console.static final void
Automatically kills the program and displays that this method is unimplemented to the console.static final void
Automatically kills the program and displays that we are trying to instantiate the constructor of a static class.static final UnsupportedOperationException
Returns a throwable exception that notifies the developer that they are attempting to instantiate a static class.static final double
time()
A time method that can be used on the robot and on a computer.static final <T> TorqueUtil.TimeResult<T>
static final void
Writes an error message with a printf style in yellow but doesn't kill the program.
-
Field Details
-
osName
-
onRobot
public static final boolean onRobot
-
-
Method Details
-
time
public static final double time()A time method that can be used on the robot and on a computer. Should really only be used for relative use. -
getStackTraceElement
Get a stack trace element.- Parameters:
level
- The stack trace level.- Returns:
- The stack trace element at the desired elevation level.
-
warnf
Writes an error message with a printf style in yellow but doesn't kill the program. -
errorf
Kills the program and writes an error message with a printf style in red. -
notImplemented
public static final void notImplemented()Automatically kills the program and displays that this method is unimplemented to the console. -
outOfDate
public static final void outOfDate()Automatically kills the program and displays that this method is unimplemented to the console. -
staticConstructor
public static final void staticConstructor()Automatically kills the program and displays that we are trying to instantiate the constructor of a static class. -
staticConstructorError
Returns a throwable exception that notifies the developer that they are attempting to instantiate a static class. Call this in static constructors like so: throw staticConstructor();- Returns:
- The throwable exception.
-
enumeratedFor
Enumerated For (enumeratedFor) is a class that *trys* to implement similar functionality to Python: for i, element in enumerate(iterable): doSomething(i, element) in the form:enumeratedFor(iterable, (i, element) -> { doSomething(i, element); }); So not that much more verbose, but you do have to specify type! - Type Parameters:
T
- Type of the iterable.- Parameters:
iterable
- The iterable to iterate over.f
- The functional interface to call.
-
enumeratedFor
A wrapper for enumeratedFor that supports static arrays.- Type Parameters:
T
- Type of the iterable.- Parameters:
array
- The array to iterate over.f
- The functional interface to call.
-
time
- Throws:
Exception
-
conditionalApply
Apply or don't modify a value based on a condition using a transforming function.- Type Parameters:
T
- Type or parameter and return.- Parameters:
use
- To modify or not to modify.value
- The input value.function
- The function that modifies the input value.- Returns:
- The modified or unmodified value.
-
group
Appends doubles like an ordered pair in parenthesis.- Parameters:
values
- Doubles to append.- Returns:
- The resulting string.
-
camelCaseToTitleCase
Splits a camel case string into title case.- Parameters:
s
- Camel case string.- Returns:
- Title case string.
-