Clover coverage report - Acegi Security System for Spring - 1.0.0-RC1
Coverage timestamp: Mon Dec 5 2005 09:05:15 EST
file stats: LOC: 75   Methods: 6
NCLOC: 31   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
GrantedAuthorityImpl.java 100% 100% 100% 100%
coverage
 1    /* Copyright 2004 Acegi Technology Pty Limited
 2    *
 3    * Licensed under the Apache License, Version 2.0 (the "License");
 4    * you may not use this file except in compliance with the License.
 5    * You may obtain a copy of the License at
 6    *
 7    * http://www.apache.org/licenses/LICENSE-2.0
 8    *
 9    * Unless required by applicable law or agreed to in writing, software
 10    * distributed under the License is distributed on an "AS IS" BASIS,
 11    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    * See the License for the specific language governing permissions and
 13    * limitations under the License.
 14    */
 15   
 16    package org.acegisecurity;
 17   
 18    import java.io.Serializable;
 19   
 20   
 21    /**
 22    * Basic concrete implementation of a {@link GrantedAuthority}.
 23    *
 24    * <p>
 25    * Stores a <code>String</code> representation of an authority granted to the
 26    * {@link Authentication} object.
 27    * </p>
 28    *
 29    * @author Ben Alex
 30    * @version $Id: GrantedAuthorityImpl.java,v 1.5 2005/11/17 00:55:49 benalex Exp $
 31    */
 32    public class GrantedAuthorityImpl implements GrantedAuthority, Serializable {
 33    //~ Instance fields ========================================================
 34   
 35    private String role;
 36   
 37    //~ Constructors ===========================================================
 38   
 39  985 public GrantedAuthorityImpl(String role) {
 40  985 super();
 41  985 this.role = role;
 42    }
 43   
 44  1 protected GrantedAuthorityImpl() {
 45  1 throw new IllegalArgumentException("Cannot use default constructor");
 46    }
 47   
 48    //~ Methods ================================================================
 49   
 50  307 public String getAuthority() {
 51  307 return this.role;
 52    }
 53   
 54  247 public boolean equals(Object obj) {
 55  247 if (obj instanceof String) {
 56  106 return obj.equals(this.role);
 57    }
 58   
 59  141 if (obj instanceof GrantedAuthority) {
 60  140 GrantedAuthority attr = (GrantedAuthority) obj;
 61   
 62  140 return this.role.equals(attr.getAuthority());
 63    }
 64   
 65  1 return false;
 66    }
 67   
 68  43 public int hashCode() {
 69  43 return this.role.hashCode();
 70    }
 71   
 72  218 public String toString() {
 73  218 return this.role;
 74    }
 75    }