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