Coverage report

  %line %branch
nl.toolforge.karma.core.location.BaseLocation
71% 
87% 

 1  
 /*
 2  
 Karma core - Core of the Karma application
 3  
 Copyright (C) 2004  Toolforge <www.toolforge.nl>
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, write to the Free Software
 17  
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
 */
 19  
 package nl.toolforge.karma.core.location;
 20  
 
 21  
 import nl.toolforge.karma.core.boot.WorkingContext;
 22  
 import nl.toolforge.karma.core.vc.AuthenticatorKey;
 23  
 
 24  
 /**
 25  
  * <code>BaseLocation</code> implements some generic <code>Location</code> functionality.
 26  
  *
 27  
  * @author D.A. Smedes
 28  
  * @version $Id: BaseLocation.java,v 1.12 2004/11/03 20:54:15 asmedes Exp $
 29  
  */
 30  
 public abstract class BaseLocation implements Location {
 31  
 
 32  3000
   private String id = null;
 33  3000
   private LocationType type = null;
 34  3000
   private WorkingContext workingContext = null;
 35  
 
 36  
   /**
 37  
    * Constructs a <code>Location</code> skeleton.
 38  
    *
 39  
    * @param id   The unique identifier for the location. Cannot be null.
 40  
    * @param type The type of the location. Cannot be null.
 41  
    */
 42  3000
   public BaseLocation(String id, LocationType type) {
 43  
 
 44  3000
     if (id == null) {
 45  0
       throw new IllegalArgumentException("Location id must be set.");
 46  
     }
 47  3000
     if (type == null) {
 48  0
       throw new IllegalArgumentException("Location must be set.");
 49  
     }
 50  3000
     this.id = id;
 51  3000
     this.type = type;
 52  3000
   }
 53  
 
 54  
   public final LocationType getType() {
 55  0
     return type;
 56  
   }
 57  
 
 58  
   public final String getId() {
 59  5218
     return id;
 60  
   }
 61  
 
 62  
   public boolean equals(Object obj) {
 63  
 
 64  0
     if (obj instanceof BaseLocation) {
 65  0
       if (((BaseLocation) obj).getId().equals(getId())) {
 66  0
         return true;
 67  
       }
 68  
     }
 69  0
     return false;
 70  
   }
 71  
 
 72  
   public int hashCode() {
 73  50
     return getId().hashCode();
 74  
   }
 75  
 
 76  
   // todo hmm, not happy with the workingcontext dependency.
 77  1502
   //
 78  1502
   public final void setWorkingContext(WorkingContext workingContext) {
 79  1442
     this.workingContext = workingContext;
 80  1442
   }
 81  1140
 
 82  
   public AuthenticatorKey getAuthenticatorKey() {
 83  420
     return new AuthenticatorKey(workingContext.getName(), getId());
 84  
   }
 85  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.