1 /*
2 * Copyright 2004-2008 the Seasar Foundation and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.seasar.uruma.rcp.binding.impl;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.seasar.uruma.rcp.binding.CommandDesc;
23 import org.seasar.uruma.rcp.binding.CommandRegistry;
24 import org.seasar.uruma.util.AssertionUtil;
25
26 /**
27 * {@link CommandRegistry} の実装クラスです。<br />
28 *
29 * @author y-komori
30 */
31 public class CommandRegistryImpl implements CommandRegistry {
32 private List<CommandDesc> commandDescList = new ArrayList<CommandDesc>();
33
34 /*
35 * @see
36 * org.seasar.uruma.rcp.binding.CommandRegistry#registerCommandDesc(org.
37 * seasar.uruma.rcp.binding.CommandDesc)
38 */
39 public void registerCommandDesc(final CommandDesc desc) {
40 AssertionUtil.assertNotNull("desc", desc);
41 commandDescList.add(desc);
42 }
43
44 /*
45 * @see org.seasar.uruma.rcp.binding.CommandRegistry#getCommandDescs()
46 */
47 public List<CommandDesc> getCommandDescs() {
48 return Collections.unmodifiableList(commandDescList);
49 }
50
51 /*
52 * @see
53 * org.seasar.uruma.rcp.binding.CommandRegistry#getCommandDesc(java.lang
54 * .String)
55 */
56 public CommandDesc getCommandDesc(final String commandId) {
57 for (CommandDesc desc : commandDescList) {
58 if (desc.getCommandId().equals(commandId)) {
59 return desc;
60 }
61 }
62 return null;
63 }
64 }