All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.grzesiek_galezowski.collections.readonly.implementation.ReadOnlyCollectionWrapper Maven / Gradle / Ivy

The newest version!
package com.github.grzesiek_galezowski.collections.readonly.implementation;

import com.github.grzesiek_galezowski.collections.implementation.iterator.ReadOnlyCollectionIteratorWrapper;
import com.github.grzesiek_galezowski.collections.readonly.interfaces.ReadOnlyCollection;
import com.github.grzesiek_galezowski.collections.readonly.interfaces.ReadOnlyCollectionIterator;

import java.io.Serializable;
import java.util.Collection;
import java.util.Spliterator;
import java.util.function.IntFunction;
import java.util.stream.Stream;

public class ReadOnlyCollectionWrapper implements ReadOnlyCollection, Serializable {
    private final Collection original;

    public ReadOnlyCollectionWrapper(final Collection original) {
        this.original = original;
    }



    @Override
    public int size() {
        return original.size();
    }

    @Override
    public boolean isEmpty() {
        return original.isEmpty();
    }

    @Override
    public boolean contains(final Object o) {
        return original.contains(o);
    }

    @Override
    public ReadOnlyCollectionIterator iterator() {
        return new ReadOnlyCollectionIteratorWrapper(original.iterator());
    }

    @Override
    public Object[] toArray() {
        return original.toArray();
    }

    @Override
    public  T1[] toArray(final T1[] a) {
        return original.toArray(a);
    }

    @Override
    public  T1[] toArray(final IntFunction intFunction) {
        return original.stream().toArray(intFunction);
    }

    @Override
    public boolean containsAll(final Collection c) {
        return original.containsAll(c);
    }

    @Override
    public Spliterator spliterator() {
        return original.spliterator();
    }

    @Override
    public Stream stream() {
        return original.stream();
    }

    @Override
    public Stream parallelStream() {
        return original.parallelStream();
    }

    @SuppressWarnings("checkstyle:all")
    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        ReadOnlyCollectionWrapper that = (ReadOnlyCollectionWrapper) o;

        return original != null ? original.equals(that.original) : that.original == null;
    }

    @SuppressWarnings("checkstyle:all")
    @Override
    public int hashCode() {
        return original != null ? original.hashCode() : 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy