Coverage Report - org.kuali.rice.ksb.api.registry.ServiceDescriptor
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceDescriptor
0%
0/15
N/A
1.133
ServiceDescriptor$1
N/A
N/A
1.133
ServiceDescriptor$Builder
0%
0/21
0%
0/2
1.133
ServiceDescriptor$Constants
0%
0/1
N/A
1.133
ServiceDescriptor$Elements
0%
0/1
N/A
1.133
 
 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.ksb.api.registry;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.kuali.rice.core.api.CoreConstants;
 29  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 30  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 31  
 import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
 32  
 import org.w3c.dom.Element;
 33  
 
 34  
 /**
 35  
  * Immutable implementation of the {@link ServiceDescriptorContract} interface.
 36  
  * Includes a serialized XML representation of the {@link ServiceConfiguration}
 37  
  * for the service.
 38  
  * 
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  *
 41  
  */
 42  
 @XmlRootElement(name = ServiceDescriptor.Constants.ROOT_ELEMENT_NAME)
 43  
 @XmlAccessorType(XmlAccessType.NONE)
 44  
 @XmlType(name = ServiceDescriptor.Constants.TYPE_NAME, propOrder = {
 45  
     ServiceDescriptor.Elements.ID,
 46  
     ServiceDescriptor.Elements.DESCRIPTOR,
 47  
     CoreConstants.CommonElements.VERSION_NUMBER,
 48  
     CoreConstants.CommonElements.FUTURE_ELEMENTS
 49  
 })
 50  0
 public final class ServiceDescriptor extends AbstractDataTransferObject
 51  
     implements ServiceDescriptorContract
 52  
 {
 53  
 
 54  
         private static final long serialVersionUID = 4555599272613878634L;
 55  
 
 56  
         @XmlElement(name = Elements.ID, required = false)
 57  
     private final String id;
 58  
         
 59  
     @XmlElement(name = Elements.DESCRIPTOR, required = false)
 60  
     private final String descriptor;
 61  
     
 62  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 63  
     private final Long versionNumber;
 64  
     
 65  0
     @SuppressWarnings("unused")
 66  
     @XmlAnyElement
 67  
     private final Collection<Element> _futureElements = null;
 68  
 
 69  
     /**
 70  
      * Private constructor used only by JAXB.
 71  
      * 
 72  
      */
 73  0
     private ServiceDescriptor() {
 74  0
         this.id = null;
 75  0
         this.descriptor = null;
 76  0
         this.versionNumber = null;
 77  0
     }
 78  
 
 79  0
     private ServiceDescriptor(Builder builder) {
 80  0
         this.id = builder.getId();
 81  0
         this.descriptor = builder.getDescriptor();
 82  0
         this.versionNumber = builder.getVersionNumber();
 83  0
     }
 84  
 
 85  
     @Override
 86  
     public String getId() {
 87  0
         return this.id;
 88  
     }
 89  
 
 90  
     @Override
 91  
     public String getDescriptor() {
 92  0
         return this.descriptor;
 93  
     }
 94  
 
 95  
     @Override
 96  
     public Long getVersionNumber() {
 97  0
         return this.versionNumber;
 98  
     }
 99  
 
 100  
 
 101  
     /**
 102  
      * A builder which can be used to construct {@link ServiceDescriptor} instances.  Enforces the constraints of the {@link ServiceDescriptorContract}.
 103  
      * 
 104  
      */
 105  0
     public final static class Builder
 106  
         implements Serializable, ModelBuilder, ServiceDescriptorContract
 107  
     {
 108  
 
 109  
                 private static final long serialVersionUID = 4439417051199359358L;
 110  
 
 111  
                 private String id;
 112  
         private String descriptor;
 113  
         private Long versionNumber;
 114  
 
 115  0
         private Builder() {
 116  0
         }
 117  
 
 118  
         public static Builder create() {
 119  0
             return new Builder();
 120  
         }
 121  
 
 122  
         public static Builder create(ServiceDescriptorContract contract) {
 123  0
             if (contract == null) {
 124  0
                 throw new IllegalArgumentException("contract was null");
 125  
             }
 126  0
             Builder builder = create();
 127  0
             builder.setId(contract.getId());
 128  0
             builder.setDescriptor(contract.getDescriptor());
 129  0
             builder.setVersionNumber(contract.getVersionNumber());
 130  0
             return builder;
 131  
         }
 132  
 
 133  
         public ServiceDescriptor build() {
 134  0
             return new ServiceDescriptor(this);
 135  
         }
 136  
 
 137  
         @Override
 138  
         public String getId() {
 139  0
             return this.id;
 140  
         }
 141  
 
 142  
         @Override
 143  
         public String getDescriptor() {
 144  0
             return this.descriptor;
 145  
         }
 146  
 
 147  
         @Override
 148  
         public Long getVersionNumber() {
 149  0
             return this.versionNumber;
 150  
         }
 151  
 
 152  
         public void setId(String id) {
 153  0
             this.id = id;
 154  0
         }
 155  
 
 156  
         public void setDescriptor(String descriptor) {
 157  0
             this.descriptor = descriptor;
 158  0
         }
 159  
 
 160  
         public void setVersionNumber(Long versionNumber) {
 161  0
             this.versionNumber = versionNumber;
 162  0
         }
 163  
 
 164  
     }
 165  
 
 166  
 
 167  
     /**
 168  
      * Defines some internal constants used on this class.
 169  
      * 
 170  
      */
 171  0
     static class Constants {
 172  
 
 173  
         final static String ROOT_ELEMENT_NAME = "serviceDescriptor";
 174  
         final static String TYPE_NAME = "ServiceDescriptorType";
 175  
     }
 176  
 
 177  
 
 178  
     /**
 179  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 180  
      * 
 181  
      */
 182  0
     static class Elements {
 183  
 
 184  
         final static String ID = "id";
 185  
         final static String DESCRIPTOR = "descriptor";
 186  
 
 187  
     }
 188  
 
 189  
 }
 190