Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CollectionAddCommand |
|
| 1.5;1.5 |
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.editor.policy.command; | |
11 | ||
12 | import java.util.List; | |
13 | ||
14 | import org.openpermis.policy.bean.PartBean; | |
15 | ||
16 | ||
17 | /** | |
18 | * Command to edit a part. | |
19 | * @param <P> the current beantype | |
20 | * @since 0.1.0 | |
21 | */ | |
22 | public class CollectionAddCommand<P extends PartBean> extends CollectionChangeCommand<P> | |
23 | { | |
24 | ||
25 | //---- Constructors | |
26 | ||
27 | /** | |
28 | * Creates a new command. * | |
29 | * @param parentBean bean holding the collection | |
30 | * @param elementBean bean to add/remove | |
31 | * @param property the property holding the collection | |
32 | * @since 0.1.0 | |
33 | */ | |
34 | public CollectionAddCommand (PartBean parentBean, P elementBean, String property) { | |
35 | 0 | super(parentBean, elementBean, property); |
36 | 0 | } |
37 | ||
38 | //---- CollectionChangeCommand | |
39 | ||
40 | /** | |
41 | * @param doExec wether to "exec" or to "undo" | |
42 | * @since 0.3.0 | |
43 | */ | |
44 | @Override | |
45 | void operateElement (boolean doExec, List<P> list) { | |
46 | 0 | if (doExec) { |
47 | 0 | list.add(this.getElementBean()); |
48 | } else { | |
49 | 0 | list.remove(this.getElementBean()); |
50 | } | |
51 | ||
52 | 0 | } |
53 | ||
54 | } |