Package org.organicdesign.fp.oneOf
Class OneOf4<A,B,C,D>
- java.lang.Object
-
- org.organicdesign.fp.oneOf.OneOf4<A,B,C,D>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)inthashCode()<R> Rmatch(@NotNull Fn1<A,R> fa, @NotNull Fn1<B,R> fb, @NotNull Fn1<C,R> fc, @NotNull Fn1<D,R> fd)Languages that have union types built in have a match statement that works like this method.@NotNull StringtoString()
-
-
-
Field Detail
-
item
@NotNull protected final @NotNull Object item
-
-
Constructor Detail
-
OneOf4
protected OneOf4(@NotNull @NotNull Object o, @NotNull @NotNull Class<A> aClass, @NotNull @NotNull Class<B> bClass, @NotNull @NotNull Class<C> cClass, @NotNull @NotNull Class<D> dClass, int index)Protected constructor for subclassing.- Parameters:
o- the itemaClass- class 0bClass- class 1cClass- class 2dClass- class 3index- 0 means this represents an A, 1 a B, 2 a C, and 3 a D.
-
-
Method Detail
-
match
public <R> R match(@NotNull @NotNull Fn1<A,R> fa, @NotNull @NotNull Fn1<B,R> fb, @NotNull @NotNull Fn1<C,R> fc, @NotNull @NotNull Fn1<D,R> fd)Languages that have union types built in have a match statement that works like this method. Exactly one of these functions will be executed - determined by which type of item this object holds.- Parameters:
fa- applied iff this stores the first type.fb- applied iff this stores the second type.fc- applied iff this stores the third type.fd- applied iff this stores the fourth type.- Returns:
- the return value of whichever function is executed.
-
-