Documentation
Articles
The API
- Iterate: The entry point for working with collections with Motif. Home of several overloaded static on(..) methods, which accepts common Java objects, and enables manipulating it through Motif’s Elements API.
- Singular: The entry point for working with single values with Motif. Here you create instances of Optional, which is a special construct for dealing with single values/objects without ever needing to do tedious null-checking.
Functional interfaces
The functional interfaces of the no.motif.f package are single method interfaces that imitate function types. The two most important ones are:
- Fn<I, O>: functional (single-method) interface where implementing methods are passed objects of one type (I), and returns objects of the same or another type (O).
- Predicate<T>: functional interface where implementing methods evaluates objects of type T as either true or false. A predicate is really a specialization of Fn<I,O> where the return type (O) is boolean, but since a predicate is such a central concept, it has got its own interface, and since Java does not allow type parameterization with primitive types, this avoids the possibility of returning null from predicates.
Function implementations
- Base: generic operations, as well as providing various ways to compose operations to form new operations.
- Strings: useful implementations of Predicate, Fn, and other functional interfaces for working with strings
- Ints: operations for working with int values.
- Longs: operations for working with long values.
- Chars: operations for working with char values.
- Decimals: operations for working with decimal number (double) values.