Java String Empty to Null emptyToDefault(T[] values, T[] def)

Here you can find the source of emptyToDefault(T[] values, T[] def)

Description

empty To Default

License

Apache License

Declaration

public static <T> T[] emptyToDefault(T[] values, T[] def) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static <T> T[] emptyToDefault(T[] values, T[] def) {
        return values == null || values.length == 0 ? def : values;
    }/*from   w w w.  j  a va 2s  .c  o  m*/

    public static byte[] emptyToDefault(byte[] values, byte[] def) {
        return values == null || values.length == 0 ? def : values;
    }

    public static short[] emptyToDefault(short[] values, short[] def) {
        return values == null || values.length == 0 ? def : values;
    }

    public static int[] emptyToDefault(int[] values, int[] def) {
        return values == null || values.length == 0 ? def : values;
    }

    public static long[] emptyToDefault(long[] values, long[] def) {
        return values == null || values.length == 0 ? def : values;
    }

    public static float[] emptyToDefault(float[] values, float[] def) {
        return values == null || values.length == 0 ? def : values;
    }

    public static double[] emptyToDefault(double[] values, double[] def) {
        return values == null || values.length == 0 ? def : values;
    }
}

Related

  1. emptyStringToNull(String input)
  2. emptyStringToNull(String str)
  3. emptyStringToNull(String string)
  4. emptyToDefault(String value, String def)
  5. emptyToNull(final String text, final boolean doTrim)
  6. emptyToNull(String field)
  7. emptyToNull(String s)
  8. emptyToNull(String s)