Here you can find the source of isNotEmpty(Object object)
public static boolean isNotEmpty(Object object)
//package com.java2s; /*/*w w w . java2s . c o m*/ * Copyright 2011-2013 HTTL Team. * * 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. */ import java.util.*; public class Main { public static boolean isNotEmpty(Object object) { return isTrue(object); } public static boolean isTrue(boolean object) { return object; } public static boolean isTrue(char object) { return object != '\0'; } public static boolean isTrue(byte object) { return object != (byte) 0; } public static boolean isTrue(short object) { return object != (short) 0; } public static boolean isTrue(int object) { return object != 0; } public static boolean isTrue(long object) { return object != 0l; } public static boolean isTrue(float object) { return object != 0f; } public static boolean isTrue(double object) { return object != 0d; } public static boolean isTrue(Object object) { if (object instanceof Boolean) { return ((Boolean) object).booleanValue(); } return getSize(object) != 0; } public static int getSize(Object object) { if (object == null) { return 0; } else if (object instanceof Collection<?>) { return ((Collection<?>) object).size(); } else if (object instanceof Map<?, ?>) { return ((Map<?, ?>) object).size(); } else if (object instanceof Object[]) { return ((Object[]) object).length; } else if (object instanceof int[]) { return ((int[]) object).length; } else if (object instanceof long[]) { return ((long[]) object).length; } else if (object instanceof float[]) { return ((float[]) object).length; } else if (object instanceof double[]) { return ((double[]) object).length; } else if (object instanceof short[]) { return ((short[]) object).length; } else if (object instanceof byte[]) { return ((byte[]) object).length; } else if (object instanceof char[]) { return ((char[]) object).length; } else if (object instanceof boolean[]) { return ((boolean[]) object).length; } else { return -1; } } }