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

com.github.grzesiek_galezowski.collections.readonly.implementation.ReadOnlyDequeWrapper 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.ReadOnlyCollectionIterator;
import com.github.grzesiek_galezowski.collections.readonly.interfaces.ReadOnlyDeque;

import java.io.Serializable;
import java.util.Deque;

public class ReadOnlyDequeWrapper
    extends ReadOnlyQueueWrapper
    implements ReadOnlyDeque, Serializable {

    private final Deque original;

    public ReadOnlyDequeWrapper(final Deque original) {
        super(original);
        this.original = original;
    }

    @Override
    public T getFirst() {
        return original.getFirst();
    }

    @Override
    public T getLast() {
        return original.getLast();
    }

    @Override
    public T peekFirst() {
        return original.peekFirst();
    }

    @Override
    public T peekLast() {
        return original.peekLast();
    }

    @Override
    public ReadOnlyCollectionIterator descendingIterator() {
        return new ReadOnlyCollectionIteratorWrapper<>(original.descendingIterator());
    }

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

        ReadOnlyDequeWrapper that = (ReadOnlyDequeWrapper) o;

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

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy