[prev in list] [next in list] [prev in thread] [next in thread] 

List:       forgerock-commons
Subject:    [Commons] [2587] forgerock-util/trunk/src: COMMONS-6 (CMN-36) Remove Iterables homebrew in favor of 
From:       noreply () forgerock ! org
Date:       2014-10-30 15:37:18
Message-ID: 20141030153718.489743F86E () sources ! internal ! forgerock ! com
[Download RAW message or body]

[Attachment #2 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2587] forgerock-util/trunk/src: COMMONS-6 (CMN-36) Remove Iterables homebrew \
in favor of guava implementation</title> </head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt;  } #msg dl a { font-weight: \
bold} #msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
 #patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
                .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://sources.forgerock.org/changelog/commons/?cs=2587">2587</a></dd> \
<dt>Author</dt> <dd>brmiller</dd> <dt>Date</dt> <dd>2014-10-30 15:37:18 +0000 (Thu, \
30 Oct 2014)</dd> </dl>

<h3>Log Message</h3>
<pre>COMMONS-6 (CMN-36) Remove Iterables homebrew in favor of guava \
implementation</pre>

<h3>Removed Paths</h3>
<ul>
<li><a href="#forgerockutiltrunksrcmainjavaorgforgerockutilIterablesjava">forgerock-util/trunk/src/main/java/org/forgerock/util/Iterables.java</a></li>
 <li><a href="#forgerockutiltrunksrctestjavaorgforgerockutilIterablesTestjava">forgerock-util/trunk/src/test/java/org/forgerock/util/IterablesTest.java</a></li>
 </ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="forgerockutiltrunksrcmainjavaorgforgerockutilIterablesjava"></a>
<div class="delfile"><h4>Deleted: \
forgerock-util/trunk/src/main/java/org/forgerock/util/Iterables.java (2586 => \
2587)</h4> <pre class="diff"><span>
<span class="info">--- \
forgerock-util/trunk/src/main/java/org/forgerock/util/Iterables.java	2014-10-30 \
                15:33:13 UTC (rev 2586)
