com.iflytek.edu.cloud.frame.doc.ClassUtils.java Source code

Java tutorial

Introduction

Here is the source code for com.iflytek.edu.cloud.frame.doc.ClassUtils.java

Source

/**
 * Copyright 2013-2014 the original author or authors.
 *
 * 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.
 */
package com.iflytek.edu.cloud.frame.doc;

import java.util.ArrayList;
import java.util.List;

import org.springframework.util.Assert;

/**
 * 
 * @author libinsong1204@gmail.com
 *
 */
public abstract class ClassUtils {
    private static final List<String> primitiveWrapperList = new ArrayList<String>();

    static {
        primitiveWrapperList.add("boolean");
        primitiveWrapperList.add(Boolean.class.getName());
        primitiveWrapperList.add("byte");
        primitiveWrapperList.add(Byte.class.getName());
        primitiveWrapperList.add("char");
        primitiveWrapperList.add(Character.class.getName());
        primitiveWrapperList.add("double");
        primitiveWrapperList.add(Double.class.getName());
        primitiveWrapperList.add("float");
        primitiveWrapperList.add(Float.class.getName());
        primitiveWrapperList.add("int");
        primitiveWrapperList.add(Integer.class.getName());
        primitiveWrapperList.add("long");
        primitiveWrapperList.add(Long.class.getName());
        primitiveWrapperList.add("short");
        primitiveWrapperList.add(Short.class.getName());
        primitiveWrapperList.add(String.class.getName());
    }

    public static boolean isPrimitiveOrWrapper(String typeName) {
        Assert.notNull(typeName, "typeName must not be null");
        return primitiveWrapperList.contains(typeName);
    }
}