Coverage Report - org.openpermis.policy.bean.basic.BasicObligationCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicObligationCollection
81%
9/11
100%
2/2
1.2
 
 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.HashSet;
 14  
 import java.util.List;
 15  
 import java.util.Set;
 16  
 
 17  
 import org.openpermis.policy.Obligation;
 18  
 import org.openpermis.policy.bean.ObligationBean;
 19  
 import org.openpermis.policy.bean.ObligationBeanCollection;
 20  
 import org.openpermis.policy.bean.SerialNumber;
 21  
 
 22  
 
 23  
 /**
 24  
  * Basic implementation of {@link BasicObligationCollection}.
 25  
  * @since 0.3.0
 26  
  */
 27  0
 public class BasicObligationCollection 
 28  
         extends BasicAbstractCollection<ObligationBean> 
 29  
         implements ObligationBeanCollection 
 30  
 {
 31  
         
 32  
         //---- Static
 33  
         
 34  
         private static final long serialVersionUID = -956620427014379243L;
 35  
 
 36  
         //---- State
 37  
         
 38  
         //---- Constructors
 39  
         
 40  
         /**
 41  
          * Creates a basic obligation collection.
 42  
          * @param serialNumber the serial number of this part.
 43  
          * @since 0.3.0
 44  
          */
 45  
         protected BasicObligationCollection (SerialNumber serialNumber) {
 46  602
                 super(serialNumber);
 47  602
         }
 48  
         
 49  
         /**
 50  
          * Creates a basic obligation collection.
 51  
          * @param serialNumber the serial number of this part.
 52  
          * @param collection a collection of {@link ObligationBean}'s.
 53  
          * @since 0.3.0
 54  
          */
 55  
         protected BasicObligationCollection (
 56  
                 SerialNumber serialNumber, Collection<ObligationBean> collection
 57  
         ) {
 58  1054
                 super(serialNumber, collection);
 59  1054
         }
 60  
         
 61  
         //---- Methods
 62  
         
 63  
         //---- ObligationCollection
 64  
 
 65  
         /**
 66  
          * @since 0.3.0
 67  
          */
 68  
         public Set<String> getObligationStrings () {
 69  14
                 final Set<String> result = new HashSet<String>();
 70  14
                 for (Obligation obligation : this) {
 71  11
                         result.add(obligation.getText());
 72  
                 }
 73  14
                 return result;
 74  
         }
 75  
         
 76  
         //---- BasicAbstractCollection
 77  
         
 78  
         /**
 79  
          * @since 0.3.0
 80  
          */
 81  
         protected boolean isCollectionType (BasicPart part) {
 82  1331
                 return part instanceof ObligationBeanCollection;
 83  
         }
 84  
 
 85  
         //---- BeanCollection
 86  
         
 87  
         /**
 88  
          * @since 0.3.0
 89  
          */
 90  
         public BasicObligationCollection create (List<ObligationBean> list) {
 91  0
                 return new BasicObligationCollection(getSerialNumber().next(), list);
 92  
         }
 93  
 
 94  
 }