+++ forgerock-util/trunk/src/main/java/org/forgerock/util/Iterables.java	2014-10-30 \
15:37:18 UTC (rev 2587) </span><span class="lines">@@ -1,355 +0,0 @@
</span><del>-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * &quot;Portions Copyrighted [year] [name of copyright owner]&quot;
- */
-
-package org.forgerock.util;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-
-/**
- * Iterable utilties.
- */
-public class Iterables {
-    /**
-     * An {@link Iterable} that will filter the provided {@link Iterable}
-     * using a {@link Predicate}.
-     */
-    private static class FilteredIterable&lt;T&gt; implements Iterable&lt;T&gt; {
-
-        /** the Iterable to filter */
-        private final Iterable&lt;T&gt; iterable;
-
-        /** the Predicate to determine inclusion or exclusion */
-        private final Predicate&lt;T&gt; predicate;
-
-        /**
-         * Construct the FilteredIterable.
-         *
-         * @param iterable the Iterable to filter
-         * @param predicate the Predicate to determine inclusion
-         */
-        private FilteredIterable(Iterable&lt;T&gt; iterable, Predicate&lt;T&gt; \
                predicate) {
-            this.iterable = iterable;
-            this.predicate = predicate;
-        }
-
-        /**
-         * Return an {@link Iterator} that filters objects according to the \
                Predicate.
-         *
-         * @return the filtered iterator.
-         */
-        @Override
-        public Iterator&lt;T&gt; iterator() {
-            return new Iterator&lt;T&gt;() {
-                final Iterator&lt;T&gt; oIterator = iterable.iterator();
-                T nextElement = null;
-
-                @Override
-                public boolean hasNext() {
-                    if (nextElement != null) {
-                        // fail-fast for next() or repeated hasNext() calls
-                        return true;
-                    }
-
-                    while (oIterator.hasNext()) {
-                        nextElement = oIterator.next();
-                        if (predicate.apply(nextElement)) {
-                            return true;
-                        }
-                        nextElement = null;
-                    }
-                    return false;
-                }
-
-                @Override
-                public T next() {
-                    if (!hasNext()) { // ensure hasNext() has &quot;advanced&quot; \
                the next &quot;filtered-in&quot; element
-                        throw new NoSuchElementException();
-                    }
-
-                    // return next element and reset for next iteration
-                    T retValue = nextElement;
-                    nextElement = null;
-                    return retValue;
-                }
-
-                @Override
-                public void remove() {
-                    oIterator.remove();
-                }
-            };
-        }
-    }
-
-    /**
-     * An {@link Iterable} that will apply a {@link Function} on the elements of
-     * the provided {@link Iterable}.
-     */
-    private static class MappedIterable&lt;T, R, E extends RuntimeException&gt; \
                implements Iterable&lt;R&gt; {
-
-        /** the Iterable to map */
-        private final Iterable&lt;T&gt; iterable;
-
-        /** the function to map across the elements */
-        private final Function&lt;T, R, E&gt; mapper;
-
-        /**
-         * Construct the MappedIterable.
-         *
-         * @param iterable the Iterable to map
-         * @param mapper the mapper function to apply
-         */
-        private MappedIterable(Iterable&lt;T&gt; iterable, Function&lt;T, R, E&gt; \
                mapper) {
-            this.iterable = iterable;
-            this.mapper = mapper;
-        }
-
-        /**
-         * Return an {@link Iterator} that maps objects according to the mapper \
                function.
-         *
-         * @return the mapped iterator.
-         */
-        @Override
-        public Iterator&lt;R&gt; iterator() {
-            return new Iterator&lt;R&gt;() {
-                final Iterator&lt;T&gt; oIterator = iterable.iterator();
-
-                @Override
-                public boolean hasNext() {
-                    return oIterator.hasNext();
-                }
-
-                @Override
-                public R next() {
-                    return mapper.apply(oIterator.next());
-                }
-
-                @Override
-                public void remove() {
-                    oIterator.remove();
-                }
-            };
-        }
-    }
-
-    /**
-     * An {@link Iterable} providing fluent expressions of
-     * &lt;ul&gt;
-     * &lt;li&gt;{@link Iterables#filter}&lt;/li&gt;
-     * &lt;li&gt;{@link Iterables#map}&lt;/li&gt;
-     * &lt;/ul&gt;
-     *
-     * @param &lt;T&gt; The parameterized element type of the {@link Iterable}.
-     */
-    public static class FluentIterable&lt;T&gt; implements Iterable&lt;T&gt; {
-        /** The Iterable to wrap */
-        private final Iterable&lt;T&gt; iterable;
-
-        /**
-         * Construct the wrapped Iterable from &lt;em&gt;iterable&lt;/em&gt;.
-         *
-         * @param iterable the Iterable to wrap
-         */
-        private FluentIterable(Iterable&lt;T&gt; iterable) {
-            this.iterable = iterable;
-        }
-
-        /**
-         * Return the wrapped Iterable's {@link Iterator}.
-         *
-         * @return the iterator.
-         */
-        @Override
-        public Iterator&lt;T&gt; iterator() {
-            return iterable.iterator();
-        }
-
-        /**
-         * Filter the wrapped Iterable according the given {@link Predicate}.
-         *
-         * @param predicate the {@linkplain Predicate} used to include elements in \
                the filtered result
-         * @return the filtered {@linkplain Iterable}
-         */
-        public FluentIterable&lt;T&gt; filter(final Predicate&lt;T&gt; predicate) {
-            return new FluentIterable&lt;T&gt;(new \
                FilteredIterable&lt;T&gt;(iterable, predicate));
-        }
-
-        /**
-         * Map the wrapped Iterable according the given {@link Function}.
-         *
-         * @param &lt;R&gt; The parameterized element type of the transform \
                function's output,
-         *           also the returned element type of the new Iterable
-         * @param &lt;E&gt; An optional exception that the transform function may \
                throw.
-         * @param mapper the {@linkplain Function} used to map elements from source \
                type to return type
-         * @return the mapped {@linkplain Iterable}
-         */
-        public &lt;R, E extends RuntimeException&gt; FluentIterable&lt;R&gt; \
                map(final Function&lt;T, R, E&gt; mapper) {
-            return new FluentIterable&lt;R&gt;(new MappedIterable&lt;T, R, \
                E&gt;(iterable, mapper));
-        }
-    }
-
-    private Iterables() {
-        // prevent construction
-    }
-
-    /**
-     * Filter an {@link Iterable} according to a {@link Predicate}. The
-     * {@link Predicate} determines which elements are
-     * &lt;em&gt;filtered &lt;strong&gt;in&lt;/strong&gt;&lt;/em&gt;.
-     *
-     * &lt;pre&gt;
-     * List&amp;lt;String&amp;gt; fruit = new ArrayList&amp;lt;String&amp;gt;();
-     * fruit.add(&amp;quot;apple&amp;quot;);
-     * fruit.add(&amp;quot;pineapple&amp;quot;);
-     * fruit.add(&amp;quot;banana&amp;quot;);
-     * fruit.add(&amp;quot;orange&amp;quot;);
-     * fruit.add(&amp;quot;pear&amp;quot;);
-     * return filter(fruit, new Predicate&amp;lt;String&amp;gt;() {
-     *     public boolean apply(String fruit) {
-     *         return fruit.startsWith(&amp;quot;p&amp;quot;);
-     *     }
-     * });
-     * &lt;/pre&gt;
-     *
-     * would return
-     *
-     * &lt;pre&gt;
-     *     [ &quot;pineapple, &quot;pear&quot; ]
-     * &lt;/pre&gt;
-     *
-     * @param &lt;T&gt;
-     *            the element type
-     * @param iterable
-     *            the {@linkplain Iterable} to filter
-     * @param predicate
-     *            the {@linkplain Predicate} used to include elements in the
-     *            filtered result
-     * @return the filtered {@linkplain Iterable}
-     */
-    public static &lt;T&gt; Iterable&lt;T&gt; filter(Iterable&lt;T&gt; iterable, \
                Predicate&lt;T&gt; predicate) {
-        return new FilteredIterable&lt;T&gt;(iterable, predicate);
-    }
-
-    /**
-     * Create an {@link Iterable} according to a source {@link Iterable} and a
-     * mapper {@link Function}. The {@link Function} transforms the source
-     * elements in the source Iterable.
-     *
-     * &lt;pre&gt;
-     * List&amp;lt;String&amp;gt; fruit = new ArrayList&amp;lt;String&amp;gt;();
-     * fruit.add(&amp;quot;apple&amp;quot;);
-     * fruit.add(&amp;quot;pineapple&amp;quot;);
-     * fruit.add(&amp;quot;banana&amp;quot;);
-     * fruit.add(&amp;quot;orange&amp;quot;);
-     * fruit.add(&amp;quot;pear&amp;quot;);
-     * return map(fruit, new Function&amp;lt;String, Integer, \
                NeverThrowsException&amp;gt;() {
-     *     public Integer apply(String fruit) {
-     *         return fruit.length();
-     *     }
-     * });
-     * &lt;/pre&gt;
-     *
-     * would return an iterable whose elements are
-     *
-     * &lt;pre&gt;
-     *     [ 5, 9, 6, 6, 4 ]
-     * &lt;/pre&gt;
-     *
-     * @param &lt;T&gt;
-     *            the source element type
-     * @param &lt;R&gt;
-     *            the returned iterable element type
-     * @param &lt;E&gt;
-     *            a RuntimeException thrown by the map function
-     * @param iterable
-     *            the source {@linkplain Iterable} to map
-     * @param mapper
-     *            the {@linkplain Function} used to map elements from source
-     *            type to return type
-     * @return the mapped {@linkplain Iterable}
-     */
-    public static &lt;T, R, E extends RuntimeException&gt; Iterable&lt;R&gt; \
                map(Iterable&lt;T&gt; iterable, Function&lt;T, R, E&gt; mapper) {
-        return new MappedIterable&lt;T, R, E&gt;(iterable, mapper);
-    }
-
-    /**
-     * Create a Iterable providing fluent expressions of
-     * &lt;ul&gt;
-     * &lt;li&gt;{@link Iterables#filter}&lt;/li&gt;
-     * &lt;li&gt;{@link Iterables#map}&lt;/li&gt;
-     * &lt;/ul&gt;
-     * &lt;p&gt;
-     * Given
-     *
-     * &lt;pre&gt;
-     * List&amp;lt;String&amp;gt; fruit = new ArrayList&amp;lt;String&amp;gt;();
-     * fruit.add(&amp;quot;apple&amp;quot;);
-     * fruit.add(&amp;quot;pineapple&amp;quot;);
-     * fruit.add(&amp;quot;banana&amp;quot;);
-     * fruit.add(&amp;quot;orange&amp;quot;);
-     * fruit.add(&amp;quot;pear&amp;quot;);
-     *
-     * final Predicate&amp;lt;String&amp;gt; pFruits = new \
                Predicate&amp;lt;String&amp;gt;() {
-     *     public boolean apply(String fruit) {
-     *         return fruit.startsWith(&amp;quot;p&amp;quot;);
-     *     }
-     * };
-     *
-     * final Function&amp;lt;String, Integer, NeverThrowsException&amp;gt; \
                getLengths =
-     *         new Function&amp;lt;String, Integer, NeverThrowsException&amp;gt;() {
-     *             public Integer apply(String fruit) {
-     *                 return fruit.length();
-     *             }
-     *         };
-     * &lt;/pre&gt;
-     *
-     * the invocation
-     *
-     * &lt;pre&gt;
-     * from(fruit).filter(pFruits).map(getLengths);
-     * &lt;/pre&gt;
-     *
-     * is equivalent to
-     *
-     * &lt;pre&gt;
-     * map(filter(fruit, pFruits), getLengths);
-     * &lt;/pre&gt;
-     *
-     * and returns an {@linkplain Iterable} whose elements are
-     *
-     * &lt;pre&gt;
-     *     [ 9, 4 ]
-     * &lt;/pre&gt;
-     *
-     * @param &lt;T&gt;
-     *            The parameterized element type of the Iterable.
-     * @param iterable
-     *            the Iterable to wrap
-     * @return a wrapped {@linkplain Iterable}
-     */
-    public static &lt;T&gt; FluentIterable&lt;T&gt; from(Iterable&lt;T&gt; iterable) \
                {
-        return new FluentIterable&lt;T&gt;(iterable);
-    }
-}
</del></span></pre></div>
<a id="forgerockutiltrunksrctestjavaorgforgerockutilIterablesTestjava"></a>
<div class="delfile"><h4>Deleted: \
forgerock-util/trunk/src/test/java/org/forgerock/util/IterablesTest.java (2586 => \
2587)</h4> <pre class="diff"><span>
<span class="info">--- \
forgerock-util/trunk/src/test/java/org/forgerock/util/IterablesTest.java	2014-10-30 \
                15:33:13 UTC (rev 2586)
