A simple lambda, x -> val seems to be equivalent to your method;
Function test1 = constant(5);
Function test2 = x -> 5;
...both ignore the input and output the constant 5 when applied;
> System.out.println(test1.apply(2));
5
> System.out.println(test2.apply(2));
5