norswap.utils
March 3, 2022 ยท View on GitHub
A collection of Java (8+) utilities.
General Utilities
Chance: Utility functions for random number generation based on a privateRandominstance.Concurrency: Utility functions dealing with concurrency and asynchronicity (futures etc).IO: Utility functions for input/output.NFiles: Utility funcitons for dealing with files and paths.Predicates: Utilities for dealing with predicate functions.Strings: Utility functions dealing with strings and string builders.Vanilla: Utility functions for Vanilla Java collections.Util: Miscellaneous utility functions.NArrays: Utility functions dealing with arrays. (Other array functions of interest are defined inVanilla.)OperatingSystem: Operating system detection.
Data Structures
(data.structures package)
ArrayStack: A stack implementation that extends ArrayList.ArrayListInt: Pendant ofArrayListspecialized forint, with a small stack interface.ArrayListLong: Pendant ofArrayListspecialized forlong, with a small stack interface.multimap(package): defines theMultiMap<K, V>that extendsMap<K, Collection<V>>, as well as implementations thereof. A multimap is a map where multiple values can be bound to a single key.
Data Wrappers
(data.wrappers package)
Indexed: A pair made out of an integer and a value.Maybe: Better alternative tojava.util.Optionalthat notably supportsnullvalues.Pair: A simple type for a pair of values.Slot: A simple wrapper for a single value, useful when dealing with lambda capture and mutation.
Functional Interfaces
(data.functions package)
Indexed<XXX>: A variant ofjava.util.funciton.<XXX>functional interface that accepts anintindex as first argument.
Exceptions
(exception package)
Exceptional: Either wraps a value or an exception.NoStackException: ARuntimeExceptionthat does not fill the stack trace.Throwing{Runnable, Consumer, Supplier}: Just likejava.lang.Runnable/java.util.function.{Consumer, Supplier}, but allowed to throw exceptions.Exceptions: Utility functions dealing with exceptions and stack traces.
Reflection
(reflection package)
Reflection: Reflection-related utilities.Subtyping: Enables subtyping checks between instances ofjava.lang.reflect.Type.GenericType: Minimal implementation ofjava.lang.reflect.ParameterizedType, useful withSubtyping.
Visitors & Tree Walkers
(visitors package)
Visitor: a simple map-based visitor.ValuedVisitor: a variant ofVisitorthat support returning a value from the visitor method.Walker: a visitor variant that can be used to perform a depth-first tree walk in pre-, post- or in-order (multiple orders can be used during the same walk).
Scaffolding
TestFixture: A base class for test classes that implements some handy assertion methods. Compatible at least with TestNG.
Versioning
Versions are M.m.p
- Major (
M) is incremented when significant changes are made to the library. It might take non-trivial time to migrate. - Minor (
m) is incremented when new features are added, or existing features are modified. The main contract here is that migration should be quick, and a clear migration path exists. - Patch (
p) is incremented for hotfixes, or tiny / quality-of-life improvements. Patch never introduce breaking changes, excepted under the guise of bug-fixes.