You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2014/06/24 18:14:27 UTC

svn commit: r1605126 - in /pivot/trunk/core/src/org/apache/pivot/functional: ./ functions/

Author: smartini
Date: Tue Jun 24 16:14:26 2014
New Revision: 1605126

URL: http://svn.apache.org/r1605126
Log:
PIVOT-799, functional interfaces

Added:
    pivot/trunk/core/src/org/apache/pivot/functional/
    pivot/trunk/core/src/org/apache/pivot/functional/functions/
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Function0.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Function1.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Function2.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Function3.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/FunctionN.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Predicate.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure0.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure1.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure2.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure3.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/ProcedureN.java
    pivot/trunk/core/src/org/apache/pivot/functional/functions/package.html
    pivot/trunk/core/src/org/apache/pivot/functional/package.html

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Function0.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Function0.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Function0.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Function0.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic function that accept n (in this case 0) arguments
+ * and returns a value.
+ */
+public interface Function0<R> {
+    public R apply();
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Function1.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Function1.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Function1.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Function1.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic function that accept n (in this case 1) arguments
+ * and returns a value.
+ */
+public interface Function1<R, T1> {
+    public R apply(T1 a);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Function2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Function2.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Function2.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Function2.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic function that accept n (in this case 2) arguments
+ * and returns a value.
+ */
+public interface Function2<R, T1, T2> {
+    public R apply(T1 a, T2 b);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Function3.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Function3.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Function3.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Function3.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic function that accept n (in this case 3) arguments
+ * and returns a value.
+ */
+public interface Function3<R, T1, T2, T3> {
+    public R apply(T1 a, T2 b, T3 c);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/FunctionN.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/FunctionN.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/FunctionN.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/FunctionN.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,26 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic function that accept n arguments
+ * (in this case variable, but all of the same type) and returns a value.
+ */
+public interface FunctionN<R, T> {
+    @SuppressWarnings("unchecked")
+    public R apply(T ... a);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Predicate.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Predicate.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Predicate.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Predicate.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic predicate that test the given argument
+ * and returns a boolean value.
+ */
+public interface Predicate<T> {
+    public boolean test(T a);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure0.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure0.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure0.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure0.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic procedure that accept n (in this case 0) arguments
+ * and returns no value (void).
+ */
+public interface Procedure0 {
+    public void apply();
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure1.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure1.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure1.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure1.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic procedure that accept n (in this case 1) arguments
+ * and returns no value (void).
+ */
+public interface Procedure1<T1> {
+    public void apply(T1 a);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure2.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure2.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure2.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic procedure that accept n (in this case 2) arguments
+ * and returns no value (void).
+ */
+public interface Procedure2<T1, T2> {
+    public void apply(T1 a, T2 b);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure3.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure3.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure3.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/Procedure3.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,25 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic procedure that accept n (in this case 3) arguments
+ * and returns no value (void).
+ */
+public interface Procedure3<T1, T2, T3> {
+    public void apply(T1 a, T2 b, T3 c);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/ProcedureN.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/ProcedureN.java?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/ProcedureN.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/ProcedureN.java Tue Jun 24 16:14:26 2014
@@ -0,0 +1,26 @@
+/*
+ * 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.pivot.functional.functions;
+
+/**
+ * Interface for the definition of a generic procedure that accept n arguments
+ * (in this case variable, but all of the same type) and returns no value (void).
+ */
+public interface ProcedureN<T> {
+    @SuppressWarnings("unchecked")
+    public void apply(T ... a);
+}

Added: pivot/trunk/core/src/org/apache/pivot/functional/functions/package.html
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/functions/package.html?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/functions/package.html (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/functions/package.html Tue Jun 24 16:14:26 2014
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+
+<html>
+<head></head>
+<body>
+<p>Contains a set of classes and interfaces for implementing generic Functions and Procedures (see FP).</p>
+</body>
+</html>

Added: pivot/trunk/core/src/org/apache/pivot/functional/package.html
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/functional/package.html?rev=1605126&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/functional/package.html (added)
+++ pivot/trunk/core/src/org/apache/pivot/functional/package.html Tue Jun 24 16:14:26 2014
@@ -0,0 +1,23 @@
+<!--
+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.
+-->
+
+<html>
+<head></head>
+<body>
+<p>Contains a set of classes for typical usage in Functional programming (FP).</p>
+</body>
+</html>