Coverage Report - org.openpermis.editor.policy.command.PartRemoveCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
PartRemoveCommand
0%
0/10
0%
0/2
1.4
 
 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 org.openpermis.policy.bean.PartBean;
 13  
 import org.openpermis.policy.bean.PolicyBean;
 14  
 
 15  
 
 16  
 /**
 17  
  * Command that deletes a target allover the model.
 18  
  * @param <P> part type
 19  
  * @since 0.1.0
 20  
  */
 21  
 public abstract class PartRemoveCommand<P extends PartBean> extends AbstractCommand
 22  
 {
 23  
         //---- State
 24  
 
 25  
         /**
 26  
          * The bean to operate.
 27  
          * @since 0.1.0
 28  
          */
 29  
         private final P part;
 30  
 
 31  
         //---- Constructors
 32  
 
 33  
         /**
 34  
          * Creates a command.
 35  
          * @param part the part to modify, must not be {@code null}.
 36  
          * @since 0.1.0
 37  
          */
 38  
         public PartRemoveCommand (P part) {
 39  0
                 super("PartRemoveCommand");
 40  0
                 if (part == null) {
 41  0
                         throw new IllegalArgumentException("Part must not be [null].");
 42  
                 }
 43  0
                 this.part = part;
 44  0
         }
 45  
 
 46  
         //---- Methods
 47  
 
 48  
         /**
 49  
          * @return the part.
 50  
          * @since 0.1.0
 51  
          */
 52  
         public P getPart () {
 53  0
                 return this.part;
 54  
         }
 55  
 
 56  
         /**
 57  
          * @since 0.1.0
 58  
          */
 59  
         abstract void removePart (PolicyBean policyBean, boolean doExec);
 60  
 
 61  
         //---- Command
 62  
 
 63  
         /**
 64  
          * @since 0.1.0
 65  
          */
 66  
         @Override
 67  
         public void execute (PolicyBean policyBean) {
 68  0
                 removePart(policyBean, true);
 69  0
         }
 70  
 
 71  
         /**
 72  
          * @since 0.1.0
 73  
          */
 74  
         @Override
 75  
         public void undo (PolicyBean policyBean) {
 76  0
                 removePart(policyBean, false);
 77  0
         }
 78  
 
 79  
 }