Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/beans/XMLEncoder/Test7169395.java
38812 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
* @author Sergey Malenkov
29
*/
30
31
import java.beans.ConstructorProperties;
32
import java.util.ArrayList;
33
import java.util.Collection;
34
import java.util.Map;
35
import java.util.TreeMap;
36
37
public class Test7169395 extends AbstractTest {
38
39
public static void main(String[] args) {
40
new Test7169395().test(true);
41
}
42
43
protected Object getObject() {
44
Container container = new Container();
45
container.add("test-null", null);
46
container.add("test-value", "value");
47
container.add("test-other", "other");
48
return container;
49
}
50
51
public static class Component {
52
53
private final Container container;
54
private final String name;
55
private String value;
56
57
@ConstructorProperties({ "container", "name" })
58
public Component(Container container, String name) {
59
this.container = container;
60
this.name = name;
61
}
62
63
public Container getContainer() {
64
return this.container;
65
}
66
67
public String getName() {
68
return this.name;
69
}
70
71
public String getValue() {
72
return this.value;
73
}
74
75
public void setValue(String value) {
76
this.value = value;
77
}
78
}
79
80
public static class Container {
81
82
private final Map<String, Component> map = new TreeMap<String, Component>();
83
84
public Collection<Component> getComponents() {
85
return new ArrayList<Component>(this.map.values());
86
}
87
88
public void setComponents(Collection<Component> components) {
89
this.map.clear();
90
for (Component component : components){
91
this.map.put(component.getName(), component);
92
}
93
}
94
95
public void add(String name, String value) {
96
Component list = new Component(this, name);
97
list.setValue(value);
98
this.map.put(name, list);
99
}
100
}
101
}
102
103