/*
 * Copyright 2008-2017 the original author or authors.
 *
 * 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.codehaus.griffon.runtime.core.mvc;

import griffon.core.artifact.GriffonController;
import griffon.core.artifact.GriffonModel;
import griffon.core.artifact.GriffonView;
import griffon.core.mvc.MVCGroup;
import griffon.core.mvc.TypedMVCGroup;

import javax.annotation.Nonnull;

/**
 * @author Andres Almiray
 * @since 2.11.0
 */
public abstract class AbstractTypedMVCGroup<M extends GriffonModel, V extends GriffonView, C extends GriffonController> extends DelegatingMVCGroup implements TypedMVCGroup<M, V, C> {
    public AbstractTypedMVCGroup(@Nonnull MVCGroup delegate) {
        super(delegate);
    }

    @Nonnull
    @Override
    public M model() {
        return (M) delegate().getModel();
    }

    @Nonnull
    @Override
    public V view() {
        return (V) delegate().getView();
    }

    @Nonnull
    @Override
    public C controller() {
        return (C) delegate().getController();
    }
}

@@ -902,16 +902,76 @@
 nnull;%0A%0A
+import static griffon.util.GriffonClassUtils.requireState;%0A%0A
 /**%0A * @
@@ -1283,16 +1283,1040 @@
 legate);
+%0A%0A        GriffonModel model = getModel();%0A        requireState(model != null, %22MVC member 'model' must not be null%22);%0A        try %7B%0A            M m = (M) model;%0A        %7D catch (ClassCastException cce) %7B%0A            throw new IllegalStateException(%22Expected 'model' is not of the right type for %22 + getClass().getName());%0A        %7D%0A%0A        GriffonView view = getView();%0A        requireState(view != null, %22MVC member 'view' must not be null%22);%0A        try %7B%0A            V v = (V) view;%0A        %7D catch (ClassCastException cce) %7B%0A            throw new IllegalStateException(%22Expected 'view' is not of the right type for %22 + getClass().getName());%0A        %7D%0A%0A        GriffonController controller = getController();%0A        requireState(controller != null, %22MVC member 'controller' must not be null%22);%0A        try %7B%0A            C c = (C) controller;%0A        %7D catch (ClassCastException cce) %7B%0A            throw new IllegalStateException(%22Expected 'controller' is not of the right type for %22 + getClass().getName());%0A        %7D
 %0A    %7D%0A%0A

Verify MVC members when a TypedMVCGroup is created