<commit_before>/*
 * jlib - The Free Java Library
 * 
 *    http://www.jlib.org
 *    
 * Copyright (c) 2006-2008 <NAME>
 * 
 * jlib is distributed under the
 *
 *    COMMON PUBLIC LICENSE VERSION 1.0
 *
 *    http://www.opensource.org/licenses/cpl1.0.php
 */

package org.jlib.container.binaryrelation;

/**
 * Association in a BinaryRelation.
 * 
 * @param <LeftValue>
 *        type of the objects on the left hand side of the BinaryRelation
 * @param <RightValue>
 *        type of the objects on the right hand side of the BinaryRelation
 * @author <NAME>
 */
public class Association<LeftValue, RightValue> {

    /** LeftValue of this Association */
    private final LeftValue leftValue;

    /** RightValue of this Association */
    private final RightValue rightValue;

    /**
     * Creates a new Association.
     * 
     * @param leftValue
     *        LeftValue of this Association
     * @param rightValue
     *        RightValue of this Association
     */
    public Association(LeftValue leftValue, RightValue rightValue) {
        super();
        this.leftValue = leftValue;
        this.rightValue = rightValue;
    }

    /**
     * Returns the object on the left hand side of this Association.
     * 
     * @return LeftValue of this Association
     */
    public LeftValue left() {
        return leftValue;
    }

    /**
     * Returns the object on the right hand side of this Association.
     * 
     * @return RightValue of this Association
     */
    public RightValue right() {
        return rightValue;
    }

    @Override
    public boolean equals(Object otherObject) {
        if (!(otherObject instanceof Association<?, ?>))
            return false;
        Association<?, ?> otherAssociation = (Association<?, ?>) otherObject;
        Object otherLeftValue = otherAssociation.left();
        Object otherRightValue = otherAssociation.right();
        if (leftValue != null && rightValue != null)
            return leftValue.equals(otherLeftValue) && rightValue.equals(otherRightValue);
        if (leftValue != null /* && rightValue == null */)
            return leftValue.equals(otherLeftValue) && otherRightValue == null;
        if (rightValue != null /* && leftValue == null */)
            return rightValue.equals(otherRightValue) && otherLeftValue == null;
        // if (leftValue == rightValue == null)
        return otherLeftValue == null && otherRightValue == null;
    }

    @Override
    public int hashCode() {
        return (leftValue != null ? leftValue.hashCode() : 0) + (rightValue != null ? rightValue.hashCode() : 0);
    }
}<commit_msg>Association: removed null handling<commit_after>/*
 * jlib - The Free Java Library
 * 
 *    http://www.jlib.org
 *    
 * Copyright (c) 2006-2008 <NAME>
 * 
 * jlib is distributed under the
 *
 *    COMMON PUBLIC LICENSE VERSION 1.0
 *
 *    http://www.opensource.org/licenses/cpl1.0.php
 */

package org.jlib.container.binaryrelation;

/**
 * Association in a BinaryRelation.
 * 
 * @param <LeftValue>
 *        type of the objects on the left hand side of the BinaryRelation
 * 
 * @param <RightValue>
 *        type of the objects on the right hand side of the BinaryRelation
 * 
 * @author <NAME>
 */
public class Association<LeftValue, RightValue> {

    /** LeftValue of this Association */
    private final LeftValue leftValue;

    /** RightValue of this Association */
    private final RightValue rightValue;

    /**
     * Creates a new Association.
     * 
     * @param leftValue
     *        LeftValue of this Association
     * 
     * @param rightValue
     *        RightValue of this Association
     */
    public Association(final LeftValue leftValue, final RightValue rightValue) {
        super();

        this.leftValue = leftValue;
        this.rightValue = rightValue;
    }

    /**
     * Returns the object on the left hand side of this Association.
     * 
     * @return LeftValue of this Association
     */
    public LeftValue left() {
        return leftValue;
    }

    /**
     * Returns the object on the right hand side of this Association.
     * 
     * @return RightValue of this Association
     */
    public RightValue right() {
        return rightValue;
    }

    @Override
    public boolean equals(final Object otherObject) {
        if (!(otherObject instanceof Association<?, ?>))
            return false;

        final Association<?, ?> otherAssociation = (Association<?, ?>) otherObject;

        return leftValue.equals(otherAssociation.left()) && rightValue.equals(otherAssociation.right());
    }

    @Override
    public int hashCode() {
        return leftValue.hashCode() * 2 + rightValue.hashCode();
    }
}
{'fraction_non_alphanumeric': 0.10245464247598719, 'fraction_numerical': 0.00576307363927428, 'mean_word_length': 2.4179431072210065, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '985623', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1236, 'n_words': 394}