Thread: [Japi-cvs] SF.net SVN: japi: [455] libs/util/trunk/src/net/sf/japi/util/Collections2. java
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-06-25 20:35:38
|
Revision: 455 http://svn.sourceforge.net/japi/?rev=455&view=rev Author: christianhujer Date: 2007-06-25 13:34:08 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Fixed some checkstyle issues. Modified Paths: -------------- libs/util/trunk/src/net/sf/japi/util/Collections2.java Modified: libs/util/trunk/src/net/sf/japi/util/Collections2.java =================================================================== --- libs/util/trunk/src/net/sf/japi/util/Collections2.java 2007-06-25 20:32:16 UTC (rev 454) +++ libs/util/trunk/src/net/sf/japi/util/Collections2.java 2007-06-25 20:34:08 UTC (rev 455) @@ -33,7 +33,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @see Collections */ -public class Collections2 { +public final class Collections2 { /** Class of java.util.Arrays.ArrayList */ private static final Class<? extends List<?>> AL; @@ -45,6 +45,10 @@ AL = c; } + /** Utility class - do not instanciate. */ + private Collections2() { + } + /** Returns a collection only containing those elements accepted by the given filter. * The original collection remains unmodified. * This method tries its best to create a new, empty variant of the Collection passed in <var>c</var>: @@ -174,7 +178,4 @@ } } - /** Private constructor - no instances needed. */ - private Collections2() {} - } // class Collections2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-06-30 09:26:19
|
Revision: 466 http://svn.sourceforge.net/japi/?rev=466&view=rev Author: christianhujer Date: 2007-06-30 02:26:17 -0700 (Sat, 30 Jun 2007) Log Message: ----------- Added missing @NotNull / @Nullable annotations. Modified Paths: -------------- libs/util/trunk/src/net/sf/japi/util/Collections2.java Modified: libs/util/trunk/src/net/sf/japi/util/Collections2.java =================================================================== --- libs/util/trunk/src/net/sf/japi/util/Collections2.java 2007-06-30 09:22:22 UTC (rev 465) +++ libs/util/trunk/src/net/sf/japi/util/Collections2.java 2007-06-30 09:26:17 UTC (rev 466) @@ -19,14 +19,16 @@ package net.sf.japi.util; +import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; import java.util.List; -import java.util.Collection; import java.util.RandomAccess; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Comparator; import net.sf.japi.util.filter.Filter; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** This class provides some additional utility methods you might miss in {@link Collections}. * It is named Collections2 so you have no problems using both, this class and <code>java.util.Collections</code> (no name conflict). @@ -61,7 +63,7 @@ * @param filter Filter to use for <var>c</var> * @return collection containing only those elements accepted by the filter or <code>null</code> if the Collection could not be created. */ - public static final <T, C extends Collection<T>> C filter(final C c, final Filter<? super T> filter) { + @Nullable public static <T, C extends Collection<T>> C filter(@NotNull final C c, @NotNull final Filter<? super T> filter) { C filtered = null; try { filtered = (C) c.getClass().newInstance(); @@ -94,7 +96,7 @@ * @param filter Filter to use for <var>c</var> * @return number of elements removed */ - public static final <T, C extends Collection<T>> int removeFilter(final C collection, final Filter<? super T> filter) { + public static <T, C extends Collection<T>> int removeFilter(@NotNull final C collection, @NotNull final Filter<? super T> filter) { int removed = 0; for (final T o : collection) { if (!filter.accept(o)) { @@ -111,7 +113,7 @@ * @see Comparable * @see Collections#sort(List) */ - public static final <T extends Comparable<? super T>> boolean isSorted(final List<T> list) { + public static <T extends Comparable<? super T>> boolean isSorted(@NotNull final List<T> list) { if (list.size() < 2) { // empty lists or lists with only 1 element are always sorted, no need to check return true; @@ -141,12 +143,12 @@ /** Checks whether a list is sorted. * @param list List to check - * @param c Comparator to use for comparing list elements + * @param c Comparator to use for comparing list elements or <code>null</code> for natural order * @return <code>true</code> if <var>list</var> is sorted, otherwise <code>false</code> * @see Comparator * @see Collections#sort(List,Comparator) */ - public static final <T> boolean isSorted(final List<T> list, final Comparator<? super T> c) { + public static <T> boolean isSorted(@NotNull final List<T> list, @Nullable final Comparator<? super T> c) { if (c == null) { //noinspection unchecked,RawUseOfParameterizedType return isSorted((List) list); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |