Coverage Report - org.kuali.rice.core.api.uif.RemotableSelectGroup
 
Classes in this File Line Coverage Branch Coverage Complexity
RemotableSelectGroup
0%
0/15
N/A
1.357
RemotableSelectGroup$1
N/A
N/A
1.357
RemotableSelectGroup$Builder
0%
0/17
0%
0/6
1.357
RemotableSelectGroup$Constants
0%
0/2
N/A
1.357
RemotableSelectGroup$Elements
0%
0/1
N/A
1.357
 
 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.core.api.uif;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.commons.lang.builder.EqualsBuilder;
 20  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 21  
 import org.apache.commons.lang.builder.ToStringBuilder;
 22  
 import org.kuali.rice.core.api.CoreConstants;
 23  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 24  
 import org.kuali.rice.core.api.mo.ModelObjectComplete;
 25  
 import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter;
 26  
 import org.w3c.dom.Element;
 27  
 
 28  
 import javax.xml.bind.annotation.XmlAccessType;
 29  
 import javax.xml.bind.annotation.XmlAccessorType;
 30  
 import javax.xml.bind.annotation.XmlAnyElement;
 31  
 import javax.xml.bind.annotation.XmlElement;
 32  
 import javax.xml.bind.annotation.XmlRootElement;
 33  
 import javax.xml.bind.annotation.XmlType;
 34  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 35  
 import java.util.Collection;
 36  
 import java.util.Collections;
 37  
 import java.util.HashMap;
 38  
 import java.util.Map;
 39  
 
 40  
 /**
 41  
  * A select control type.
 42  
  */
 43  
 @XmlRootElement(name = RemotableSelectGroup.Constants.ROOT_ELEMENT_NAME)
 44  
 @XmlAccessorType(XmlAccessType.NONE)
 45  
 @XmlType(name = RemotableSelectGroup.Constants.TYPE_NAME, propOrder = {
 46  
         RemotableSelectGroup.Elements.KEY_LABELS,
 47  
         RemotableSelectGroup.Elements.LABEL,
 48  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS })
 49  0
 public final class RemotableSelectGroup implements SelectGroup, ModelObjectComplete {
 50  
 
 51  
     @XmlElement(name = Elements.KEY_LABELS, required = true)
 52  
     @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
 53  
     private final Map<String, String> keyLabels;
 54  
 
 55  
     @XmlElement(name = Elements.LABEL, required = false)
 56  
     private final String label;
 57  
 
 58  0
     @SuppressWarnings("unused")
 59  
     @XmlAnyElement
 60  
     private final Collection<Element> _futureElements = null;
 61  
 
 62  
     /**
 63  
      * Should only be invoked by JAXB.
 64  
      */
 65  
     @SuppressWarnings("unused")
 66  0
     private RemotableSelectGroup() {
 67  0
         label = null;
 68  0
         keyLabels = null;
 69  0
     }
 70  
 
 71  0
     private RemotableSelectGroup(Builder b) {
 72  0
         label = b.label;
 73  0
         keyLabels = b.keyLabels;
 74  0
     }
 75  
 
 76  
     @Override
 77  
     public Map<String, String> getKeyLabels() {
 78  0
         return keyLabels;
 79  
     }
 80  
 
 81  
     @Override
 82  
     public String getLabel() {
 83  0
         return label;
 84  
     }
 85  
 
 86  
     @Override
 87  
     public int hashCode() {
 88  0
         return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 89  
     }
 90  
 
 91  
     @Override
 92  
     public boolean equals(Object obj) {
 93  0
         return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);
 94  
     }
 95  
 
 96  
     @Override
 97  
     public String toString() {
 98  0
         return ToStringBuilder.reflectionToString(this);
 99  
     }
 100  
 
 101  0
     public static final class Builder implements SelectGroup, ModelBuilder {
 102  
         private String label;
 103  
         private Map<String, String> keyLabels;
 104  
 
 105  0
         private Builder(Map<String, String> keyLabels, String label) {
 106  0
             setKeyLabels(keyLabels);
 107  0
             setLabel(label);
 108  0
         }
 109  
 
 110  
         public static Builder create(Map<String, String> keyLabels, String label) {
 111  0
             return new Builder(keyLabels, label);
 112  
         }
 113  
 
 114  
         @Override
 115  
         public String getLabel() {
 116  0
             return label;
 117  
         }
 118  
 
 119  
         public void setLabel(String label) {
 120  0
             if (StringUtils.isBlank(label)) {
 121  0
                 throw new IllegalArgumentException("label was blank");
 122  
             }
 123  
 
 124  0
             this.label = label;
 125  0
         }
 126  
 
 127  
         @Override
 128  
         public Map<String, String> getKeyLabels() {
 129  0
             return keyLabels;
 130  
         }
 131  
 
 132  
         public void setKeyLabels(Map<String, String> keyLabels) {
 133  0
             if (keyLabels == null || keyLabels.isEmpty()) {
 134  0
                 throw new IllegalArgumentException("keyLabels must be non-null & non-empty");
 135  
             }
 136  
 
 137  0
             this.keyLabels = Collections.unmodifiableMap(new HashMap<String, String>(keyLabels));
 138  0
         }
 139  
 
 140  
         @Override
 141  
         public RemotableSelectGroup build() {
 142  0
             return new RemotableSelectGroup(this);
 143  
         }
 144  
     }
 145  
 
 146  
     /**
 147  
      * Defines some internal constants used on this class.
 148  
      */
 149  0
     static final class Constants {
 150  
         static final String TYPE_NAME = "SelectGroupType";
 151  
         final static String ROOT_ELEMENT_NAME = "selectGroup";
 152  0
         final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS};
 153  
     }
 154  
 
 155  0
     static final class Elements {
 156  
         static final String LABEL = "label";
 157  
         static final String KEY_LABELS = "keyLabels";
 158  
     }
 159  
 }