blob: 905ec2f9ff1bafec79d81e90d87e1f48c22ea73a (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package com.vaadin.tests.containers;
import java.util.Collection;
import java.util.LinkedList;
import com.vaadin.data.util.BeanItemContainer;
public class BeanItemContainerTest {
/**
* Test class for BeanItemContainer
*
* @throws IllegalAccessException
* @throws InstantiationException
*/
public static void main(String[] args) throws InstantiationException,
IllegalAccessException {
BeanItemContainer<Hello> c = new BeanItemContainer<Hello>(Hello.class);
c.addItem(new Hello());
Collection<Hello> col = new LinkedList<Hello>();
for (int i = 0; i < 100; i++) {
col.add(new Hello());
}
col.add(new Hello2());
c = new BeanItemContainer<Hello>(col);
System.out.println(c + " contains " + c.size() + " objects");
// test that subclass properties are handled correctly
System.out.println(c + " item 0 second = "
+ c.getContainerProperty(c.getIdByIndex(0), "second"));
System.out.println(c + " item 100 second = "
+ c.getContainerProperty(c.getIdByIndex(100), "second"));
}
public static class Hello {
public String first;
public String second;
public Hello() {
first = "f";
second = "l";
}
public String getFirst() {
return first;
}
public void setFirst(String first) {
this.first = first;
}
public String getSecond() {
return second;
}
public void setSecond(String second) {
this.second = second;
}
}
public static class Hello2 extends Hello {
@Override
public String getSecond() {
return "second";
}
}
}
|