// standard: Therian.standard(); // using ServiceLoader to find TherianModules: Therian.usingDiscoveredModules(); // custom: Therian.usingModules(new CustomTherianModule1(), new CustomTherianModule2()); // standard + custom: Therian.usingModules( TherianModule.create().withOperators(Operators.standard()), TherianModule.create().withOperators( new CustomOperator1(), new CustomOperator2() ) TherianModule.expandingDependencies( TherianModule.create().withOperators( new DependentOperator1(), new DependentOperator2() ) ), new CustomTherianModule());
// standalone: therian.context(); // wrapping: therian.contextFor(elContext);
The Positions class provides a number of methods to help you create “base” Positions for your Operations:
Foo foo = ...; Position.Readable<Foo> readFoo = Positions.readOnly(foo); Position.ReadWrite<Foo> rwFoo = Positions.readWrite(Foo.class, foo);
With parameterized base types, be sure to specify your Type using a parameterized Type instance or an implementation of org.apache.commons.lang3.reflect.Typed such as org.apache.commons.lang3.reflect.TypeLiteral:
List<Foo> foos = ...; Position.Readable<List<Foo>> readFoos = Positions.readOnly(new TypeLiteral<List<Foo>>() {}, foos);
Positions methods have been extensively overloaded for specifying the Type of the `Position. Have we overlooked something? Tell us!
Position.Readable<List<E>> list = ...; RelativePosition.ReadWrite<List<E>, E> elementN = Element.<E> atIndex(n).of(list); Position.ReadWrite<E> simpleElementN = elementN; Position.Readable<E[]> array = ...; RelativePosition.ReadWrite<E[], E> arrayElementM = Element.<E> atArrayIndex(m).of(array); Position.ReadWrite<E> simpleArrayElementM = arrayElementM;
Position.Readable<Map<K, V>> map = ...; K key = ...; RelativePosition.ReadWrite<Map<K, V>, V> valueAtKey = Keyed.<V> value().at(key).of(map); Position.ReadWrite<V> simpleValueAtKey = valueAtKey;
Position.Readable<Foo> foo = ...; RelativePosition.ReadWrite<Foo, Bar> bar = Property.<Bar> at("bar").of(foo); Position.ReadWrite<Bar> simpleBar = bar; RelativePosition.ReadWrite<Foo, Baz> optionalBaz = Property.<Baz> optional("baz").of(foo); Position.ReadWrite<Baz> simpleOptionalBaz = optionalBaz;