Coverage Report - org.openpermis.editor.policy.adapter.overview.RoleOverview
 
Classes in this File Line Coverage Branch Coverage Complexity
RoleOverview
88%
8/9
75%
3/4
3
 
 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  
 
 11  
 import org.openpermis.policy.Role;
 12  
 
 13  
 
 14  
 /**
 15  
  * Describes a {@link Role} that has been adapted to a short overview string.
 16  
  * @since 0.4.0
 17  
  */
 18  1
 public class RoleOverview implements Overview {                                                                                                
 19  
 
 20  
 
 21  
         //---- Static
 22  
         
 23  
         //---- State
 24  
         
 25  
         private Role role;                                                                                                        
 26  
         
 27  
         //---- Constructors
 28  
         
 29  
         /**
 30  
          * Creates a role overview adaptee.
 31  
          * @param role the {@link Role}.
 32  
          * @since 0.4.0
 33  
          */
 34  2
         public RoleOverview (Role role) {
 35  2
                 if (role == null) {
 36  1
                         throw new IllegalArgumentException("Role is null.");
 37  
                 }
 38  1
                 this.role = role;
 39  1
         }
 40  
         
 41  
         //---- Methods
 42  
         
 43  
         //---- Overview
 44  
         
 45  
         /**
 46  
          * @since 0.3.0
 47  
          */
 48  
         public String get () {
 49  1
                 if (this.role.getName() == null) {
 50  0
                         return "";
 51  
                 }
 52  1
                 return 
 53  
                         this.role.getRoleHierarchy().getIdentity() + 
 54  
                         " - " +
 55  
                         this.role.getName().toString();
 56  
         }
 57  
 
 58  
 
 59  
 }