org.abego.commons.seq.AbstractSeq Maven / Gradle / Ivy
/*
* MIT License
*
* Copyright (c) 2020 Udo Borkowski, ([email protected])
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.abego.commons.seq;
import org.eclipse.jdt.annotation.Nullable;
import java.util.Comparator;
import java.util.function.Function;
import java.util.function.Predicate;
import static org.abego.commons.lang.IterableUtil.hashCodeForIterable;
import static org.abego.commons.lang.IterableUtil.toStringOfIterable;
public abstract class AbstractSeq implements Seq {
@Override
public Seq filter(Predicate condition) {
return SeqUtil.filter(this, condition);
}
@Override
public Seq map(Function super T, ? extends R> mapper) {
return SeqUtil.map(this, mapper);
}
@Override
public > Seq sortedBy(Function sortKey) {
return SeqUtil.sortedBy(this, sortKey);
}
@Override
public Seq sorted() {
return SeqUtil.sorted(this);
}
@Override
public Seq sorted(Comparator super T> comparator) {
return SeqUtil.sorted(this, comparator);
}
@Override
public boolean equals(@Nullable Object o) {
if (!(o instanceof Seq)) return false;
return SeqHelper.seqsAreEqual(this, (Seq>) o);
}
@Override
public int hashCode() {
return hashCodeForIterable(this);
}
/**
* Return this Seq as a String starting with the class name and followed
* by a ", " (comma and space) separated list of the items of the
* Seq in brackets (`[...]`), each item converted using {@link String#valueOf(Object)}.
*/
@Override
public String toString() {
return toStringOfIterable(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy