Package at.jku.ssw.fp.sect02_1
Class Demo1_ApplyFunction
- java.lang.Object
-
- at.jku.ssw.fp.sect02_1.Demo1_ApplyFunction
-
public class Demo1_ApplyFunction extends Object
Demos for generics.- Author:
- Herbert Praehofer
-
-
Constructor Summary
Constructors Constructor Description Demo1_ApplyFunction()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A,B>
BapplyFunction(Function<? super A,? extends B> fn, A obj)
Applies a function object on an object value.(package private) static <A> List<A>
either(List<? extends A> first, List<? extends A> second)
Returns the first list if not empty, otherwise the second liststatic void
main(String[] args)
-
-
-
Method Detail
-
main
public static void main(String[] args)
-
applyFunction
public static <A,B> B applyFunction(Function<? super A,? extends B> fn, A obj)
Applies a function object on an object value.- Type Parameters:
A
- the type of the valueB
- the type of the result- Parameters:
fn
- the function to applyobj
- the object value- Returns:
- the result of the application
-
either
static <A> List<A> either(List<? extends A> first, List<? extends A> second)
Returns the first list if not empty, otherwise the second list- Type Parameters:
A
- the common base type of the elements of th two lists- Parameters:
first
- the first listsecond
- the second list- Returns:
- the first list if not empty, otherwise the second list
-
-