<commit_before>/**
 * Copyright CSIRO Australian e-Health Research Centre (http://aehrc.com).
 * All rights reserved. Use is subject to license terms and conditions.
 */
package au.csiro.ontology.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * This class represents a conjunction (also referred to as an
 * ObjectIntersectionOf in OWL).
 * 
 * @author <NAME>
 * 
 */
public class Conjunction implements IConjunction {

    final private IConcept[] concepts;
    final private int hashCode;

    public Conjunction(final IConcept[] concepts) {
        final SortedSet<IConcept> sorted = new TreeSet<IConcept>();
        for (IConcept concept : concepts) {
            sorted.add(concept);
        }
        this.concepts = sorted.toArray(new IConcept[sorted.size()]);
        hashCode = sorted.hashCode();
    }

    public Conjunction(final Collection<? extends IConcept> concepts) {
        // Store the concepts in hashCode order so that equals() is order
        // independent, i.e. conjunctions are reflexive (should also be
        // transitive, but Agile says STTCPW)

        final SortedSet<IConcept> sorted = new TreeSet<>(
                concepts);
        this.concepts = sorted.toArray(new IConcept[sorted.size()]);
        hashCode = sorted.hashCode();
    }

    public IConcept[] getConcepts() {
        return concepts;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        sb.append(concepts[0]);
        for (int i = 1; i < concepts.length; i++) {
            sb.append(" + ");
            sb.append(concepts[i]);
        }
        sb.append(")");
        return sb.toString();
    }

    @Override
    public int hashCode() {
        return hashCode;
    }
<commit_msg>fix toString bug when Conjunction is empty<commit_after>/**
 * Copyright CSIRO Australian e-Health Research Centre (http://aehrc.com).
 * All rights reserved. Use is subject to license terms and conditions.
 */
package au.csiro.ontology.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * This class represents a conjunction (also referred to as an
 * ObjectIntersectionOf in OWL).
 * 
 * @author <NAME>
 * 
 */
public class Conjunction implements IConjunction {

    final private IConcept[] concepts;
    final private int hashCode;

    public Conjunction(final IConcept[] concepts) {
        final SortedSet<IConcept> sorted = new TreeSet<IConcept>();
        for (IConcept concept : concepts) {
            sorted.add(concept);
        }
        this.concepts = sorted.toArray(new IConcept[sorted.size()]);
        hashCode = sorted.hashCode();
    }

    public Conjunction(final Collection<? extends IConcept> concepts) {
        // Store the concepts in hashCode order so that equals() is order
        // independent, i.e. conjunctions are reflexive (should also be
        // transitive, but Agile says STTCPW)

        final SortedSet<IConcept> sorted = new TreeSet<>(
                concepts);
        this.concepts = sorted.toArray(new IConcept[sorted.size()]);
        hashCode = sorted.hashCode();
    }

    public IConcept[] getConcepts() {
        return concepts;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        if (concepts.length > 0) {
            sb.append(concepts[0]);
            for (int i = 1; i < concepts.length; i++) {
                sb.append(" + ");
                sb.append(concepts[i]);
            }
        }
        sb.append(")");
        return sb.toString();
    }

    @Override
    public int hashCode() {
        return hashCode;
    }

{'fraction_non_alphanumeric': 0.113107822410148, 'fraction_numerical': 0.001321353065539112, 'mean_word_length': 2.440909090909091, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 16, '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': '3021258', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1071, 'n_words': 309}