All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.cosmos.implementation.apachecommons.lang.ObjectUtils Maven / Gradle / Ivy

Go to download

This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API

There is a newer version: 4.60.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Portions Copyright (c) Microsoft Corporation
 */

package com.azure.cosmos.implementation.apachecommons.lang;

public class ObjectUtils {
    /**
     * 

{@code ObjectUtils} instances should NOT be constructed in * standard programming. Instead, the static methods on the class should * be used, such as {@code ObjectUtils.defaultIfNull("a","b");}.

* *

This constructor is public to permit tools that require a JavaBean * instance to operate.

*/ private ObjectUtils() { super(); } /** *

Returns a default value if the object passed is {@code null}.

* *
     * ObjectUtils.defaultIfNull(null, null)      = null
     * ObjectUtils.defaultIfNull(null, "")        = ""
     * ObjectUtils.defaultIfNull(null, "zz")      = "zz"
     * ObjectUtils.defaultIfNull("abc", *)        = "abc"
     * ObjectUtils.defaultIfNull(Boolean.TRUE, *) = Boolean.TRUE
     * 
* * @param the type of the object * @param object the {@code Object} to test, may be {@code null} * @param defaultValue the default value to return, may be {@code null} * @return {@code object} if it is not {@code null}, defaultValue otherwise */ public static T defaultIfNull(final T object, final T defaultValue) { return object != null ? object : defaultValue; } /** *

Compares two objects for inequality, where either one or both * objects may be {@code null}.

* *
     * ObjectUtils.notEqual(null, null)                  = false
     * ObjectUtils.notEqual(null, "")                    = true
     * ObjectUtils.notEqual("", null)                    = true
     * ObjectUtils.notEqual("", "")                      = false
     * ObjectUtils.notEqual(Boolean.TRUE, null)          = true
     * ObjectUtils.notEqual(Boolean.TRUE, "true")        = true
     * ObjectUtils.notEqual(Boolean.TRUE, Boolean.TRUE)  = false
     * ObjectUtils.notEqual(Boolean.TRUE, Boolean.FALSE) = true
     * 
* * @param object1 the first object, may be {@code null} * @param object2 the second object, may be {@code null} * @return {@code false} if the values of both objects are the same */ public static boolean notEqual(final Object object1, final Object object2) { return !equals(object1, object2); } /** *

Compares two objects for equality, where either one or both * objects may be {@code null}.

* *
     * ObjectUtils.equals(null, null)                  = true
     * ObjectUtils.equals(null, "")                    = false
     * ObjectUtils.equals("", null)                    = false
     * ObjectUtils.equals("", "")                      = true
     * ObjectUtils.equals(Boolean.TRUE, null)          = false
     * ObjectUtils.equals(Boolean.TRUE, "true")        = false
     * ObjectUtils.equals(Boolean.TRUE, Boolean.TRUE)  = true
     * ObjectUtils.equals(Boolean.TRUE, Boolean.FALSE) = false
     * 
* * @param object1 the first object, may be {@code null} * @param object2 the second object, may be {@code null} * @return {@code true} if the values of both objects are the same * @deprecated this method has been replaced by {@code java.util.Objects.equals(Object, Object)} in Java 7 and will * be removed from future releases. */ @Deprecated private static boolean equals(final Object object1, final Object object2) { if (object1 == object2) { return true; } if (object1 == null || object2 == null) { return false; } return object1.equals(object2); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy