Java SQL Type isPrimitive(Class type)

Here you can find the source of isPrimitive(Class type)

Description

is Primitive

License

Open Source License

Declaration

@SuppressWarnings("rawtypes")
    public static boolean isPrimitive(Class type) 

Method Source Code

//package com.java2s;
/*******************************************************************************
* Inspired Model Exporter is a framework to export data from pojo class.
* Copyright (C) 2016 Inspired Soft/*w  ww.  ja v a 2s  .  com*/
* 
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.    
*******************************************************************************/

import java.beans.PropertyDescriptor;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;

public class Main {
    /**
     * Check if the property is primitive including the wrapped types like Boolean, Double, String, etc.
     * @param property The property to check
     * @return True id the given property is primitive
     */
    @SuppressWarnings("rawtypes")
    public static boolean isPrimitive(PropertyDescriptor property) {
        Class type = property.getPropertyType();
        return type.isPrimitive() || isPrimitive(type);
    }

    @SuppressWarnings("rawtypes")
    public static boolean isPrimitive(Class type) {
        return (type == Integer.class || type == Double.class || type == String.class || type == Date.class
                || type == Boolean.class || type == BigDecimal.class || type == Timestamp.class
                || type == Long.class);
    }
}

Related

  1. isNumeric(int sqlType)
  2. isNumericType(int datatype)
  3. isNumericType(int type)
  4. isPlainJdbcType(int type)
  5. isPrecisionRequired(int jdbcType)
  6. isPrimitiveCollection(Method m)
  7. isScaleRequired(int type)
  8. isSerializationClass(Class clazz)
  9. isSimpleType(Class type)