On Wed, Jan 29, 2014 at 1:34 PM, Martijn Dashorst < [email protected]> wrote:
> On Wed, Jan 29, 2014 at 9:31 AM, Martin Grigorov <[email protected] > >wrote: > > > - currently IModel is also IDetachable > > I am not sure that lambda's in Java 8 will work here unless we remove > > IDetachable from the base imodel interface and add it to each > > implementation. > > > > We can provide a default implementation in IDetachable. This will make > IReadableModel a FunctionalInterface: > > public interface IJava8Detachable extends Serializable { > default public void detach() { > } > } > > @FunctionalInterface > public interface IJava8ReadableModel<T> extends IJava8Detachable { > public T getObject(); > } > > @FunctionalInterface > public interface IJava8WriteableModel<T> extends IJava8Detachable { > public void setObject(T object); > } > > A method defining the readable model as a parameter: > > public <T> void setSomeReadableModel(IJava8ReadableModel<T> m) { > ... > } > > > Usage scenario: > > setSomeReadableModel(() -> "Foo " + System.currentTimeMillis()); > > Martijn > All this looks promising but this code depends on JDK 8 features. Your previous mail started with: "Should we strive to ease the addition of lambda expressions to Wicket by introducing single method interfaces in various places in Wicket 7?" So this discussion should be focused on "how to make Wicket 7 better for early users of JDK 8". Wicket 8/9 based on JDK8 won't be released in the next few years :-/
