Here you can find the source of getPrimitive(final String classname)
null
Parameter | Description |
---|---|
classname | The name of the class (or primitive) for which to retrieve the Class |
null
public static Class<?> getPrimitive(final String classname)
//package com.java2s; /*//from ww w .j a v a2 s . co m * Copyright 2012 Robert Philipp * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.HashMap; import java.util.Map; public class Main { private static Map<String, Class<?>> TYPE_MAP = new HashMap<>(); /** * Returns the primitive {@link Class} object if the specified class name represents * a primitive type; otherwise, returns <code>null</code> * @param classname The name of the class (or primitive) for which to retrieve the {@link Class} * @return the primitive {@link Class} object if the specified class name represents * a primitive type; otherwise, returns <code>null</code> */ public static Class<?> getPrimitive(final String classname) { return TYPE_MAP.get(classname); // if( Integer.TYPE.toString().equals( classname ) ) // { // return Integer.TYPE; // } // if( Double.TYPE.toString().equals( classname ) ) // { // return Double.TYPE; // } // if( Float.TYPE.toString().equals( classname ) ) // { // return Float.TYPE; // } // if( Long.TYPE.toString().equals( classname ) ) // { // return Long.TYPE; // } // if( Short.TYPE.toString().equals( classname ) ) // { // return Short.TYPE; // } // if( Boolean.TYPE.toString().equals( classname ) ) // { // return Boolean.TYPE; // } // if( Character.TYPE.toString().equals( classname ) ) // { // return Character.TYPE; // } // if( Byte.TYPE.toString().equals( classname ) ) // { // return Byte.TYPE; // } // return null; } }