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

Reply via email to