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-2008 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.workgroup;
 18  
 
 19  
 import org.kuali.rice.kew.util.Utilities;
 20  
 import org.kuali.rice.kim.util.KimConstants;
 21  
 
 22  
 /**
 23  
  * A {@link GroupId} which identifies the name of a {@link Workgroup}.
 24  
  *
 25  
  * @see Workgroup
 26  
  *
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public final class GroupNameId implements GroupId {
 30  
 
 31  
         private static final long serialVersionUID = -4625193242111678434L;
 32  
 
 33  0
         private String namespace = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE;
 34  
         private String nameId;
 35  
 
 36  0
     public GroupNameId(String nameId) {
 37  0
         this.nameId = nameId;
 38  0
         this.namespace = Utilities.parseGroupNamespaceCode(nameId);
 39  0
         this.nameId = Utilities.parseGroupName(nameId);
 40  0
     }
 41  
 
 42  0
     public GroupNameId(String namespace, String nameId) {
 43  0
             this.namespace = namespace;
 44  0
             this.nameId = nameId;
 45  0
     }
 46  
 
 47  
     public String getNameId() {
 48  0
         return nameId;
 49  
     }
 50  
 
 51  
     public String getNamespace() {
 52  0
             return namespace;
 53  
     }
 54  
 
 55  
     public boolean isEmpty() {
 56  0
       return (nameId == null) || (nameId.trim().length() == 0);
 57  
   }
 58  
 
 59  
     /**
 60  
      * If you make this class non-final, you must rewrite equals to work for subclasses.
 61  
      */
 62  
     public boolean equals(Object obj) {
 63  0
         boolean isEqual = false;
 64  
 
 65  0
         if (obj != null && (obj instanceof GroupNameId)) {
 66  0
             GroupNameId w = (GroupNameId) obj;
 67  
 
 68  0
             if (w.getNameId() != null && getNameId() != null) {
 69  0
                 return w.getNameId().equals(getNameId()) && w.getNamespace().equals(getNamespace());
 70  
             } else {
 71  0
                 return false;
 72  
             }
 73  
         }
 74  
 
 75  0
         return isEqual;
 76  
     }
 77  
 
 78  
     public int hashCode() {
 79  0
         if (nameId == null) {
 80  0
             return 0;
 81  
         }
 82  0
         return nameId.hashCode();
 83  
     }
 84  
 
 85  
     public String toString() {
 86  0
         if (nameId != null) {
 87  0
             return nameId;
 88  
         }
 89  0
         return "null";
 90  
     }
 91  
 
 92  
 }