Coverage Report - org.apache.creadur.whisker.model.Organisation
 
Classes in this File Line Coverage Branch Coverage Complexity
Organisation
38%
12/31
6%
1/16
2.444
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  *  to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  *  with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License. 
 18  
  */
 19  
 package org.apache.creadur.whisker.model;
 20  
 
 21  
 import java.util.Map;
 22  
 
 23  
 /**
 24  
  * Describes a group or individual with responsibility for 
 25  
  * upstream distributions.
 26  
  */
 27  1
 public class Organisation implements Comparable<Organisation> {
 28  
 
 29  
     /** Identifies this group or individual with responsibility. */
 30  
     private final String id;
 31  
     /** A name for this group or individual suitable for presentation. */
 32  
     private final String name;
 33  
     /** A locator for the home of this group or individual. */
 34  
     private final String url;
 35  
 
 36  
     /**
 37  
      * Constructs an instance.
 38  
      * @param id identifies this group or individual 
 39  
      * with responsibility for 
 40  
      * upstream distributions, not null
 41  
      * @param name a name for this group or individual 
 42  
      * suitable for presentation, not null
 43  
      * @param url a locator for the home of this group 
 44  
      * or individual, not null
 45  
      */
 46  
     public Organisation(final String id, final String name, final String url) {
 47  10
         super();
 48  10
         this.id = id;
 49  10
         this.name = name;
 50  10
         this.url = url;
 51  10
     }
 52  
 
 53  
     /**
 54  
      * Stores this organisation by id.
 55  
      * @param organisationsById not null
 56  
      * @return this organisation
 57  
      */
 58  
     public Organisation storeIn(
 59  
             final Map<String, Organisation> organisationsById) {
 60  6
         organisationsById.put(this.id, this);
 61  6
         return this;
 62  
     }
 63  
 
 64  
     /**
 65  
      * Gets a name for this group or individual 
 66  
      * suitable for presentation.
 67  
      * @return not null
 68  
      */
 69  
     public String getName() {
 70  2
         return this.name;
 71  
     }
 72  
 
 73  
     /**
 74  
      * Gets a locator for the home of this group 
 75  
      * or individual.
 76  
      * @return not null
 77  
      */
 78  
     public String getURL() {
 79  0
         return this.url;
 80  
     }
 81  
 
 82  
     /**
 83  
      * Gets an identifier for this group or individual 
 84  
      * with responsibility for 
 85  
      * upstream distributions.
 86  
      * @return not null
 87  
      */
 88  
     public String getId() {
 89  4
         return this.id;
 90  
     }
 91  
 
 92  
     @Override
 93  
     public int hashCode() {
 94  0
         final int prime = 31;
 95  0
         int result = 1;
 96  0
         result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
 97  0
         return result;
 98  
     }
 99  
 
 100  
     @Override
 101  
     public boolean equals(final Object obj) {
 102  0
         if (this == obj) {
 103  0
             return true;
 104  
         }
 105  0
         if (obj == null) {
 106  0
             return false;
 107  
         }
 108  0
         if (getClass() != obj.getClass()) {
 109  0
             return false;
 110  
         }
 111  0
         final Organisation other = (Organisation) obj;
 112  0
         if (this.id == null) {
 113  0
             if (other.id != null) {
 114  0
                 return false;
 115  
             }
 116  0
         } else if (!this.id.equals(other.id)) {
 117  0
             return false;
 118  
         }
 119  0
         return true;
 120  
     }
 121  
 
 122  
     /**
 123  
      * @see java.lang.Comparable#compareTo(java.lang.Object)
 124  
      */
 125  
     public int compareTo(final Organisation other) {
 126  1
         final int nameDifference = getName().compareTo(other.getName());
 127  1
         return nameDifference == 0 ? getId().compareTo(other.getId())
 128  
                 : nameDifference;
 129  
     }
 130  
 
 131  
     @Override
 132  
     public String toString() {
 133  0
         return "Organisation [id=" + this.id + ", name=" + this.name + ", url="
 134  
                 + this.url + "]";
 135  
     }
 136  
 }