<commit_before>package be.wegenenverkeer.atomium.japi.format;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.w3c.dom.Element;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@XmlAccessorType(XmlAccessType.NONE)
public final class Content<T> {

    private static final ThreadLocal<JAXBElementUnmarshaller> jaxbElementUnmarshallerThreadLocal = new ThreadLocal<JAXBElementUnmarshaller>();

    public static void setJAXBElementUnmarshaller(JAXBElementUnmarshaller jaxbElementUnmarshaller) {
        Content.jaxbElementUnmarshallerThreadLocal.set(jaxbElementUnmarshaller);
    }

    public static void resetJAXBElementUnmarshaller() {
        Content.jaxbElementUnmarshallerThreadLocal.remove();
    }

    @XmlAttribute(name="type")
    private String type;

    public String getType() {
        return this.type;
    }

    @XmlAnyElement(lax = true) @XmlMixed @JsonIgnore
    private List objects = new ArrayList();

    @XmlTransient
    private T value;

    public Content() {}

    @SuppressWarnings("unchecked")
    public Content(T value, String type) {
        this.type = type;
        objects.add(value);
        if (value.getClass().isAnnotationPresent(XmlRootElement.class) || value instanceof String) {
            this.value = value;
        } else if (value instanceof JAXBElement) {
            this.value = ((JAXBElement<T>) value).getValue();
        } else {
            this.value = value;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Content content = (Content) o;
        return Objects.equals(type, content.type) && Objects.equals(getValue(), content.getValue());

    }

    @Override
    public int hashCode() {
        return Objects.hash(type, value);
    }

    public T getValue() {
        if (value == null) {
            value = getValueFromObjects();
        }
        return value;
    }

    @SuppressWarnings("unchecked")
    private T getValueFromObjects() {
        StringBuilder buffer = new StringBuilder();
        for (Object o : objects) {<commit_msg>hashCode also based on getValue method<commit_after>package be.wegenenverkeer.atomium.japi.format;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.w3c.dom.Element;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@XmlAccessorType(XmlAccessType.NONE)
public final class Content<T> {

    private static final ThreadLocal<JAXBElementUnmarshaller> jaxbElementUnmarshallerThreadLocal = new ThreadLocal<JAXBElementUnmarshaller>();

    public static void setJAXBElementUnmarshaller(JAXBElementUnmarshaller jaxbElementUnmarshaller) {
        Content.jaxbElementUnmarshallerThreadLocal.set(jaxbElementUnmarshaller);
    }

    public static void resetJAXBElementUnmarshaller() {
        Content.jaxbElementUnmarshallerThreadLocal.remove();
    }

    @XmlAttribute(name="type")
    private String type;

    public String getType() {
        return this.type;
    }

    @XmlAnyElement(lax = true) @XmlMixed @JsonIgnore
    private List objects = new ArrayList();

    @XmlTransient
    private T value;

    public Content() {}

    @SuppressWarnings("unchecked")
    public Content(T value, String type) {
        this.type = type;
        objects.add(value);
        if (value.getClass().isAnnotationPresent(XmlRootElement.class) || value instanceof String) {
            this.value = value;
        } else if (value instanceof JAXBElement) {
            this.value = ((JAXBElement<T>) value).getValue();
        } else {
            this.value = value;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Content content = (Content) o;
        return Objects.equals(type, content.type) && Objects.equals(getValue(), content.getValue());

    }

    @Override
    public int hashCode() {
        return Objects.hash(type, getValue());
    }

    public T getValue() {
        if (value == null) {
            value = getValueFromObjects();
        }
        return value;
    }

    @SuppressWarnings("unchecked")
    private T getValueFromObjects() {
        StringBuilder buffer = new StringBuilder();
        for (Object o : objects) {
{'fraction_non_alphanumeric': 0.10556038227628149, 'fraction_numerical': 0.0004344048653344917, 'mean_word_length': 3.060846560846561, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '6349946', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1326, 'n_words': 299}