Java Class to Primitive toClass(String primitiveName)

Here you can find the source of toClass(String primitiveName)

Description

Convert a primitive name (int, byte etc.) to a class or null if the name is not a primitive.

License

Open Source License

Declaration

public static Class toClass(String primitiveName) 

Method Source Code


//package com.java2s;
/*//from  ww  w  .j a v  a 2s .  co m
 * Copyright (c) 1998 - 2005 Versant Corporation
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Versant Corporation - initial API and implementation
 */

import java.util.*;

public class Main {
    private static final HashMap PRIMITIVE_NAME_MAP = new HashMap(17);

    /**
     * Convert a primitive name (int, byte etc.) to a class or null if the
     * name is not a primitive.
     */
    public static Class toClass(String primitiveName) {
        return (Class) PRIMITIVE_NAME_MAP.get(primitiveName);
    }
}

Related

  1. getWrapper(String primitiveClassName)
  2. getWrapperTypeByPrimitive(Class clazz)
  3. primitiveToWrapper(Class cls)
  4. primitiveToWrapper(Class in)
  5. primitiveToWrapper(final Class p)