Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.util.stream;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.function.DoubleBinaryOperator;
import java.util.function.DoubleConsumer;
import java.util.function.DoublePredicate;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.IntConsumer;
import java.util.function.IntFunction;
import java.util.function.IntPredicate;
import java.util.function.IntUnaryOperator;
import java.util.function.LongBinaryOperator;
import java.util.function.LongConsumer;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
* LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
*/
public class LambdaTestHelpers {
public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
@SuppressWarnings("rawtypes")
public static final Consumer bEmpty = x -> { };
@SuppressWarnings("rawtypes")
public static final IntConsumer bIntEmpty = x -> { };
@SuppressWarnings("rawtypes")
public static final BiConsumer bBiEmpty = (x,y) -> { };
@SuppressWarnings("rawtypes")
public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
@SuppressWarnings("rawtypes")
public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
public static final Function mZero = x -> 0;
public static final Function mId = x -> x;
public static final Function mDoubler = x -> x * 2;
public static final Function> mfId = e -> Collections.singletonList(e).stream();
public static final Function> mfNull = e -> Collections.emptyList().stream();
public static final Function> mfLt = e -> {
List l = new ArrayList<>();
for (int i=0; i imDoubler = x -> x * 2;
public static final ToLongFunction lmDoubler = x -> x * 2;
public static final ToDoubleFunction dmDoubler = x -> x * 2;
public static final Predicate pFalse = x -> false;
public static final Predicate pTrue = x -> true;
public static final Predicate pEven = x -> 0 == x % 2;
public static final Predicate pOdd = x -> 1 == x % 2;
public static final IntPredicate ipFalse = x -> false;
public static final IntPredicate ipTrue = x -> true;
public static final IntPredicate ipEven = x -> 0 == x % 2;
public static final IntPredicate ipOdd = x -> 1 == x % 2;
public static final LongPredicate lpFalse = x -> false;
public static final LongPredicate lpTrue = x -> true;
public static final LongPredicate lpEven = x -> 0 == x % 2;
public static final LongPredicate lpOdd = x -> 1 == x % 2;
public static final DoublePredicate dpFalse = x -> false;
public static final DoublePredicate dpTrue = x -> true;
public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
public static final BinaryOperator rPlus = (x, y) -> x+y;
public static final BinaryOperator rMax = (x, y) -> Math.max(x, y);
public static final BinaryOperator rMin = (x, y) -> Math.min(x,y);
public static final IntBinaryOperator irPlus = (x, y) -> x+y;
public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
public static final IntUnaryOperator irDoubler = x -> x * 2;
public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
public static final Comparator cInteger = (a, b) -> Integer.compare(a, b);
public static final BiPredicate, ?> bipFalse = (x, y) -> false;
public static final BiPredicate, ?> bipTrue = (x, y) -> true;
public static final BiPredicate bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
public static final BiPredicate bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
public static final BiPredicate, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
public static final IntFunction integerArrayGenerator = s -> new Integer[s];
public static final IntFunction