3 * Copyright © 2013 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package info.globalcode.sql.dk;
20 import java.util.ArrayList;
21 import java.util.Collection;
26 * @author Ing. František Kučera (frantovo.cz)
28 public class Functions {
33 public static boolean equalz(Object a, Object b) {
34 return a == null ? b == null : a.equals(b);
39 * @param text String to be examinated
40 * @param trim whether text should be trimmed before examination
41 * @return whether text is not empty and one or more characters long (after prospective trim)
43 public static boolean isEmpty(String text, boolean trim) {
50 return text.isEmpty();
55 * @see #isEmpty(java.lang.String, boolean)
57 public static boolean isNotEmpty(String text, boolean trim) {
58 return !isEmpty(text, trim);
61 public boolean isEmpty(Collection c) {
62 return c == null || c.isEmpty();
65 public boolean isNotEmpty(Collection c) {
69 public boolean isEmpty(Map m) {
70 return m == null || m.isEmpty();
73 public boolean isNotEmpty(Map m) {
78 * @return empty collection if given one is null | or the original one
80 public static <T> Collection<T> notNull(Collection<T> c) {
82 return new ArrayList<>();