Java Type Convert typeToUnboxedType(Class type)

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

Description

Converts a type to its unboxed type equivalent if one exists based on the terminology specified as part of PainlessLookupUtility .

License

Apache License

Declaration

public static Class<?> typeToUnboxedType(Class<?> type) 

Method Source Code

//package com.java2s;
/*//from  w w w  . ja va2 s  .c o m
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you 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.
 */

public class Main {
    /**
     * Converts a type to its unboxed type equivalent if one exists based on the terminology specified as part of
     * {@link PainlessLookupUtility}. Otherwise, this behaves as an identity function.
     */
    public static Class<?> typeToUnboxedType(Class<?> type) {
        if (type == Boolean.class) {
            return boolean.class;
        } else if (type == Byte.class) {
            return byte.class;
        } else if (type == Short.class) {
            return short.class;
        } else if (type == Character.class) {
            return char.class;
        } else if (type == Integer.class) {
            return int.class;
        } else if (type == Long.class) {
            return long.class;
        } else if (type == Float.class) {
            return float.class;
        } else if (type == Double.class) {
            return double.class;
        }

        return type;
    }
}

Related

  1. typeToSimpleName(String typeName)
  2. TypeToString(int typeNum)
  3. typeToString(Object o)
  4. typeToTag(String TheType)
  5. typeToTyperef(Class type)
  6. typeToVMSignature(final String type)