Coverage Report - org.openpermis.editor.policy.adapter.overview.ActionBeanOverview
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionBeanOverview
94%
18/19
83%
5/6
3.5
 
 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.editor.policy.adapter.overview;
 9  
 
 10  
 import org.openpermis.policy.ParameterList;
 11  
 import org.openpermis.policy.bean.ActionBean;
 12  
 
 13  
 
 14  
 /**
 15  
  * Describes a {@link ActionBean} that has been adapted to a short overview string.
 16  
  * @since 0.3.0
 17  
  */
 18  2
 public class ActionBeanOverview implements Overview {                                                                                                
 19  
 
 20  
 
 21  
         //---- Static
 22  
         
 23  
         //---- State
 24  
         
 25  
         private ActionBean action;                                                                                                                                                
 26  
         
 27  
         //---- Constructors
 28  
         
 29  
         /**
 30  
          * Creates a action bean overview adaptee.
 31  
          * @param action the {@link ActionBean}.
 32  
          * @since 0.3.0
 33  
          */
 34  3
         public ActionBeanOverview (ActionBean action) {
 35  3
                 if (action == null) {
 36  1
                         throw new IllegalArgumentException("Action is null.");
 37  
                 }
 38  2
                 this.action = action;
 39  2
         }
 40  
         
 41  
         //---- Methods
 42  
         
 43  
         //---- Overview
 44  
         
 45  
         /**
 46  
          * @since 0.3.0
 47  
          */
 48  
         public String get () {
 49  2
                 if (this.action.getName() == null) {
 50  0
                         return "";
 51  
                 }
 52  2
                 final StringBuilder builder = new StringBuilder();
 53  2
                 builder.append(this.action.getName() + " (");
 54  2
                 String prefix = "";
 55  2
                 for (ParameterList.Parameter param : this.action.getParameters()) {
 56  2
                         builder.append(prefix);
 57  2
                         builder.append(param.getType().getSimpleName());
 58  2
                         builder.append(" ");
 59  2
                         builder.append(param.getName());
 60  2
                         prefix = ", ";
 61  
                 }
 62  2
                 builder.append(")");
 63  2
                 return builder.toString();
 64  
         }
 65  
 
 66  
 
 67  
 }