<commit_before>package net.ripe.commons.ip;

import java.io.Serializable;
import java.util.NoSuchElementException;

public abstract class Optional<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final Optional<?> ABSENT = new Absent<Object>();

    public static <T> Optional<T> of(T value) {
        return value != null ? new Present<T>(value) : Optional.<T>absent();
    }

    @SuppressWarnings("unchecked")
    public static <T> Optional<T> absent() {
        return (Optional<T>) ABSENT;
    }

    public static <T> T getOrNull(Optional<T> optional) {
        return optional.isPresent() ? optional.get() : null;
    }

    public abstract T get();

    public abstract boolean isPresent();

    public boolean isAbsent() {
        return !isPresent();
    }

    public static final class Present<T> extends Optional<T> {

        private final T value;

        private Present(T value) {
            this.value = value;
        }

        @Override
        public T get() {
            return value;
        }

        @Override
        public boolean isPresent() {
            return true;
        }

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

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

    public static final class Absent<T> extends Optional<T> {

        @Override
        public T get() {
            throw new NoSuchElementException("Absent.get");
        }

        @Override
        public boolean isPresent() {
            return false;
        }
    }
}
<commit_msg>If statements must use braces (sonar violation)<commit_after>package net.ripe.commons.ip;

import java.io.Serializable;
import java.util.NoSuchElementException;

public abstract class Optional<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final Optional<?> ABSENT = new Absent<Object>();

    public static <T> Optional<T> of(T value) {
        return value != null ? new Present<T>(value) : Optional.<T>absent();
    }

    @SuppressWarnings("unchecked")
    public static <T> Optional<T> absent() {
        return (Optional<T>) ABSENT;
    }

    public static <T> T getOrNull(Optional<T> optional) {
        return optional.isPresent() ? optional.get() : null;
    }

    public abstract T get();

    public abstract boolean isPresent();

    public boolean isAbsent() {
        return !isPresent();
    }

    public static final class Present<T> extends Optional<T> {

        private final T value;

        private Present(T value) {
            this.value = value;
        }

        @Override
        public T get() {
            return value;
        }

        @Override
        public boolean isPresent() {
            return true;
        }

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

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

    public static final class Absent<T> extends Optional<T> {

        @Override
        public T get() {
            throw new NoSuchElementException("Absent.get");
        }

        @Override
        public boolean isPresent() {
            return false;
        }
    }
}

{'fraction_non_alphanumeric': 0.10260499734183945, 'fraction_numerical': 0.000531632110579479, 'mean_word_length': 1.9193173002327386, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '5324583', 'n_tokens_mistral': 1025, 'n_tokens_neox': 987, 'n_words': 298}