Arthur Bogaart pushed to branch release/4.1 at cms-community / hippo-cms

Commits:
c873e47f by Arthur Bogaart at 2016-11-15T15:46:11+01:00
CMS-10540 Use SerializableSupplier interface in ReadOnlyModel

- Annotate SerializableSupplier with @FunctionalInterface
- ReadOnlyModel can be final

(cherry picked from commit ac701e5)
(cherry picked from commit 8a3d94f)
(cherry picked from commit 404079f)

- - - - -
799d88af by Arthur Bogaart at 2016-11-15T15:48:37+01:00
CMS-10540 Reintegrate bugfix/CMS-10540

- - - - -


2 changed files:

- api/src/main/java/org/hippoecm/frontend/model/ReadOnlyModel.java
- + api/src/main/java/org/hippoecm/frontend/model/SerializableSupplier.java


Changes:

=====================================
api/src/main/java/org/hippoecm/frontend/model/ReadOnlyModel.java
=====================================
--- a/api/src/main/java/org/hippoecm/frontend/model/ReadOnlyModel.java
+++ b/api/src/main/java/org/hippoecm/frontend/model/ReadOnlyModel.java
@@ -15,18 +15,16 @@
  */
 package org.hippoecm.frontend.model;
 
-import java.util.function.Supplier;
-
 import org.apache.wicket.model.AbstractReadOnlyModel;
 
 /**
  * Read-only Wicket model that accepts a lambda function to return the object.
  */
-public class ReadOnlyModel<T> extends AbstractReadOnlyModel<T> {
+public final class ReadOnlyModel<T> extends AbstractReadOnlyModel<T> {
 
-    private final Supplier<T> supplier;
+    private final SerializableSupplier<T> supplier;
 
-    private ReadOnlyModel(final Supplier<T> supplier) {
+    private ReadOnlyModel(final SerializableSupplier<T> supplier) {
         this.supplier = supplier;
     }
 
@@ -35,7 +33,7 @@ public class ReadOnlyModel<T> extends 
AbstractReadOnlyModel<T> {
         return supplier.get();
     }
 
-    public static <T> ReadOnlyModel<T> of(final Supplier<T> supplier) {
+    public static <T> ReadOnlyModel<T> of(final SerializableSupplier<T> 
supplier) {
         return new ReadOnlyModel<>(supplier);
     }
 }


=====================================
api/src/main/java/org/hippoecm/frontend/model/SerializableSupplier.java
=====================================
--- /dev/null
+++ b/api/src/main/java/org/hippoecm/frontend/model/SerializableSupplier.java
@@ -0,0 +1,23 @@
+/*
+ *  Copyright 2016 Hippo B.V. (http://www.onehippo.com)
+ *
+ *  Licensed 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.hippoecm.frontend.model;
+
+import java.io.Serializable;
+import java.util.function.Supplier;
+
+@FunctionalInterface
+public interface SerializableSupplier<T> extends Supplier<T>, Serializable {
+}



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-cms/compare/2dee5c819305259aff02147e06ec2d8caa653f28...799d88afec13b5485def4183b4a48e495c3a73ac
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to