Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BasicActionCollection |
|
| 1.6;1.6 |
1 | /* | |
2 | * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport | |
3 | * (http://www.vbs.admin.ch) | |
4 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
5 | * All rights reserved. | |
6 | * | |
7 | * Licensed under the Open Permis License which accompanies this distribution, | |
8 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
9 | */ | |
10 | package org.openpermis.policy.bean.basic; | |
11 | ||
12 | import java.util.Collection; | |
13 | import java.util.List; | |
14 | ||
15 | import org.openpermis.policy.Action; | |
16 | import org.openpermis.policy.bean.ActionBean; | |
17 | import org.openpermis.policy.bean.ActionBeanCollection; | |
18 | import org.openpermis.policy.bean.SerialNumber; | |
19 | ||
20 | ||
21 | /** | |
22 | * Basic implementation of {@link BasicActionCollection}. | |
23 | * @since 0.3.0 | |
24 | */ | |
25 | 0 | public class BasicActionCollection |
26 | extends BasicAbstractCollection<ActionBean> | |
27 | implements ActionBeanCollection | |
28 | { | |
29 | ||
30 | //---- Static | |
31 | ||
32 | private static final long serialVersionUID = -956620427014379243L; | |
33 | ||
34 | //---- State | |
35 | ||
36 | //---- Constructors | |
37 | ||
38 | /** | |
39 | * Creates a basic action collection. | |
40 | * @param serialNumber the serial number of this part. | |
41 | * @since 0.3.0 | |
42 | */ | |
43 | protected BasicActionCollection (SerialNumber serialNumber) { | |
44 | 595 | super(serialNumber); |
45 | 595 | } |
46 | ||
47 | /** | |
48 | * Creates a basic action collection. | |
49 | * @param serialNumber the serial number of this part. | |
50 | * @param collection a collection of {@link ActionBean}'s. | |
51 | * @since 0.3.0 | |
52 | */ | |
53 | protected BasicActionCollection (SerialNumber serialNumber, Collection<ActionBean> collection) { | |
54 | 603 | super(serialNumber, collection); |
55 | 602 | } |
56 | ||
57 | //---- Methods | |
58 | ||
59 | //---- ActionCollection | |
60 | ||
61 | /** | |
62 | * @since 0.3.0 | |
63 | */ | |
64 | public Action findMatch (String actionName, List<?> arguments) { | |
65 | 54 | for (Action action : this) { |
66 | 55 | if (action.matches(actionName, arguments)) { |
67 | 15 | return action; |
68 | } | |
69 | } | |
70 | 39 | return null; |
71 | } | |
72 | ||
73 | //---- BasicAbstractCollection | |
74 | ||
75 | /** | |
76 | * @since 0.3.0 | |
77 | */ | |
78 | protected boolean isCollectionType (BasicPart part) { | |
79 | 2469 | return part instanceof ActionBeanCollection; |
80 | } | |
81 | ||
82 | //---- BeanCollection | |
83 | ||
84 | /** | |
85 | * @since 0.3.0 | |
86 | */ | |
87 | public BasicActionCollection create (List<ActionBean> list) { | |
88 | 0 | return new BasicActionCollection(getSerialNumber().next(), list); |
89 | } | |
90 | ||
91 | } |