[Mulgara-svn] r1159 - trunk/src/jar/util/java/org/mulgara/util
pag at mulgara.org
pag at mulgara.org
Sat Aug 23 01:50:24 UTC 2008
Author: pag
Date: 2008-08-22 18:50:23 -0700 (Fri, 22 Aug 2008)
New Revision: 1159
Added:
trunk/src/jar/util/java/org/mulgara/util/Fn1.java
trunk/src/jar/util/java/org/mulgara/util/Fn1E.java
Removed:
trunk/src/jar/util/java/org/mulgara/util/Fn.java
trunk/src/jar/util/java/org/mulgara/util/FnE.java
Modified:
trunk/src/jar/util/java/org/mulgara/util/C.java
Log:
Updated class names to allow for single and zero argument functors, and updated parameter names to be a little clearer
Modified: trunk/src/jar/util/java/org/mulgara/util/C.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/C.java 2008-08-23 01:48:51 UTC (rev 1158)
+++ trunk/src/jar/util/java/org/mulgara/util/C.java 2008-08-23 01:50:23 UTC (rev 1159)
@@ -21,7 +21,7 @@
/**
* Generic Collections utility class.
* This class defines static methods for operating on Collections and the functors found in
- * {@link org.mulgara.util.Fn} and {@link org.mulgara.util.Fn2}.
+ * {@link org.mulgara.util.Fn1} and {@link org.mulgara.util.Fn2}.
*
* @created Aug 4, 2008
* @author Paul Gearon
@@ -39,22 +39,22 @@
* argument type for the operation.
* @param <T2> The type of the elements in the result list, which is also
* the return type of the operation.
- * @param <E> The exception that my be thrown from {@link FnE#fn(Object)}.
+ * @param <E> The exception that my be thrown from {@link Fn1E#fn(Object)}.
* @param args The input list.
* @param op The operation to apply to the elements of the input list.
* @return A list whose elements are the result of applying op to each element of args.
- * @throws E An exception that may be thrown from the {@link FnE#fn(Object)} method.
+ * @throws E An exception that may be thrown from the {@link Fn1E#fn(Object)} method.
*/
- public static <T1,T2,E extends Exception> List<T2> map(Collection<T1> args, FnE<T1,T2,E> op) throws E {
+ public static <T1,T2,E extends Exception> List<T2> map(Collection<T1> args, Fn1E<T1,T2,E> op) throws E {
List<T2> result = new LinkedList<T2>();
for (T1 a: args) result.add(op.fn(a));
return result;
}
/**
- * The same method as {@link #map(Collection, FnE)} for arrays.
+ * The same method as {@link #map(Collection, Fn1E)} for arrays.
*/
- public static <T1,T2,E extends Exception> List<T2> map(T1[] args, FnE<T1,T2,E> op) throws E {
+ public static <T1,T2,E extends Exception> List<T2> map(T1[] args, Fn1E<T1,T2,E> op) throws E {
List<T2> result = new ArrayList<T2>(args.length);
for (T1 a: args) result.add(op.fn(a));
return result;
@@ -73,14 +73,14 @@
* @param op The operation to apply to the elements of the input list.
* @return A list whose elements are the result of applying op to each element of args.
*/
- public static <T1,T2> List<T2> map(Collection<T1> args, Fn<T1,T2> op) {
- return map(args, (FnE<T1,T2,RuntimeException>)op);
+ public static <T1,T2> List<T2> map(Collection<T1> args, Fn1<T1,T2> op) {
+ return map(args, (Fn1E<T1,T2,RuntimeException>)op);
}
/**
- * The same method as {@link #map(Collection, Fn)} for arrays.
+ * The same method as {@link #map(Collection, Fn1)} for arrays.
*/
- public static <T1,T2> List<T2> map(T1[] args, Fn<T1,T2> op) {
+ public static <T1,T2> List<T2> map(T1[] args, Fn1<T1,T2> op) {
List<T2> result = new ArrayList<T2>(args.length);
for (T1 a: args) result.add(op.fn(a));
return result;
Deleted: trunk/src/jar/util/java/org/mulgara/util/Fn.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/Fn.java 2008-08-23 01:48:51 UTC (rev 1158)
+++ trunk/src/jar/util/java/org/mulgara/util/Fn.java 2008-08-23 01:50:23 UTC (rev 1159)
@@ -1,26 +0,0 @@
-/*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- */
-
-package org.mulgara.util;
-
-/**
- * Functor template for a function that takes one type and returns another without
- * throwing an exception.
- *
- * @created Aug 4, 2008
- * @author Paul Gearon
- * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public interface Fn<T1,T2> extends FnE<T1,T2,RuntimeException> {
-
-}
Copied: trunk/src/jar/util/java/org/mulgara/util/Fn1.java (from rev 1141, trunk/src/jar/util/java/org/mulgara/util/Fn.java)
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/Fn1.java (rev 0)
+++ trunk/src/jar/util/java/org/mulgara/util/Fn1.java 2008-08-23 01:50:23 UTC (rev 1159)
@@ -0,0 +1,26 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.util;
+
+/**
+ * Functor template for a function that takes one type and returns another without
+ * throwing an exception.
+ *
+ * @created Aug 4, 2008
+ * @author Paul Gearon
+ * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public interface Fn1<T1,T2> extends Fn1E<T1,T2,RuntimeException> {
+
+}
Copied: trunk/src/jar/util/java/org/mulgara/util/Fn1E.java (from rev 1141, trunk/src/jar/util/java/org/mulgara/util/FnE.java)
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/Fn1E.java (rev 0)
+++ trunk/src/jar/util/java/org/mulgara/util/Fn1E.java 2008-08-23 01:50:23 UTC (rev 1159)
@@ -0,0 +1,34 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.util;
+
+/**
+ * Functor template for a function that takes one type and returns another.
+ * An exception may be thrown.
+ *
+ * @created Aug 4, 2008
+ * @author Paul Gearon
+ * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public interface Fn1E<T1,T2,E extends Exception> {
+
+ /**
+ * Declares a function template that takes one argument and returns a value of
+ * another type.
+ * @param arg The single argument.
+ * @return A value based on arg.
+ * @throws E Can throw an exception of this type.
+ */
+ T2 fn(T1 arg) throws E;
+}
Deleted: trunk/src/jar/util/java/org/mulgara/util/FnE.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/FnE.java 2008-08-23 01:48:51 UTC (rev 1158)
+++ trunk/src/jar/util/java/org/mulgara/util/FnE.java 2008-08-23 01:50:23 UTC (rev 1159)
@@ -1,34 +0,0 @@
-/*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- */
-
-package org.mulgara.util;
-
-/**
- * Functor template for a function that takes one type and returns another.
- * An exception may be thrown.
- *
- * @created Aug 4, 2008
- * @author Paul Gearon
- * @copyright © 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
- * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
- */
-public interface FnE<T1,T2,E extends Exception> {
-
- /**
- * Declares a function template that takes one argument and returns a value of
- * another type.
- * @param arg The single argument.
- * @return A value based on arg.
- * @throws E Can throw an exception of this type.
- */
- T2 fn(T1 arg) throws E;
-}
More information about the Mulgara-svn
mailing list