package org.granchi.hollywood;

/**
 * Model for a Hollywood application.
 * <p>
 * <ul>
 * <li>Should not block, nor start any thread</li>
 * <li>Should be immutable, so there are no lateral effects from it being passed from actor to
 * actor</li>
 * <li>Is called from a single thread, so it will never receive two actions concurrently</li>
 * <li>Is ok to return itself from an action, if no change is needed</li>
 * </ul>
 *
 * @author serandel
 */
public interface Model {
    /**
     * Generates a new model, from itself and the data contained in an action.
     * <p>
     * It is allowed to return itself if the action didn't cause any state change.
     *
     * @param action action, can't be null
     * @return new model
     */
    Model actUpon(Action action);
}
@@ -25,16 +25,76 @@
 ywood;%0A%0A
+import java.util.Collection;%0Aimport java.util.Collections;%0A%0A
 /**%0A * M
@@ -517,17 +517,22 @@
 lic 
-interface
+abstract class
  Mod
@@ -804,16 +804,25 @@
  */%0A    
+abstract 
 Model ac
@@ -842,10 +842,621 @@
 action);
+%0A%0A    /**%0A     * Returns itself if it's of a specific class or a subclass of it, or, for composite models, the%0A     * submodels that are compliant with the same condition.%0A     *%0A     * @param type desired class%0A     * @param %3CT%3E  type of the desired class%0A     * @return model of submodel of that class%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT extends Model%3E Collection%3CT%3E getSubmodelOfType(Class%3CT%3E type) %7B%0A        if (type.isAssignableFrom(this.getClass())) %7B%0A            return Collections.singletonList((T) this);%0A        %7D else %7B%0A            return Collections.emptyList();%0A        %7D%0A    %7D
 %0A%7D

Change Model to an abstract class so getSubmodelOfType is defined here (and I remain unconvinced about the API...)