+++ forgerock-util/trunk/src/test/java/org/forgerock/util/IterablesTest.java	2014-10-30 \
15:37:18 UTC (rev 2587) </span><span class="lines">@@ -1,208 +0,0 @@
</span><del>-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * &quot;Portions Copyrighted [year] [name of copyright owner]&quot;
- */
-package org.forgerock.util;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.forgerock.util.promise.NeverThrowsException;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.forgerock.util.Iterables.filter;
-import static org.forgerock.util.Iterables.from;
-import static org.forgerock.util.Iterables.map;
-
-
-/**
- * Test the Iterables methods.
- */
-@SuppressWarnings(&quot;javadoc&quot;)
-public class IterablesTest {
-
-    private static final Predicate&lt;String&gt; IGNORE_G_WORDS =
-            new Predicate&lt;String&gt;() {
-                @Override
-                public boolean apply(String s) {
-                    return !s.toLowerCase().startsWith(&quot;g&quot;);
-                }
-            };
-
-    private static final Predicate&lt;String&gt; ALWAYS_TRUE =
-            new Predicate&lt;String&gt;() {
-                @Override
-                public boolean apply(String s) {
-                    return true;
-                }
-            };
-
-    private static final Predicate&lt;String&gt; ALWAYS_FALSE =
-            new Predicate&lt;String&gt;() {
-                @Override
-                public boolean apply(String s) {
-                    return false;
-                }
-            };
-
-    @DataProvider
-    public Object[][] filterCollections() {
-        return new Object[][] {
-                // @formatter:off
-                { new String[] { &quot;goo&quot;, &quot;gah&quot;, &quot;boo&quot;, \
                &quot;bah&quot;, &quot;zoo&quot; }, &quot;bbz&quot; },
-                { new String[] { &quot;boo&quot;, &quot;baz&quot;, &quot;goo&quot;, \
                &quot;gah&quot;, &quot;zoo&quot; }, &quot;bbz&quot; },
-                { new String[] { &quot;boo&quot;, &quot;goo&quot;, &quot;bah&quot;, \
                &quot;zoo&quot;, &quot;gah&quot; }, &quot;bbz&quot; }
-
-                // @formatter:on
-        };
-    }
-
-    @Test(dataProvider = &quot;filterCollections&quot;)
-    public void testFilter(final String[] value, final String firstLetters) {
-        StringBuilder sb = new StringBuilder();
-        for (String element : filter(Arrays.asList(value), IGNORE_G_WORDS)) {
-            sb.append(element.charAt(0));
-        }
-        assertThat(sb.toString()).isEqualTo(firstLetters);
-    }
-
-    @Test
-    public void testNoElementsHasNext()
-    {
-        assertThat(filter(new ArrayList&lt;String&gt;(), \
                ALWAYS_TRUE).iterator().hasNext()).isFalse();
-    }
-
-    @Test(expectedExceptions = NoSuchElementException.class)
-    public void testNoElementsNext()
-    {
-        filter(new ArrayList&lt;String&gt;(), ALWAYS_TRUE).iterator().next();
-    }
-
-    @Test
-    public void testNextWithoutHasNextTruePredicate()
-    {
-        assertThat(filter(Arrays.asList(new String[] { &quot;a&quot; }), \
                ALWAYS_TRUE).iterator().next()).isEqualTo(&quot;a&quot;);
-    }
-
-    @Test(expectedExceptions = NoSuchElementException.class)
-    public void testNextWithoutHasNextFalsePredicate()
-    {
-        filter(Arrays.asList(new String[] { &quot;a&quot; }), \
                ALWAYS_FALSE).iterator().next();
-    }
-
-    @Test
-    public void testRemoveTruePredicate()
-    {
-        List&lt;String&gt; list = new ArrayList&lt;String&gt;();
-        list.add(&quot;a&quot;);
-        Iterator&lt;String&gt; iterator = filter(list, ALWAYS_TRUE).iterator();
-        assertThat(iterator.next()).isEqualTo(&quot;a&quot;);
-        iterator.remove();
-        assertThat(list.contains(&quot;a&quot;)).isFalse();
-    }
-
-    @Test(expectedExceptions = IllegalStateException.class)
-    public void testRemoveFalsePredicate()
-    {
-        List&lt;String&gt; list = new ArrayList&lt;String&gt;();
-        list.add(&quot;a&quot;);
-        filter(list, ALWAYS_FALSE).iterator().remove();
-    }
-
-    @Test(expectedExceptions = IllegalStateException.class)
-    public void testRemoveEmpty()
-    {
-        filter(new ArrayList&lt;String&gt;(), ALWAYS_TRUE).iterator().remove();
-    }
-
-    private static final Function&lt;String, Character, NeverThrowsException&gt; \
                FIRST_LETTERS =
-            new Function&lt;String, Character, NeverThrowsException&gt;() {
-                @Override
-                public Character apply(String value) throws NeverThrowsException {
-                    return value.charAt(0);
-                }
-            };
-
-    @DataProvider
-    public Object[][] mapCollections() {
-        return new Object[][] {
-                // @formatter:off
-                { new String[] { &quot;goo&quot;, &quot;gah&quot;, &quot;boo&quot;, \
                &quot;bah&quot;, &quot;zoo&quot; }, &quot;ggbbz&quot; },
-                { new String[] { &quot;boo&quot;, &quot;baz&quot;, &quot;goo&quot;, \
                &quot;gah&quot;, &quot;zoo&quot; }, &quot;bbggz&quot; },
-                { new String[] { &quot;boo&quot;, &quot;goo&quot;, &quot;bah&quot;, \
                &quot;zoo&quot;, &quot;gah&quot; }, &quot;bgbzg&quot; }
-                // @formatter:on
-        };
-    }
-
-    @Test(dataProvider = &quot;mapCollections&quot;)
-    public void testMap(final String[] value, final String firstLetters) {
-        StringBuilder sb = new StringBuilder();
-        for (Character element : map(Arrays.asList(value), FIRST_LETTERS)) {
-            sb.append(element);
-        }
-        assertThat(sb.toString()).isEqualTo(firstLetters);
-    }
-
-    @Test(dataProvider = &quot;filterCollections&quot;)
-    public void test_Filter(final String[] value, final String firstLetters) {
-        StringBuilder sb = new StringBuilder();
-        for (String element : from(Arrays.asList(value)).filter(IGNORE_G_WORDS)) {
-            sb.append(element.charAt(0));
-        }
-        assertThat(sb.toString()).isEqualTo(firstLetters);
-    }
-
-    @Test(dataProvider = &quot;mapCollections&quot;)
-    public void test_Map(final String[] value, final String firstLetters) {
-        StringBuilder sb = new StringBuilder();
-        for (Character element : from(Arrays.asList(value)).map(FIRST_LETTERS)) {
-            sb.append(element);
-        }
-        assertThat(sb.toString()).isEqualTo(firstLetters);
-    }
-
-    @DataProvider
-    public Object[][] filterAndMapCollections() {
-        return new Object[][] {
-                // @formatter:off
-                { new String[] { &quot;goo&quot;, &quot;gah&quot;, &quot;boo&quot;, \
                &quot;bah&quot;, &quot;zoo&quot; }, &quot;bbz&quot; },
-                { new String[] { &quot;boo&quot;, &quot;baz&quot;, &quot;goo&quot;, \
                &quot;gah&quot;, &quot;zoo&quot; }, &quot;bbz&quot; },
-                { new String[] { &quot;boo&quot;, &quot;goo&quot;, &quot;bah&quot;, \
                &quot;zoo&quot;, &quot;gah&quot; }, &quot;bbz&quot; }
-                // @formatter:on
-        };
-    }
-
-    @Test(dataProvider = &quot;filterAndMapCollections&quot;)
-    public void test_FilterAndMap(final String[] value, final String firstLetters) {
-        StringBuilder sb = new StringBuilder();
-        for (Character element : \
                from(Arrays.asList(value)).filter(IGNORE_G_WORDS).map(FIRST_LETTERS)) \
                {
-            sb.append(element);
-        }
-        assertThat(sb.toString()).isEqualTo(firstLetters);
-    }
-
-}
</del></span></pre>
</div>
</div>
<div id="footer">Copyright (c) by ForgeRock. All rights reserved.</div>

</body>
</html>



_______________________________________________
Commons mailing list
Commons@forgerock.org
https://lists.forgerock.org/mailman/listinfo/commons


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic