You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb <se...@gmail.com> on 2011/03/03 01:19:38 UTC

Re: svn commit: r1076446 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/collection/FilteredIterable.java test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java

On 2 March 2011 22:55,  <mb...@apache.org> wrote:
> Author: mbenson
> Date: Wed Mar  2 22:55:02 2011
> New Revision: 1076446
>
> URL: http://svn.apache.org/viewvc?rev=1076446&view=rev
> Log:
> add FilteredIterable
>
> Added:
>    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java   (with props)
>    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java   (with props)
>
> Added: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java
> URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java?rev=1076446&view=auto
> ==============================================================================
> --- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java (added)
> +++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterable.java Wed Mar  2 22:55:02 2011
> @@ -0,0 +1,172 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.commons.functor.core.collection;
> +
> +import java.util.Collections;
> +import java.util.Iterator;
> +
> +import org.apache.commons.functor.UnaryFunction;
> +import org.apache.commons.functor.UnaryPredicate;
> +import org.apache.commons.functor.core.IsInstance;
> +import org.apache.commons.functor.core.composite.UnaryAnd;
> +
> +/**
> + * Adds a fluent filtering API to any {@link Iterable}.
> + *
> + * @version $Revision$ $Date$
> + *
> + * @param <T>
> + */
> +public class FilteredIterable<T> implements Iterable<T> {
> +    @SuppressWarnings({ "rawtypes", "unchecked" })
> +    // type irrelevant for empty instance
> +    private static final FilteredIterable EMPTY = new FilteredIterable(Collections.EMPTY_LIST) {

BTW, using Collections.emptyList() instead should allow the @Suppress
tag to be removed.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1076446 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/collection/FilteredIterable.java test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java

Posted by Matt Benson <gu...@gmail.com>.
On Mar 2, 2011, at 6:19 PM, sebb wrote:

> On 2 March 2011 22:55,  <mb...@apache.org> wrote:
>> Author: mbenson
>> Date: Wed Mar  2 22:55:02 2011
>> New Revision: 1076446
>> 
>> URL: http://svn.apache.org/viewvc?rev=1076446&view=rev
>> Log:
>> add FilteredIterable
[SNIP]

>> +public class FilteredIterable<T> implements Iterable<T> {
>> +    @SuppressWarnings({ "rawtypes", "unchecked" })
>> +    // type irrelevant for empty instance
>> +    private static final FilteredIterable EMPTY = new FilteredIterable(Collections.EMPTY_LIST) {
> 
> BTW, using Collections.emptyList() instead should allow the @Suppress
> tag to be removed.
> 

Except that the local instance is itself a raw instance of the containing parameterized type.  ;)

Matt

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org