NoopGriffonControllerActionManager.java
01 /*
02  * Copyright 2007-2013 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *      http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  */
15 
16 package org.codehaus.griffon.runtime.core.controller;
17 
18 import griffon.core.GriffonApplication;
19 import griffon.core.GriffonController;
20 import griffon.core.controller.GriffonControllerAction;
21 import griffon.core.controller.GriffonControllerActionManager;
22 
23 import java.util.Collections;
24 import java.util.Map;
25 
26 import static griffon.util.GriffonNameUtils.uncapitalize;
27 
28 /**
29  @author Andres Almiray
30  @since 1.1.0
31  */
32 public class NoopGriffonControllerActionManager implements GriffonControllerActionManager {
33     private final GriffonApplication app;
34 
35     public NoopGriffonControllerActionManager(GriffonApplication app) {
36         this.app = app;
37     }
38 
39     @Override
40     public Map<String, GriffonControllerAction> actionsFor(GriffonController controller) {
41         return Collections.emptyMap();
42     }
43 
44     @Override
45     public GriffonControllerAction actionFor(GriffonController controller, String actionName) {
46         return null;
47     }
48 
49     @Override
50     public void createActions(GriffonController controller) {
51         // empty
52     }
53 
54     @Override
55     public String normalizeName(String actionName) {
56         if (actionName.endsWith(ACTION)) {
57             actionName = actionName.substring(0, actionName.length() - ACTION.length());
58         }
59         return uncapitalize(actionName);
60     }
61 
62     @Override
63     public GriffonApplication getApp() {
64         return app;
65     }
66 }