001/* 002 * Copyright 2023 the original author or authors. 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.tools.lang; 017 018import lombok.experimental.UtilityClass; 019 020/** 021 * Overladed methods to check the emptiness of given primitive arrays. With 022 * empty being defined as is the given elements are {@code null} or 0 == 023 * array.length 024 * 025 * @author Oliver Wolff 026 * 027 */ 028@UtilityClass 029public class MoreArrays { 030 031 /** 032 * Simple check method for a {@code null} safe check of the emptiness of the 033 * given parameter. 034 * 035 * @param array to be checked, may be null 036 * @return {@code true} is the given elements are {@code null} or 0 == 037 * array.length 038 */ 039 public static boolean isEmpty(byte[] array) { 040 return null == array || 0 == array.length; 041 } 042 043 /** 044 * Simple check method for a {@code null} safe check of the emptiness of the 045 * given parameter. 046 * 047 * @param array to be checked, may be null 048 * @return {@code true} is the given elements are {@code null} or 0 == 049 * array.length 050 */ 051 public static boolean isEmpty(char[] array) { 052 return null == array || 0 == array.length; 053 } 054 055 /** 056 * Simple check method for a {@code null} safe check of the emptiness of the 057 * given parameter. 058 * 059 * @param array to be checked, may be null 060 * @return {@code true} is the given elements are {@code null} or 0 == 061 * array.length 062 */ 063 public static boolean isEmpty(boolean[] array) { 064 return null == array || 0 == array.length; 065 } 066 067 /** 068 * Simple check method for a {@code null} safe check of the emptiness of the 069 * given parameter. 070 * 071 * @param array to be checked, may be null 072 * @return {@code true} is the given elements are {@code null} or 0 == 073 * array.length 074 */ 075 public static boolean isEmpty(int[] array) { 076 return null == array || 0 == array.length; 077 } 078 079 /** 080 * Simple check method for a {@code null} safe check of the emptiness of the 081 * given parameter. 082 * 083 * @param array to be checked, may be null 084 * @return {@code true} is the given elements are {@code null} or 0 == 085 * array.length 086 */ 087 public static boolean isEmpty(long[] array) { 088 return null == array || 0 == array.length; 089 } 090 091 /** 092 * Simple check method for a {@code null} safe check of the emptiness of the 093 * given parameter. 094 * 095 * @param array to be checked, may be null 096 * @return {@code true} is the given elements are {@code null} or 0 == 097 * array.length 098 */ 099 public static boolean isEmpty(double[] array) { 100 return null == array || 0 == array.length; 101 } 102 103 /** 104 * Simple check method for a {@code null} safe check of the emptiness of the 105 * given parameter. 106 * 107 * @param array to be checked, may be null 108 * @return {@code true} is the given elements are {@code null} or 0 == 109 * array.length 110 */ 111 public static boolean isEmpty(float[] array) { 112 return null == array || 0 == array.length; 113 } 114 115 /** 116 * Simple check method for a {@code null} safe check of the emptiness of the 117 * given parameter. 118 * 119 * @param array to be checked, may be null 120 * @return {@code true} is the given elements are {@code null} or 0 == 121 * array.length 122 */ 123 public static boolean isEmpty(short[] array) { 124 return null == array || 0 == array.length; 125 } 126}