Coverage Report - org.kuali.rice.krms.api.repository.term.TermResolverDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
TermResolverDefinition
69%
27/39
50%
1/2
1.378
TermResolverDefinition$1
N/A
N/A
1.378
TermResolverDefinition$Builder
69%
48/69
50%
8/16
1.378
TermResolverDefinition$Constants
0%
0/1
N/A
1.378
TermResolverDefinition$Elements
0%
0/1
N/A
1.378
 
 1  
 /*
 2  
  * Copyright 2011 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.krms.api.repository.term;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 21  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 22  
 import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter;
 23  
 import org.kuali.rice.krms.api.repository.BuilderUtils;
 24  
 
 25  
 import javax.xml.bind.annotation.XmlAccessType;
 26  
 import javax.xml.bind.annotation.XmlAccessorType;
 27  
 import javax.xml.bind.annotation.XmlAnyElement;
 28  
 import javax.xml.bind.annotation.XmlElement;
 29  
 import javax.xml.bind.annotation.XmlElementWrapper;
 30  
 import javax.xml.bind.annotation.XmlRootElement;
 31  
 import javax.xml.bind.annotation.XmlType;
 32  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 33  
 import java.io.Serializable;
 34  
 import java.util.Collection;
 35  
 import java.util.Collections;
 36  
 import java.util.Map;
 37  
 import java.util.Set;
 38  
 
 39  
 /**
 40  
  * This is a description of what this class does - gilesp don't forget to fill this in. 
 41  
  * 
 42  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 43  
  *
 44  
  */
 45  0
 @XmlRootElement(name = TermResolverDefinition.Constants.ROOT_ELEMENT_NAME)
 46  
 @XmlAccessorType(XmlAccessType.NONE)
 47  
 @XmlType(name = TermResolverDefinition.Constants.TYPE_NAME, propOrder = {
 48  
                 TermResolverDefinition.Elements.ID,
 49  
                 TermResolverDefinition.Elements.NAME,
 50  
         TermResolverDefinition.Elements.NAMESPACE_CODE,
 51  
         TermResolverDefinition.Elements.CONTEXT_ID,
 52  
                 TermResolverDefinition.Elements.TYPE_ID,
 53  
                 TermResolverDefinition.Elements.OUTPUT,
 54  
                 TermResolverDefinition.Elements.PREREQUISITES,
 55  
                 TermResolverDefinition.Elements.ATTRIBUTES,
 56  
                 TermResolverDefinition.Elements.PARAMETER_NAMES,
 57  
         CoreConstants.CommonElements.VERSION_NUMBER,
 58  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 59  
 })
 60  1
 public final class TermResolverDefinition extends AbstractDataTransferObject implements TermResolverDefinitionContract {
 61  
         
 62  
     private static final long serialVersionUID = 1L;
 63  
         
 64  
         @XmlElement(name = Elements.ID, required=false)
 65  
         private final String id;
 66  
         @XmlElement(name = Elements.NAMESPACE_CODE, required=true)
 67  
         private final String namespaceCode;
 68  
         @XmlElement(name = Elements.NAME, required=true)
 69  
         private final String name;
 70  
     @XmlElement(name = Elements.CONTEXT_ID, required=false)
 71  
     private final String contextId;
 72  
     @XmlElement(name = Elements.TYPE_ID, required=true)
 73  
     private final String typeId;
 74  
         @XmlElement(name = Elements.OUTPUT, required=false)
 75  
         private final TermSpecificationDefinition output;
 76  
 
 77  
         @XmlElement(name = "termSpecificationDefinition", required=false)
 78  
         @XmlElementWrapper(name = Elements.PREREQUISITES, required=false)
 79  
         private final Set<TermSpecificationDefinition> prerequisites;
 80  
 
 81  
         @XmlElement(name = Elements.ATTRIBUTES, required = false)
 82  
         @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
 83  
         private final Map<String, String> attributes;
 84  
 
 85  
         @XmlElementWrapper(name = Elements.PARAMETER_NAMES, required=false)
 86  
         @XmlElement(name = "parameterName")
 87  
         private final Set<String> parameterNames;
 88  
 
 89  
         @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 90  
     private final Long versionNumber;        
 91  
         
 92  3
     @SuppressWarnings("unused")
 93  
         @XmlAnyElement
 94  
         private final Collection<org.w3c.dom.Element> _futureElements = null;
 95  
     
 96  
         /**
 97  
          * This private constructor is for JAXB use only, don't invoke directly.
 98  
          */
 99  2
         private TermResolverDefinition() {
 100  2
                 id = null;
 101  2
                 namespaceCode = null;
 102  2
                 name = null;
 103  2
                 contextId = null;
 104  2
                 typeId = null;
 105  2
                 output = null;
 106  2
                 prerequisites = null;
 107  2
                 attributes = null;
 108  2
                 parameterNames = null;
 109  2
         versionNumber = null;
 110  2
         }
 111  
         
 112  1
         private TermResolverDefinition(Builder builder) {
 113  1
                 this.id = builder.getId();
 114  1
                 this.namespaceCode = builder.getNamespaceCode();
 115  1
                 this.name = builder.getName();
 116  1
                 this.contextId = builder.getContextId();
 117  1
                 this.typeId = builder.getTypeId();
 118  1
                 this.output = builder.getOutput().build();
 119  1
                 this.prerequisites = BuilderUtils.convertFromBuilderSet(builder.getPrerequisites());
 120  1
                 this.parameterNames = Collections.unmodifiableSet(builder.getParameterNames());
 121  1
                 this.versionNumber = builder.getVersionNumber();
 122  1
         if (builder.attributes != null){
 123  1
                 this.attributes = Collections.unmodifiableMap(builder.getAttributes());
 124  
         } else {
 125  0
                 this.attributes = null;
 126  
         }
 127  1
         }
 128  
         
 129  2
         public static class Builder implements TermResolverDefinitionContract, ModelBuilder, 
 130  
                 Serializable {
 131  
                 
 132  
                 private static final long serialVersionUID = 1L;
 133  
                 
 134  
                 private String id;
 135  
                 private String namespaceCode;
 136  
                 private String name;
 137  
         private String contextId;
 138  
         private String typeId;
 139  
                 private TermSpecificationDefinition.Builder output;
 140  
                 private Set<TermSpecificationDefinition.Builder> prerequisites;
 141  
         private Map<String, String> attributes;
 142  
                 private Set<String> parameterNames;
 143  
         private Long versionNumber;
 144  
                 
 145  
                 private Builder(String id,
 146  
                                 String namespaceCode,
 147  
                                 String name,
 148  
                 String contextId,
 149  
                 String typeId,
 150  
                                 TermSpecificationDefinition.Builder output,
 151  
                                 Set<TermSpecificationDefinition.Builder> prerequisites,
 152  
                                 Map<String, String> attributes,
 153  1
                                 Set<String> parameterNames) {
 154  1
                         setId(id);
 155  1
                         setNamespaceCode(namespaceCode);
 156  1
                         setName(name);
 157  1
                         setContextId(contextId);
 158  1
                         setTypeId(typeId);
 159  1
                         setOutput(output);
 160  1
                         setPrerequisites(prerequisites);
 161  1
                         setAttributes(attributes);
 162  1
                         setParameterNames(parameterNames);
 163  1
                 }
 164  
                 
 165  
                 
 166  
                 
 167  0
                 private Builder(TermResolverDefinitionContract termResolver) {
 168  0
                         setId(termResolver.getId());
 169  0
                         setNamespaceCode(termResolver.getNamespaceCode());
 170  0
                         setName(termResolver.getName());
 171  0
                         setContextId(termResolver.getContextId());
 172  0
                         setTypeId(termResolver.getTypeId());
 173  0
                         setOutput(TermSpecificationDefinition.Builder.create(termResolver.getOutput()));
 174  0
                         setPrerequisites(BuilderUtils.transform(termResolver.getPrerequisites(), TermSpecificationDefinition.Builder.toBuilder));
 175  0
                         setAttributes(termResolver.getAttributes());
 176  0
                         this.setParameterNames(termResolver.getParameterNames());
 177  0
                         this.setVersionNumber(termResolver.getVersionNumber());
 178  0
                 }
 179  
                 
 180  
                 public static Builder create(TermResolverDefinitionContract termResolver) {
 181  0
                         return new Builder(termResolver);
 182  
                 }
 183  
                 
 184  
                 public static Builder create(String id,
 185  
                                 String namespaceCode,
 186  
                                 String name,
 187  
                                 String contextId,
 188  
                                 String typeId,
 189  
                                 TermSpecificationDefinition.Builder output,
 190  
                                 Set<TermSpecificationDefinition.Builder> prerequisites,
 191  
                                 Map<String, String> attributes,
 192  
                                 Set<String> parameterNames) {
 193  1
                         return new Builder(id, namespaceCode, name, contextId, typeId, output, prerequisites, attributes, parameterNames); 
 194  
                 }
 195  
 
 196  
                 // Builder setters:
 197  
                 // TODO: proper validation & javadocs
 198  
                 
 199  
                 /**
 200  
                  * @param id the id to set
 201  
                  */
 202  
                 public void setId(String id) {
 203  1
                         if (id != null && StringUtils.isBlank(id)) {
 204  0
                                 throw new IllegalArgumentException(/* TODO */);
 205  
                         }
 206  1
                         this.id = id;
 207  1
                 }
 208  
 
 209  
                 /**
 210  
                  * @param namespaceCode the namespaceCode to set
 211  
                  */
 212  
                 public void setNamespaceCode(String namespaceCode) {
 213  1
                         if (StringUtils.isBlank(namespaceCode)) {
 214  0
                                 throw new IllegalArgumentException(/* TODO */);
 215  
                         }
 216  1
                         this.namespaceCode = namespaceCode;
 217  1
                 }
 218  
 
 219  
                 /**
 220  
                  * @param name the name to set
 221  
                  */
 222  
                 public void setName(String name) {
 223  1
                         if (StringUtils.isBlank(name)) {
 224  0
                                 throw new IllegalArgumentException(/* TODO */);
 225  
                         }
 226  1
                         this.name = name;
 227  1
                 }
 228  
 
 229  
         /**
 230  
          * @param contextId the contextId to set
 231  
          */
 232  
         public void setContextId(String contextId) {
 233  1
             this.contextId = contextId;
 234  1
         }
 235  
                 
 236  
                 /**
 237  
                  * @param typeId the typeId to set
 238  
                  */
 239  
                 public void setTypeId(String typeId) {
 240  1
                         if (StringUtils.isBlank(typeId)) {
 241  0
                                 throw new IllegalArgumentException(/* TODO */);
 242  
                         }
 243  1
                         this.typeId = typeId;
 244  1
                 }
 245  
 
 246  
                 /**
 247  
                  * @param output the output to set
 248  
                  */
 249  
                 public void setOutput(TermSpecificationDefinition.Builder output) {
 250  1
                         if (output == null) {
 251  0
                                 throw new IllegalArgumentException(/* TODO */);
 252  
                         }
 253  1
                         this.output = output;
 254  1
                 }
 255  
 
 256  
                 /**
 257  
                  * @param prerequisites the prerequisites to set
 258  
                  */
 259  
                 public void setPrerequisites(
 260  
                                 Set<TermSpecificationDefinition.Builder> prerequisites) {
 261  1
                         this.prerequisites = prerequisites;
 262  1
                 }
 263  
 
 264  
                 /**
 265  
                  * @param attributes the attributes to set
 266  
                  */
 267  
                 public void setAttributes(Map<String, String> attributes){
 268  1
                         if (attributes == null){
 269  0
                                 this.attributes = Collections.emptyMap();
 270  
                         } else {
 271  1
                                 this.attributes = Collections.unmodifiableMap(attributes);
 272  
                         }
 273  1
                 }
 274  
 
 275  
                 /**
 276  
                  * @param parameterNames the parameterNames to set
 277  
                  */
 278  
                 public void setParameterNames(Set<String> parameterNames) {
 279  1
                         this.parameterNames = parameterNames;
 280  1
                 }                
 281  
                 
 282  
                 /**
 283  
                  * @param versionNumber the versionNumber to set.  May be null.
 284  
                  */
 285  
         public void setVersionNumber(Long versionNumber){
 286  0
             this.versionNumber = versionNumber;
 287  0
         }
 288  
         
 289  
                 // Builder getters:
 290  
 
 291  
                 /**
 292  
                  * @return the id
 293  
                  */
 294  
                 public String getId() {
 295  1
                         return this.id;
 296  
                 }
 297  
                 
 298  
                 /**
 299  
                  * @return the namespaceCode
 300  
                  */
 301  
                 public String getNamespaceCode() {
 302  1
                         return this.namespaceCode;
 303  
                 }
 304  
                 /**
 305  
                  * @return the name
 306  
                  */
 307  
                 public String getName() {
 308  1
                         return this.name;
 309  
                 }
 310  
         /**
 311  
          * @return the contextId
 312  
          */
 313  
         public String getContextId() {
 314  1
             return this.contextId;
 315  
         }
 316  
                 /**
 317  
                  * @return the typeId
 318  
                  */
 319  
                 public String getTypeId() {
 320  1
                         return this.typeId;
 321  
                 }
 322  
                 /**
 323  
                  * @return the output
 324  
                  */
 325  
                 public TermSpecificationDefinition.Builder getOutput() {
 326  1
                         return this.output;
 327  
                 }
 328  
                 /**
 329  
                  * @return the prerequisites
 330  
                  */
 331  
                 public Set<TermSpecificationDefinition.Builder> getPrerequisites() {
 332  1
                         return this.prerequisites;
 333  
                 }
 334  
                 /**
 335  
                  * @return the attributes
 336  
                  */
 337  
                 public Map<String, String> getAttributes() {
 338  1
                         return this.attributes;
 339  
                 }
 340  
                 /**
 341  
                  * @return the parameterNames
 342  
                  */
 343  
                 public Set<String> getParameterNames() {
 344  1
                         return (parameterNames == null) ? Collections.<String>emptySet() : parameterNames;
 345  
                 }
 346  
                 
 347  
                 /**
 348  
                  * @return the version number
 349  
                  */
 350  
         @Override
 351  
         public Long getVersionNumber() {
 352  1
             return this.versionNumber;
 353  
         }
 354  
 
 355  
                 /**
 356  
                  * This overridden method ...
 357  
                  * 
 358  
                  * @see org.kuali.rice.core.api.mo.ModelBuilder#build()
 359  
                  */
 360  
                 @Override
 361  
                 public TermResolverDefinition build() {
 362  1
                         return new TermResolverDefinition(this);
 363  
                 }
 364  
                 
 365  
         }
 366  
         
 367  
         /**
 368  
          * @return the id
 369  
          */
 370  
         @Override
 371  
         public String getId() {
 372  0
                 return this.id;
 373  
         }
 374  
         
 375  
         /**
 376  
          * @return the namespaceCode
 377  
          */
 378  
         @Override
 379  
         public String getNamespaceCode() {
 380  0
                 return this.namespaceCode;
 381  
         }
 382  
         
 383  
         /**
 384  
          * @return the name
 385  
          */
 386  
         @Override
 387  
         public String getName() {
 388  0
                 return this.name;
 389  
         }
 390  
         
 391  
     /**
 392  
      * @return the contextId
 393  
      */
 394  
     public String getContextId() {
 395  0
         return this.contextId;
 396  
     }
 397  
 
 398  
         /**
 399  
          * @return the typeId
 400  
          */
 401  
         @Override
 402  
         public String getTypeId() {
 403  0
                 return this.typeId;
 404  
         }
 405  
         
 406  
         /**
 407  
          * @return the specification
 408  
          */
 409  
         @Override
 410  
         public TermSpecificationDefinition getOutput() {
 411  0
                 return this.output;
 412  
         }
 413  
         
 414  
         /**
 415  
          * @return the prerequisites
 416  
          */
 417  
         @Override
 418  
         public Set<TermSpecificationDefinition> getPrerequisites() {
 419  0
                 return this.prerequisites;
 420  
         }
 421  
         /**
 422  
          * @return the attributes
 423  
          */
 424  
         @Override
 425  
         public Map<String, String> getAttributes() {
 426  0
                 return this.attributes;
 427  
         }
 428  
 
 429  
         /**
 430  
          * @return the parameterNames
 431  
          */
 432  
         @Override
 433  
         public Set<String> getParameterNames() {
 434  0
                 return this.parameterNames;
 435  
         }
 436  
         
 437  
         /**
 438  
          * @see org.kuali.rice.core.api.mo.common.Versioned#getVersionNumber()
 439  
          */
 440  
     @Override
 441  
     public Long getVersionNumber() {
 442  0
         return versionNumber;
 443  
     }
 444  
         
 445  
         /**
 446  
          * Defines some internal constants used on this class.
 447  
          */
 448  0
         static class Constants {
 449  
                 final static String ROOT_ELEMENT_NAME = "termResolverDefinition";
 450  
                 final static String TYPE_NAME = "termResolverDefinitionType";
 451  
         }
 452  
         
 453  0
         static class Elements {
 454  
                 public static final String ID = "id";
 455  
                 public static final String NAMESPACE_CODE = "namespaceCode";
 456  
                 public static final String NAME = "name";
 457  
         public static final String CONTEXT_ID = "contextId";
 458  
         public static final String TYPE_ID = "typeId";
 459  
                 public static final String OUTPUT = "output";
 460  
                 public static final String PREREQUISITES = "prerequisites";
 461  
                 public static final String ATTRIBUTES = "attributes";
 462  
                 public static final String PARAMETER_NAMES = "parameterNames";
 463  
         }
 464  
 }