summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/functypes/Const.java
blob: 4c3d49869d86b314f9f8cf723412219123fa8800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package bjc.functypes;

import bjc.typeclasses.Container;

/**
 * Represents a constant container
 * 
 * @author bjcul
 *
 * @param <V> The type of the value
 * @param <A> The ignored argument type
 */
public class Const<V, A> implements Container<V, Const<V, ?>>{
	private V payload;
	
	private Const(V payload) {
		this.payload = payload;
	}
	
	/**
	 * Create a constant container.
	 * 
	 * @param <V> The value contained
	 * @param <A> The ignored argument type
	 * 
	 * @param val The type of the value
	 * 
	 * @return A constant container giving the contained value
	 */
	public static <V, A> Const<V, A> of(V val) {
		return new Const<>(val);
	}
	
	V get() {
		return payload;
	}
}