<commit_before>/*******************************************************************************
 * 
 *    jlib - Open Source Java Library
 * 
 *    www.jlib.org
 * 
 * 
 *    Copyright 2012 <NAME>
 * 
 *    Licensed 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.
 * 
 ******************************************************************************/

package org.jlib.core;

/**
 * Utility class providing static methods for Object operations.
 * 
 * @author <NAME>
 */
public final class ObjectUtility {

    /** no visible constructor */
    private ObjectUtility() {}

    /**
     * Returns the specified optional Value.
     * 
     * @param <Value>
     *        type of the value
     * 
     * @param valueName
     *        {@link String} specifying a descriptive name of the Value
     * 
     * @param value
     *        Value to return or {@code null}
     * 
     * @return {@code value}, if {@code value != null}
     * 
     * @throws ValueNotAccessibleException
     *         if {@code value == null}
     */
    public static <Value> Value optional(final String valueName, /* @Nullable */final Value value)
    throws ValueNotAccessibleException {
        if (value == null)
            throw new ValueNotAccessibleException(valueName);

        return value;
    }

    /**
     * Compares the specified Objects for mutual equality. Two Objects
     * {@code object1}, {@code object2} are considered equal if
     * {@code object1 == object2 == null} or {@code object1.equals(object2)}.
     * 
     * @param objects
     *        comma separated sequence of Objects to compare
     * 
     * @return {@code true} if all specified Objects are equal or if the
     *         specified sequence of Objects is empty; {@code false} otherwise
     */
    public static final boolean equal(final Object... objects) {
        if (objects.length == 0)
            return true;
        final Object firstObject = objects[0];
        if (firstObject != null) {
            for (int index = 1; index < objects.length; index ++)
                if (!firstObject.equals(objects[index]))
                    return false;
        }
        else
            for (int index = 1; index < objects.length; index ++)
                if (objects[index] != null)
                    return false;
        return true;
    }

    /**
     * Returns the hash code of the specified Object as returned by its
     * {@link Object#hashCode() hashCode} method or {@code 0} if the specified
     * Object is {@code null}.
     * 
     * @param object
     *        Object of which the hash code is returned
     * @return integer specifying the hash code of Object; {@code 0} if
     *         {@code object} is {@code null}
     */
    public static int hashCode(final Object object) {
        return object != null
            ? object.hashCode()
            : 0;
    }
}<commit_msg>equal: final modifier removed<commit_after>/*******************************************************************************
 *
 *    jlib - Open Source Java Library
 *
 *    www.jlib.org
 *
 *
 *    Copyright 2012 <NAME>
 *
 *    Licensed 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.
 *
 ******************************************************************************/

package org.jlib.core;

/**
 * Utility class providing static methods for Object operations.
 *
 * @author <NAME>
 */
public final class ObjectUtility {

    /** no visible constructor */
    private ObjectUtility() {}

    /**
     * Returns the specified optional Value.
     *
     * @param <Value>   type of the value
     * @param valueName {@link String} specifying a descriptive name of the Value
     * @param value     Value to return or {@code null}
     *
     * @return {@code value}, if {@code value != null}
     *
     * @throws ValueNotAccessibleException if {@code value == null}
     */
    public static <Value> Value optional(final String valueName, /* @Nullable */final Value value)
    throws ValueNotAccessibleException {
        if (value == null)
            throw new ValueNotAccessibleException(valueName);

        return value;
    }

    /**
     * Compares the specified Objects for mutual equality. Two Objects
     * {@code object1}, {@code object2} are considered equal if
     * {@code object1 == object2 == null} or {@code object1.equals(object2)}.
     *
     * @param objects comma separated sequence of Objects to compare
     *
     * @return {@code true} if all specified Objects are equal or if the
     *         specified sequence of Objects is empty; {@code false} otherwise
     */
    public static boolean equal(final Object... objects) {
        if (objects.length == 0)
            return true;
        final Object firstObject = objects[0];
        if (firstObject != null) {
            for (int index = 1; index < objects.length; index++)
                if (! firstObject.equals(objects[index]))
                    return false;
        }
        else
            for (int index = 1; index < objects.length; index++)
                if (objects[index] != null)
                    return false;
        return true;
    }

    /**
     * Returns the hash code of the specified Object as returned by its
     * {@link Object#hashCode() hashCode} method or {@code 0} if the specified
     * Object is {@code null}.
     *
     * @param object Object of which the hash code is returned
     *
     * @return integer specifying the hash code of Object; {@code 0} if
     *         {@code object} is {@code null}
     */
    public static int hashCode(final Object object) {
        return object != null
               ? object.hashCode()
               : 0;
    }
}
{'fraction_non_alphanumeric': 0.1357398568019093, 'fraction_numerical': 0.0062649164677804296, 'mean_word_length': 2.289990186457311, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2365742', 'n_tokens_mistral': 1721, 'n_tokens_neox': 1639, 'n_words': 672}