001package ca.uhn.fhir.util; 002 003import org.apache.commons.lang3.StringUtils; 004 005/* 006 * #%L 007 * HAPI FHIR - Core Library 008 * %% 009 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 010 * %% 011 * Licensed under the Apache License, Version 2.0 (the "License"); 012 * you may not use this file except in compliance with the License. 013 * You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software 018 * distributed under the License is distributed on an "AS IS" BASIS, 019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 020 * See the License for the specific language governing permissions and 021 * limitations under the License. 022 * #L% 023 */ 024 025public class ObjectUtil { 026 027 public static boolean equals(Object object1, Object object2) { 028 if (object1 == object2) { 029 return true; 030 } 031 if ((object1 == null) || (object2 == null)) { 032 return false; 033 } 034 return object1.equals(object2); 035 } 036 037 public static <T> T requireNonNull(T obj, String message) { 038 if (obj == null) 039 throw new NullPointerException(message); 040 return obj; 041 } 042 043 public static void requireNotEmpty(String str, String message) { 044 if (StringUtils.isBlank(str)) { 045 throw new IllegalArgumentException(message); 046 } 047 } 048 049}