Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/com/sun/beans/finder/PrimitiveWrapperMap.java
41161 views
1
/*
2
* Copyright (c) 2008, 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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
package com.sun.beans.finder;
26
27
import java.util.HashMap;
28
import java.util.Map;
29
30
/**
31
* This utility class associates
32
* name of primitive type with appropriate wrapper.
33
*
34
* @since 1.7
35
*
36
* @author Sergey A. Malenkov
37
*/
38
public final class PrimitiveWrapperMap {
39
40
/**
41
* Replaces all primitive types in specified array with wrappers.
42
*
43
* @param types array of classes where all primitive types
44
* will be replaced by appropriate wrappers
45
*/
46
static void replacePrimitivesWithWrappers(Class<?>[] types) {
47
for (int i = 0; i < types.length; i++) {
48
if (types[i] != null) {
49
if (types[i].isPrimitive()) {
50
types[i] = getType(types[i].getName());
51
}
52
}
53
}
54
}
55
56
/**
57
* Returns wrapper for primitive type by its name.
58
*
59
* @param name the name of primitive type
60
* @return found wrapper for primitive type,
61
* or {@code null} if not found
62
*/
63
public static Class<?> getType(String name) {
64
return map.get(name);
65
}
66
67
private static final Map<String, Class<?>> map = new HashMap<String, Class<?>>(9);
68
69
static {
70
map.put(Boolean.TYPE.getName(), Boolean.class);
71
map.put(Character.TYPE.getName(), Character.class);
72
map.put(Byte.TYPE.getName(), Byte.class);
73
map.put(Short.TYPE.getName(), Short.class);
74
map.put(Integer.TYPE.getName(), Integer.class);
75
map.put(Long.TYPE.getName(), Long.class);
76
map.put(Float.TYPE.getName(), Float.class);
77
map.put(Double.TYPE.getName(), Double.class);
78
map.put(Void.TYPE.getName(), Void.class);
79
}
80
81
/**
82
* Disable instantiation.
83
*/
84
private PrimitiveWrapperMap() {
85
}
86
}
87
88