net.sf.staccatocommons.collections.stream.impl.internal.DeconsTransformStream Maven / Gradle / Ivy
/**
* Copyright (c) 2011, The Staccato-Commons Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
package net.sf.staccatocommons.collections.stream.impl.internal;
import net.sf.staccatocommons.collections.stream.Stream;
import net.sf.staccatocommons.lang.tuple.Pair;
/**
* @author flbulgarelli
*
* @param
* @param
*/
public final class DeconsTransformStream extends AbstractTransformStream {
private final DeconsApplicable function;
/**
* Creates a new {@link DeconsTransformStream}
*/
public DeconsTransformStream(Stream stream, DeconsApplicable function) {
super(stream);
this.function = function;
}
@Override
protected Stream apply() {
if (getStream().isEmpty())
return function.emptyApply();
Pair> decons = getStream().decons();
return function.apply(decons._0(), decons._1());
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy