Coverage Report - org.kuali.rice.kew.workgroup.GroupNameId
 
Classes in this File Line Coverage Branch Coverage Complexity
GroupNameId
0%
0/26
0%
0/20
2.5
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.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/ecl2.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.kew.workgroup;
 17  
 
 18  
 import org.kuali.rice.kew.util.Utilities;
 19  
 import org.kuali.rice.kim.api.KimConstants;
 20  
 
 21  
 /**
 22  
  * A {@link GroupId} which identifies the name of a {@link Workgroup}.
 23  
  *
 24  
  * @see Workgroup
 25  
  *
 26  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 27  
  */
 28  
 public final class GroupNameId implements GroupId {
 29  
 
 30  
         private static final long serialVersionUID = -4625193242111678434L;
 31  
 
 32  0
         private String namespace = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE;
 33  
         private String nameId;
 34  
 
 35  0
     public GroupNameId(String nameId) {
 36  0
         this.nameId = nameId;
 37  0
         this.namespace = Utilities.parseGroupNamespaceCode(nameId);
 38  0
         this.nameId = Utilities.parseGroupName(nameId);
 39  0
     }
 40  
 
 41  0
     public GroupNameId(String namespace, String nameId) {
 42  0
             this.namespace = namespace;
 43  0
             this.nameId = nameId;
 44  0
     }
 45  
 
 46  
     public String getNameId() {
 47  0
         return nameId;
 48  
     }
 49  
 
 50  
     public String getNamespace() {
 51  0
             return namespace;
 52  
     }
 53  
 
 54  
     public boolean isEmpty() {
 55  0
       return (nameId == null) || (nameId.trim().length() == 0);
 56  
   }
 57  
 
 58  
     /**
 59  
      * If you make this class non-final, you must rewrite equals to work for subclasses.
 60  
      */
 61  
     public boolean equals(Object obj) {
 62  0
         boolean isEqual = false;
 63  
 
 64  0
         if (obj != null && (obj instanceof GroupNameId)) {
 65  0
             GroupNameId w = (GroupNameId) obj;
 66  
 
 67  0
             if (w.getNameId() != null && getNameId() != null) {
 68  0
                 return w.getNameId().equals(getNameId()) && w.getNamespace().equals(getNamespace());
 69  
             } else {
 70  0
                 return false;
 71  
             }
 72  
         }
 73  
 
 74  0
         return isEqual;
 75  
     }
 76  
 
 77  
     public int hashCode() {
 78  0
         if (nameId == null) {
 79  0
             return 0;
 80  
         }
 81  0
         return nameId.hashCode();
 82  
     }
 83  
 
 84  
     public String toString() {
 85  0
         if (nameId != null) {
 86  0
             return nameId;
 87  
         }
 88  0
         return "null";
 89  
     }
 90  
 
 91  
 }