-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyLogic.java
More file actions
51 lines (39 loc) · 1.25 KB
/
MyLogic.java
File metadata and controls
51 lines (39 loc) · 1.25 KB
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
43
44
45
46
47
48
49
50
51
package myapp.logic;
import myapp.bean.MechanoidBean;
import myapp.bean.ProductBean;
import myapp.bean.UserBean;
import myapp.bean.base.Age;
import myapp.bean.base.Name;
import myapp.bean.base.ProductId;
public class MyLogic {
public static <T extends Name> void printName(T name) {
System.err.println("Name:" + name.getName());
}
public static <T extends Name & Age> void printUserDetail(T user) {
System.err.println("my name is " + user.getName() + ". I'm "
+ user.getAge() + " years old.");
}
public static <T extends Name & ProductId> void printProductDetail(T product) {
System.err.println("" + product.getName() + " (ID="
+ product.getProductId() + ")");
}
public static void main(String[] args) {
UserBean user = new UserBean();
user.setName("ryozi");
user.setAge(24);
printName(user);
printUserDetail(user);
ProductBean product = new ProductBean();
product.setName("HogeHogeApp");
product.setProductId("ID0001");
printName(product);
printProductDetail(product);
MechanoidBean mecha = new MechanoidBean();
mecha.setName("yoshio");
mecha.setProductId("MC0001");
mecha.setAge(2);
printName(mecha);
printProductDetail(mecha);
printUserDetail(mecha);
}
}