<commit_before>/**
 * 
 */
package datastructures;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author <NAME>
 *
 */
public class KeyJoint implements Iterable<AttributeJoint> {
    private List<AttributeJoint> keys;
    private static final Logger LOG = Logger.getLogger(KeyJoint.class.getName());

    /**
     * Constructs a Null list of AttributeJoints representing keys of a Relation.
     */
    public KeyJoint() {
        // Manually generated default constructor.
    }
    
    /**
     * Constructs an list of AttributesJoint representing Relation keys.
     * 
     * Every AttributeJoint from {@code keyJoint} must be a key.
     * 
     * @param keyJoint An array of String object.
     */
    public KeyJoint(List<AttributeJoint> keyJoint) {
        keys = new ArrayList<>(keyJoint);
    }

    /**
     * Returns a list of AttributeJoint objects representing keys of a Relation.
     * 
     * @return a list of AttributeJoint objects representing keys of a Relation.
     */
    public List<AttributeJoint> getKeyJoint() {
        return keys;
    }
    
    /**
     * Returns the value of this KeyJoint object in string format.
     * 
     * The format being used is <i>{{obj, obj}, {obj, obj}, {...}, ...}</i>.
     * 
     * @return a string representing this object, if the list is empty or
     * null returns "null" string.
     */
    @Override
    public String toString() {
        String msg = "null";
        try {
            msg = "{" + this.keys.get(0);
            for (int i = 1; i < this.keys.size(); i++)
                msg += ", " + this.keys.get(i);
            msg += "}";
        }
        catch(NullPointerException ex){
            LOG.log(Level.INFO, ex.getMessage(), ex);
        }
        return msg;
    }
    
    /**
     * Adds a new key (AttributeJoint) the this list.
     * 
     * If the list is not instantiated, instantiates it.
     * 
     * @param key key to be added.
     */
    public void addKey(AttributeJoint key) {
        if (this.keys == null)
            this.keys = new ArrayList<>();
        this.keys.add(key);
    }
    
    /**
     * Returns an Iterator other the AttributeJoint objects list.
     * 
     * @return an iterator other the AttributeJoint objects list.
     */
    @Override
    public Iterator<AttributeJoint> iterator() {
        return this.keys.iterator();
    }
    
    /**
     * Returns how many keys are in the list.
     * 
     * @return how many keys are in the list.
     */
    public int getSize() {
        try {
            return this.keys.size();            
        }
        catch (NullPointerException ex) {
            LOG.log(Level.INFO, ex.getMessage(), ex);
        }
        return 0;
    }

    /**
     * Returns the key from {@code index} position.
     * 
     * If {@code index} is out of bonds returns a null.
     * 
     * @param index the position of key to return.
     * @return the key from position {@code index}
     */
    public AttributeJoint getKey(int index) {
        try {
            return this.keys.get(index);
        }
        catch (IndexOutOfBoundsException ex) {
            LOG.log(Level.INFO, ex.getMessage(), ex);
        }
        return null;
    }

