
com.github.sirikid.iterators.EmptySpliterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maybe Show documentation
Show all versions of maybe Show documentation
Implementation Maybe monad in Java
The newest version!
/*
* Copyright (c) 2016, Ivan Sokolov. All rights reserved.
* This code is licensed under MIT license (see LICENSE for details)
*/
package com.github.sirikid.iterators;
import java.util.Spliterator;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import static java.util.Objects.requireNonNull;
/**
* Empty spliterator. Use it when need return a spliterator, but you have no elements.
*
* @author Ivan Sokolov
* @version 1.0.0
* @param type of elements
* @see EmptyIterator
* @since 1.0.0
*/
public class EmptySpliterator implements Spliterator {
@Override
public boolean tryAdvance(Consumer super E> action) {
requireNonNull(action);
return false;
}
@Nullable
@Override
public Spliterator trySplit() {
return null;
}
@Override
public long estimateSize() {
return 0;
}
@Override
public int characteristics() {
return DISTINCT | SIZED | NONNULL | IMMUTABLE | CONCURRENT | SUBSIZED;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy