Here you can find the source of isNullOrEmptyAwareEqual(final List> targetOne, final List> targetTwo)
Parameter | Description |
---|---|
targetOne | one list to check for equality |
targetTwo | other list to check for equality |
public static boolean isNullOrEmptyAwareEqual(final List<?> targetOne, final List<?> targetTwo)
//package com.java2s; /*/*w w w . java2s.c om*/ Copyright (C) 2016 HermeneutiX.org This file is part of SciToS. SciToS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SciToS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SciToS. If not, see <http://www.gnu.org/licenses/>. */ import java.util.List; public class Main { /** * Check if either both objects are {@code null} or {@link String#isEmpty() empty}. Otherwise check if one {@link String#equals(Object) equals} * the other. * * @param targetOne * one {@code String} to check for equality * @param targetTwo * other {@code String} to check for equality * @return if both are {@code null}/{@link String#isEmpty() empty} or {@link String#equals(Object) equal} to each other */ public static boolean isNullOrEmptyAwareEqual(final String targetOne, final String targetTwo) { final boolean checkResult; if (targetOne == null || targetOne.isEmpty()) { checkResult = targetTwo == null || targetTwo.isEmpty(); } else { checkResult = targetOne.equals(targetTwo); } return checkResult; } /** * Check if either both objects are {@code null} or {@link List#isEmpty() empty}. Otherwise check if one {@link List#equals(Object) equals} the * other. * * @param targetOne * one list to check for equality * @param targetTwo * other list to check for equality * @return if both are {@code null}/{@link List#isEmpty() empty} or {@link List#equals(Object) equal} to each other */ public static boolean isNullOrEmptyAwareEqual(final List<?> targetOne, final List<?> targetTwo) { final boolean checkResult; if (targetOne == null || targetOne.isEmpty()) { checkResult = targetTwo == null || targetTwo.isEmpty(); } else { checkResult = targetOne.equals(targetTwo); } return checkResult; } }