Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLEncoder/Test7169395.java
41149 views
1
/*
2
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 7169395
27
* @summary Tests that array list initialized correctly
28
* @run main/othervm -Djava.security.manager=allow Test7169395
29
* @author Sergey Malenkov
30
*/
31
32
import java.beans.ConstructorProperties;
33
import java.util.ArrayList;
34
import java.util.Collection;
35
import java.util.Map;
36
import java.util.TreeMap;
37
38
public class Test7169395 extends AbstractTest {
39
40
public static void main(String[] args) {
41
new Test7169395().test(true);
42
}
43
44
protected Object getObject() {
45
Container container = new Container();
46
container.add("test-null", null);
47
container.add("test-value", "value");
48
container.add("test-other", "other");
49
return container;
50
}
51
52
public static class Component {
53
54
private final Container container;
55
private final String name;
56
private String value;
57
58
@ConstructorProperties({ "container", "name" })
59
public Component(Container container, String name) {
60
this.container = container;
61
this.name = name;
62
}
63
64
public Container getContainer() {
65
return this.container;
66
}
67
68
public String getName() {
69
return this.name;
70
}
71
72
public String getValue() {
73
return this.value;
74
}
75
76
public void setValue(String value) {
77
this.value = value;
78
}
79
}
80
81
public static class Container {
82
83
private final Map<String, Component> map = new TreeMap<String, Component>();
84
85
public Collection<Component> getComponents() {
86
return new ArrayList<Component>(this.map.values());
87
}
88
89
public void setComponents(Collection<Component> components) {
90
this.map.clear();
91
for (Component component : components){
92
this.map.put(component.getName(), component);
93
}
94
}
95
96
public void add(String name, String value) {
97
Component list = new Component(this, name);
98
list.setValue(value);
99
this.map.put(name, list);
100
}
101
}
102
}
103
104