Coverage Report - org.openpermis.policy.bean.basic.BasicObligation
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicObligation
81%
13/16
100%
2/2
1.25
 
 1  
 /*
 2  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 3  
  * All rights reserved.
 4  
  * 
 5  
  * Licensed under the Open Permis License which accompanies this distribution, 
 6  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 7  
  */
 8  
 package org.openpermis.policy.bean.basic;
 9  
 
 10  
 import static org.openpermis.policy.bean.basic.BasicUtilities.equalObjects;
 11  
 import org.openpermis.policy.bean.ObligationBean;
 12  
 import org.openpermis.policy.bean.SerialNumber;
 13  
 
 14  
 
 15  
 /**
 16  
  * A basic implementation of {@link ObligationBean}.
 17  
  * @since 0.3.0
 18  
  */
 19  
 public class BasicObligation 
 20  
         extends BasicPartBean
 21  
         implements ObligationBean 
 22  
 {
 23  
 
 24  
         //---- Static
 25  
         
 26  
         private static final long serialVersionUID = -6726829688085066146L;
 27  
         
 28  
         //---- State
 29  
         
 30  
         private String text;
 31  
         
 32  
         //---- Constructors
 33  
         
 34  
         /**
 35  
          * Creates a new obligation containing text, that is returned for a granted decision.
 36  
          * @param serialNumber the serial number of this part.
 37  
          * @param text a {@link String}.
 38  
          * @since 0.3.0
 39  
          */
 40  
         protected BasicObligation (SerialNumber serialNumber, String text) {
 41  138
                 super(ObligationBean.class, serialNumber);
 42  138
                 setText(text);
 43  137
         }
 44  
         
 45  
         //---- Methods
 46  
         
 47  
         //---- Obligation
 48  
         
 49  
         /**
 50  
          * @since 0.3.0
 51  
          */
 52  
         public String getText () {
 53  89
                 return this.text;
 54  
         }
 55  
         
 56  
         //---- ObligationBean
 57  
         
 58  
         /**
 59  
          * @since 0.3.0
 60  
          */
 61  
         public void setText (String text) {
 62  138
                 if (text == null) {
 63  1
                         throw new IllegalArgumentException("Text is null.");
 64  
                 }
 65  137
                 final String oldText = this.text;
 66  137
                 this.text = text;
 67  137
                 firePropertyChange("text", oldText, this.text);
 68  137
         }
 69  
         
 70  
         //---- BasicPart
 71  
 
 72  
         /**
 73  
          * @since 0.3.0
 74  
          */
 75  
         @Override
 76  
         protected boolean comparablePart (BasicPart part) {
 77  56
                 return part instanceof ObligationBean;
 78  
         }
 79  
 
 80  
         /**
 81  
          * @since 0.3.0
 82  
          */
 83  
         @Override
 84  
         protected boolean equalPart (BasicPart part) {
 85  28
                 return equalObjects(getText(), ((ObligationBean) part).getText());
 86  
         }
 87  
 
 88  
         /**
 89  
          * @since 0.3.0
 90  
          */
 91  
         @Override
 92  
         protected int partHashCode () {
 93  19
                 return getText().hashCode();
 94  
         }
 95  
 
 96  
         /**
 97  
          * @since 0.3.0
 98  
          */
 99  
         @Override
 100  
         protected String getSimpleClassName () {
 101  0
                 return ObligationBean.class.getSimpleName();
 102  
         }
 103  
 
 104  
         /**
 105  
          * @since 0.3.0
 106  
          */
 107  
         @Override
 108  
         protected void appendPartDetails (StringBuilder sb) {
 109  0
                 appendDetails(sb, "obligation", getText());
 110  0
         }
 111  
 
 112  
 }