| 
001 /*002  * Copyright 2008-2015 the original author or authors.
 003  *
 004  * Licensed under the Apache License, Version 2.0 (the "License");
 005  * you may not use this file except in compliance with the License.
 006  * You may obtain a copy of the License at
 007  *
 008  *     http://www.apache.org/licenses/LICENSE-2.0
 009  *
 010  * Unless required by applicable law or agreed to in writing, software
 011  * distributed under the License is distributed on an "AS IS" BASIS,
 012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 013  * See the License for the specific language governing permissions and
 014  * limitations under the License.
 015  */
 016 package org.codehaus.griffon.runtime.core.mvc;
 017
 018 import griffon.core.artifact.GriffonController;
 019 import griffon.core.artifact.GriffonModel;
 020 import griffon.core.artifact.GriffonMvcArtifact;
 021 import griffon.core.artifact.GriffonView;
 022 import griffon.core.mvc.MVCFunction;
 023 import griffon.core.mvc.MVCGroup;
 024 import griffon.core.mvc.MVCGroupFunction;
 025 import griffon.core.mvc.MVCGroupManager;
 026 import griffon.core.mvc.MVCHandler;
 027
 028 import javax.annotation.Nonnull;
 029 import javax.inject.Inject;
 030 import java.util.List;
 031 import java.util.Map;
 032
 033 import static java.util.Objects.requireNonNull;
 034
 035 /**
 036  * Base implementation of the MVCHandler interface.
 037  *
 038  * @author Andres Almiray
 039  * @since 2.0.0
 040  */
 041 public abstract class AbstractMVCHandler implements MVCHandler {
 042     private final MVCGroupManager mvcGroupManager;
 043
 044     @Inject
 045     public AbstractMVCHandler(@Nonnull MVCGroupManager mvcGroupManager) {
 046         this.mvcGroupManager = requireNonNull(mvcGroupManager, "Argument 'mvcGroupManager' must not be null");
 047     }
 048
 049     protected MVCGroupManager getMvcGroupManager() {
 050         return mvcGroupManager;
 051     }
 052
 053     @Nonnull
 054     public MVCGroup createMVCGroup(@Nonnull Map<String, Object> args, @Nonnull String mvcType) {
 055         return mvcGroupManager.createMVCGroup(args, mvcType);
 056     }
 057
 058     @Nonnull
 059     public MVCGroup createMVCGroup(@Nonnull Map<String, Object> args, @Nonnull String mvcType, @Nonnull String mvcId) {
 060         return mvcGroupManager.createMVCGroup(args, mvcType, mvcId);
 061     }
 062
 063     @Nonnull
 064     public MVCGroup createMVCGroup(@Nonnull String mvcType) {
 065         return mvcGroupManager.createMVCGroup(mvcType);
 066     }
 067
 068     @Nonnull
 069     public MVCGroup createMVCGroup(@Nonnull String mvcType, @Nonnull Map<String, Object> args) {
 070         return mvcGroupManager.createMVCGroup(mvcType, args);
 071     }
 072
 073     @Nonnull
 074     public MVCGroup createMVCGroup(@Nonnull String mvcType, @Nonnull String mvcId) {
 075         return mvcGroupManager.createMVCGroup(mvcType, mvcId);
 076     }
 077
 078     @Nonnull
 079     public MVCGroup createMVCGroup(@Nonnull String mvcType, @Nonnull String mvcId, @Nonnull Map<String, Object> args) {
 080         return mvcGroupManager.createMVCGroup(mvcType, mvcId, args);
 081     }
 082
 083     @Nonnull
 084     public List<? extends GriffonMvcArtifact> createMVC(@Nonnull Map<String, Object> args, @Nonnull String mvcType) {
 085         return mvcGroupManager.createMVC(args, mvcType);
 086     }
 087
 088     @Nonnull
 089     public List<? extends GriffonMvcArtifact> createMVC(@Nonnull Map<String, Object> args, @Nonnull String mvcType, @Nonnull String mvcId) {
 090         return mvcGroupManager.createMVC(args, mvcType, mvcId);
 091     }
 092
 093     @Nonnull
 094     public List<? extends GriffonMvcArtifact> createMVC(@Nonnull String mvcType) {
 095         return mvcGroupManager.createMVC(mvcType);
 096     }
 097
 098     @Nonnull
 099     public List<? extends GriffonMvcArtifact> createMVC(@Nonnull String mvcType, @Nonnull Map<String, Object> args) {
 100         return mvcGroupManager.createMVC(mvcType, args);
 101     }
 102
 103     @Nonnull
 104     public List<? extends GriffonMvcArtifact> createMVC(@Nonnull String mvcType, @Nonnull String mvcId) {
 105         return mvcGroupManager.createMVC(mvcType, mvcId);
 106     }
 107
 108     @Nonnull
 109     public List<? extends GriffonMvcArtifact> createMVC(@Nonnull String mvcType, @Nonnull String mvcId, @Nonnull Map<String, Object> args) {
 110         return mvcGroupManager.createMVC(mvcType, mvcId, args);
 111     }
 112
 113     public void destroyMVCGroup(@Nonnull String mvcId) {
 114         mvcGroupManager.destroyMVCGroup(mvcId);
 115     }
 116
 117     public <M extends GriffonModel, V extends GriffonView, C extends GriffonController> void withMVC(@Nonnull String mvcType, @Nonnull String mvcId, @Nonnull MVCFunction<M, V, C> handler) {
 118         mvcGroupManager.withMVC(mvcType, mvcId, handler);
 119     }
 120
 121     public <M extends GriffonModel, V extends GriffonView, C extends GriffonController> void withMVC(@Nonnull Map<String, Object> args, @Nonnull String mvcType, @Nonnull MVCFunction<M, V, C> handler) {
 122         mvcGroupManager.withMVC(args, mvcType, handler);
 123     }
 124
 125     public <M extends GriffonModel, V extends GriffonView, C extends GriffonController> void withMVC(@Nonnull Map<String, Object> args, @Nonnull String mvcType, @Nonnull String mvcId, @Nonnull MVCFunction<M, V, C> handler) {
 126         mvcGroupManager.withMVC(args, mvcType, mvcId, handler);
 127     }
 128
 129     public <M extends GriffonModel, V extends GriffonView, C extends GriffonController> void withMVC(@Nonnull String mvcType, @Nonnull Map<String, Object> args, @Nonnull MVCFunction<M, V, C> handler) {
 130         mvcGroupManager.withMVC(mvcType, args, handler);
 131     }
 132
 133     public <M extends GriffonModel, V extends GriffonView, C extends GriffonController> void withMVC(@Nonnull String mvcType, @Nonnull MVCFunction<M, V, C> handler) {
 134         mvcGroupManager.withMVC(mvcType, handler);
 135     }
 136
 137     public <M extends GriffonModel, V extends GriffonView, C extends GriffonController> void withMVC(@Nonnull String mvcType, @Nonnull String mvcId, @Nonnull Map<String, Object> args, @Nonnull MVCFunction<M, V, C> handler) {
 138         mvcGroupManager.withMVC(mvcType, mvcId, args, handler);
 139     }
 140
 141     public void withMVCGroup(@Nonnull String mvcType, @Nonnull String mvcId, @Nonnull MVCGroupFunction handler) {
 142         mvcGroupManager.withMVCGroup(mvcType, mvcId, handler);
 143     }
 144
 145     public void withMVCGroup(@Nonnull Map<String, Object> args, @Nonnull String mvcType, @Nonnull MVCGroupFunction handler) {
 146         mvcGroupManager.withMVCGroup(args, mvcType, handler);
 147     }
 148
 149     public void withMVCGroup(@Nonnull Map<String, Object> args, @Nonnull String mvcType, @Nonnull String mvcId, @Nonnull MVCGroupFunction handler) {
 150         mvcGroupManager.withMVCGroup(args, mvcType, mvcId, handler);
 151     }
 152
 153     public void withMVCGroup(@Nonnull String mvcType, @Nonnull Map<String, Object> args, @Nonnull MVCGroupFunction handler) {
 154         mvcGroupManager.withMVCGroup(mvcType, args, handler);
 155     }
 156
 157     public void withMVCGroup(@Nonnull String mvcType, @Nonnull MVCGroupFunction handler) {
 158         mvcGroupManager.withMVCGroup(mvcType, handler);
 159     }
 160
 161     public void withMVCGroup(@Nonnull String mvcType, @Nonnull String mvcId, @Nonnull Map<String, Object> args, @Nonnull MVCGroupFunction handler) {
 162         mvcGroupManager.withMVCGroup(mvcType, mvcId, args, handler);
 163     }
 164 }
 |