aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/onXExample_post.jpage
blob: 85e3c58f9eebde1cb70c2a71ed6e85cfce4637ac (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
38
39
40
41
42
import com.google.inject.Inject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.hibernate.validator.Min;

public class OnMethodOnParamExample {
	private int bananas;
	private int radishes;
	
	@Deprecated
	public int getBananas() {
		return bananas;
	}
	
	@Min(10)
	public int setRadishes(int radishes) {
		this.radishes = radishes;
	}
	
	@Override public String toString() {
		return String.format("I have %d bananas and %d beautiful radishes", bananas, radishes);
	}
}

class OnConstructorExample {
	private final Fireman fireman;
	private int fires = 10;
	
	@Inject
	public OnConstructorExample(Fireman fireman) {
		this.fireman = fireman;
	}
	
	public void setFires(@SuppressWarnings("all") int fires) {
		this.fires = fires;
	}
	
	@Override public String toString() {
		return String.format("Fireman: %s has %d fires", fireman, fires);
	}
}