- java.lang.Object
-
- org.scijava.function.Inplaces
-
public final class Inplaces extends Object
Container class for inplace-style functional interfaces at various arities.An inplace has functional method
mutatewith a number of arguments corresponding to the arity. Any of the arguments annotated with @Mutablemay be mutated during execution. Some interfaces narrow this behavior to only a specific argument; most ops in practice will implement one of these narrowed interfaces. For example,Inplaces.Arity2_1is a binary inplace op that mutates the first of two arguments—e.g., ana /= bdivision operation would be anInplaces.Arity2_1, whereasb = a / bwould be anInplaces.Arity2_2.Each inplace interface implements a corresponding
Consumer-style interface (seeConsumers) with same arity; the consumer'sacceptmethod simply delegates tomutate. This pattern allows inplace ops to be used directly as consumers as needed.Note that there is no nullary (arity 0) inplace interface, because there would be no arguments to mutate; see also
Consumers.Arity0,Computers.Arity0andProducer.- Author:
- Curtis Rueden, Gabriel Selzer
-
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static Map<Class<?>,Inplaces.InplaceInfo>ALL_ARITIESstatic Map<Inplaces.InplaceInfo,Class<?>>ALL_INPLACESAll known inplace types and their arities and mutable positions.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Inplaces.InplaceInfoarityOf(Class<?> c)static Class<?>inplaceOfArity(int arity, int mutableIndex)static booleanisInplace(Class<?> c)
-
-
-
Field Detail
-
ALL_INPLACES
public static final Map<Inplaces.InplaceInfo,Class<?>> ALL_INPLACES
All known inplace types and their arities and mutable positions. The entries are sorted by arity and mutable position.
-
ALL_ARITIES
public static final Map<Class<?>,Inplaces.InplaceInfo> ALL_ARITIES
-
-
Method Detail
-
isInplace
public static boolean isInplace(Class<?> c)
- Returns:
trueif the given type is a known inplace type,falseotherwise.
Note that only the type itself and not its type hierarchy is considered.- Throws:
NullPointerException- Ifcisnull.
-
inplaceOfArity
public static Class<?> inplaceOfArity(int arity, int mutableIndex)
- Parameters:
arity- anintcorresponding to aInplaceof that arity.mutableIndex- anintcorresponding to a the mutable index of d arity.- Returns:
- the
Inplaceof arityarity. - Throws:
IllegalArgumentException- iff there is no knownInplaceof arityarity.
-
arityOf
public static Inplaces.InplaceInfo arityOf(Class<?> c)
- Parameters:
c- theClassof unknown arity- Returns:
- the arity of
c, or-1ifcis not aInplace.
-
-