    /**
     * Returns a hash code for this key joint.
     * 
     * The hash code for a KeyJoint object is
     * computed using the default implementations of Eclipse.
     * 
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((keys == null) ? 0 : keys.hashCode());
        return result;
    }

    /**
     * Compares this KeyJoint to the specified object.
     * 
     * The result is true if and only if the argument
     * is not null and is a KeyJoint object that represents
     * the same attribute joint list as this object. It uses 
     * eclipse default implementation.
     * 
     * @param keyJoint The object to compare this KeyJoint against.
     * @return true if the given object represents a KeyJoint
     * equivalent to this keys list, false otherwise.
     */
    @Override
    public boolean equals(Object keyJoint) {
        try {
            if (getClass() != keyJoint.getClass())<commit_msg>Fix SonarQube issue<commit_after>/**
 * 
 */
package datastructures;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author <NAME>
 *
 */
public class KeyJoint implements Iterable<AttributeJoint> {
    private List<AttributeJoint> keys;
    private static final Logger LOG = Logger.getLogger(KeyJoint.class.getName());

    /**
     * Constructs a Null list of AttributeJoints representing keys of a Relation.
     */
    public KeyJoint() {
        // Manually generated default constructor.
    }
    
    /**
     * Constructs an list of AttributesJoint representing Relation keys.
     * 
     * Every AttributeJoint from {@code keyJoint} must be a key.
     * 
     * @param keyJoint An array of String object.
     */
    public KeyJoint(List<AttributeJoint> keyJoint) {
        keys = new ArrayList<>(keyJoint);
    }

    /**
     * Returns a list of AttributeJoint objects representing keys of a Relation.
     * 
     * @return a list of AttributeJoint objects representing keys of a Relation.
     */
    public List<AttributeJoint> getKeyJoint() {
        return keys;
    }
    
    /**
     * Returns the value of this KeyJoint object in string format.
     * 
     * The format being used is <i>{{obj, obj}, {obj, obj}, {...}, ...}</i>.
     * 
     * @return a string representing this object, if the list is empty or
     * null returns "null" string.
     */
    @Override
    public String toString() {
        String msg = "null";
        try {
            msg = "{" + this.keys.get(0);
            for (int i = 1; i < this.keys.size(); i++)
                msg += ", " + this.keys.get(i);
            msg += "}";
        }
        catch(NullPointerException ex){
            LOG.log(Level.INFO, ex.getMessage(), ex);
        }
        return msg;
    }
    
    /**
     * Adds a new key (AttributeJoint) the this list.
     * 
     * If the list is not instantiated, instantiates it.
     * 
     * @param key key to be added.
     */
    public void addKey(AttributeJoint key) {
        if (this.keys == null)
            this.keys = new ArrayList<>();
        this.keys.add(key);
    }
    
    /**
     * Returns an Iterator other the AttributeJoint objects list.
     * 
     * @return an iterator other the AttributeJoint objects list.
     */
    @Override
    public Iterator<AttributeJoint> iterator() {
        return this.keys.iterator();
    }
    
    /**
     * Returns how many keys are in the list.
     * 
     * @return how many keys are in the list.
     */
    public int getSize() {
        try {
            return this.keys.size();            
        }
        catch (NullPointerException ex) {
            LOG.log(Level.INFO, ex.getMessage(), ex);
        }
        return 0;
    }

    /**
     * Returns the key from {@code index} position.
     * 
     * If {@code index} is out of bonds returns a null.
     * 
     * @param index the position of key to return.
     * @return the key from position {@code index}
     */
    public AttributeJoint getKey(int index) {
        try {
            return this.keys.get(index);
        }
        catch (IndexOutOfBoundsException ex) {
            LOG.log(Level.INFO, ex.getMessage(), ex);
        }
        return null;
    }

    /**
     * Returns a hash code for this key joint.
     * 
     * The hash code for a KeyJoint object is
     * computed using the default implementations of Eclipse.
     * 
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((keys == null) ? 0 : keys.hashCode());
        return result;
    }

    /**
     * Compares this KeyJoint to the specified object.
     * 
     * The result is true if and only if the argument
     * is not null and is a KeyJoint object that represents
     * the same attribute joint list as this object. It uses 
     * eclipse default implementation.
     * 
     * @param keyJoint The object to compare this KeyJoint against.
     * @return true if the given object represents a KeyJoint
     * equivalent to this keys list, false otherwise.
     */
    @Override
    public boolean equals(Object keyJoint) {
        try {
            if (keyJoint != null && getClass() != keyJoint.getClass())
{'fraction_non_alphanumeric': 0.10230646266270838, 'fraction_numerical': 0.0015985384791048184, 'mean_word_length': 1.9012918184829413, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6334067', 'n_tokens_mistral': 2515, 'n_tokens_neox': 2388, 'n_words': 849}