Java Primitive Type Create toPrimitiveArray(Boolean[] a)

Here you can find the source of toPrimitiveArray(Boolean[] a)

Description

to Primitive Array

License

Apache License

Declaration

public static boolean[] toPrimitiveArray(Boolean[] a) 

Method Source Code

//package com.java2s;
/* ===========================================================================
 * Copyright (C) 2015 CapsicoHealth Inc.
 *
 * 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./*ww  w .  j  ava  2 s. c  o m*/
 */

public class Main {
    protected static final boolean[] EMPTY_BOOLEAN_P = {};
    protected static final int[] EMPTY_INTEGER_P = {};
    protected static final long[] EMPTY_LONG_P = {};
    protected static final float[] EMPTY_FLOAT_P = {};
    protected static final double[] EMPTY_DOUBLE_P = {};
    protected static final char[] EMPTY_CHARACTER_P = {};

    public static boolean[] toPrimitiveArray(Boolean[] a) {
        if (a == null)
            return EMPTY_BOOLEAN_P;
        boolean[] A = new boolean[a.length];
        for (int i = 0; i < a.length; ++i)
            A[i] = a[i];
        return A;
    }

    public static int[] toPrimitiveArray(Integer[] a) {
        if (a == null)
            return EMPTY_INTEGER_P;
        int[] A = new int[a.length];
        for (int i = 0; i < a.length; ++i)
            A[i] = a[i];
        return A;
    }

    public static long[] toPrimitiveArray(Long[] a) {
        if (a == null)
            return EMPTY_LONG_P;
        long[] A = new long[a.length];
        for (int i = 0; i < a.length; ++i)
            A[i] = a[i];
        return A;
    }

    public static float[] toPrimitiveArray(Float[] a) {
        if (a == null)
            return EMPTY_FLOAT_P;
        float[] A = new float[a.length];
        for (int i = 0; i < a.length; ++i)
            A[i] = a[i];
        return A;
    }

    public static double[] toPrimitiveArray(Double[] a) {
        if (a == null)
            return EMPTY_DOUBLE_P;
        double[] A = new double[a.length];
        for (int i = 0; i < a.length; ++i)
            A[i] = a[i];
        return A;
    }

    public static char[] toPrimitiveArray(Character[] a) {
        if (a == null)
            return EMPTY_CHARACTER_P;
        char[] A = new char[a.length];
        for (int i = 0; i < a.length; ++i)
            A[i] = a[i];
        return A;
    }
}

Related

  1. toPrimitive(Long[] array)
  2. toPrimitive(Long[] array)
  3. toPrimitive(Long[] array)
  4. toPrimitive(Object o)
  5. toPrimitive(Object value)
  6. toPrimitiveArray(Byte[] array)
  7. toPrimitiveArray(Byte[] bytes)
  8. toPrimitiveArray(Integer[] array)
  9. toPrimitiveArray(Object[] array)