Coverage Report - org.kuali.rice.core.util.ConcreteKeyValue
 
Classes in this File Line Coverage Branch Coverage Complexity
ConcreteKeyValue
0%
0/40
0%
0/24
3
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl1.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.util;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import org.apache.commons.lang.builder.CompareToBuilder;
 21  
 
 22  
 /**
 23  
  * A mutable, comparable key value pair of Strings.
 24  
  *  
 25  
  * This class is not meant to be extended.
 26  
  * 
 27  
  * For extension see AbstractKeyValue & KeyValue.
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  0
 public final class ConcreteKeyValue extends AbstractKeyValue implements Comparable<KeyValue> {
 32  
         private static final long serialVersionUID = 1176799455504861488L;
 33  
 
 34  
         public ConcreteKeyValue() {
 35  0
                 super();
 36  0
         }
 37  
 
 38  
         public ConcreteKeyValue(String key, String value) {
 39  0
                 super(key, value);
 40  0
         }
 41  
 
 42  
         public ConcreteKeyValue(KeyValue keyValue) {
 43  0
                 super(keyValue);
 44  0
         }
 45  
         
 46  
         public ConcreteKeyValue(Map.Entry<String, String> entry) {
 47  0
                 super(entry);
 48  0
         }
 49  
         
 50  
         public void setKey(String key) {
 51  0
                 this.key = key;
 52  0
         }
 53  
 
 54  
         public void setValue(String value) {
 55  0
                 this.value = value;
 56  0
         }
 57  
 
 58  
         @Override
 59  
         public int compareTo(KeyValue o) {
 60  0
                 if (o == null) {
 61  0
                         throw new NullPointerException("o is null");
 62  
                 }
 63  
 
 64  0
                 return new CompareToBuilder()
 65  
                         .append(this.getValue(), o.getValue(), String.CASE_INSENSITIVE_ORDER)
 66  
                         .append(this.getKey(), o.getKey(), String.CASE_INSENSITIVE_ORDER)
 67  
                         .toComparison();
 68  
         }
 69  
         
 70  
         @Override
 71  
         public int hashCode() {
 72  0
                 final int prime = 31;
 73  0
                 int result = 1;
 74  0
                 result = prime * result
 75  
                                 + ((this.getKey() == null) ? 0 : this.getKey().hashCode());
 76  0
                 result = prime * result
 77  
                                 + ((this.getValue() == null) ? 0 : this.getValue().hashCode());
 78  0
                 return result;
 79  
         }
 80  
 
 81  
         @Override
 82  
         public boolean equals(Object obj) {
 83  0
                 if (this == obj)
 84  0
                         return true;
 85  0
                 if (obj == null)
 86  0
                         return false;
 87  0
                 if (getClass() != obj.getClass())
 88  0
                         return false;
 89  0
                 KeyValue other = (KeyValue) obj;
 90  0
                 if (this.getKey() == null) {
 91  0
                         if (other.getKey() != null)
 92  0
                                 return false;
 93  0
                 } else if (!this.getKey().equals(other.getKey()))
 94  0
                         return false;
 95  0
                 if (this.getValue() == null) {
 96  0
                         if (other.getValue() != null)
 97  0
                                 return false;
 98  0
                 } else if (!this.getValue().equals(other.getValue()))
 99  0
                         return false;
 100  0
                 return true;
 101  
         }
 102  
         
 103  
         @Override
 104  
         public String toString() {
 105  0
                 return "ConcreteKeyValue [getKey()=" + this.getKey() + ", getValue()="
 106  
                                 + this.getValue() + "]";
 107  
         }
 108  
 }