Coverage Report - org.kuali.rice.ksb.api.registry.ServiceEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceEndpoint
0%
0/13
N/A
1.5
ServiceEndpoint$1
N/A
N/A
1.5
ServiceEndpoint$Builder
0%
0/21
0%
0/6
1.5
ServiceEndpoint$Constants
0%
0/1
N/A
1.5
ServiceEndpoint$Elements
0%
0/1
N/A
1.5
 
 1  
 package org.kuali.rice.ksb.api.registry;
 2  
 
 3  
 import java.io.Serializable;
 4  
 import java.util.Collection;
 5  
 
 6  
 import javax.xml.bind.annotation.XmlAccessType;
 7  
 import javax.xml.bind.annotation.XmlAccessorType;
 8  
 import javax.xml.bind.annotation.XmlAnyElement;
 9  
 import javax.xml.bind.annotation.XmlElement;
 10  
 import javax.xml.bind.annotation.XmlRootElement;
 11  
 import javax.xml.bind.annotation.XmlType;
 12  
 
 13  
 import org.kuali.rice.core.api.CoreConstants;
 14  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 15  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 16  
 import org.w3c.dom.Element;
 17  
 
 18  
 /**
 19  
  * Immutable implementation of the {@link ServiceEndpointContract} interface.
 20  
  * Represents a service endpoint that has been published to the service registry.
 21  
  * Includes both a {@link ServiceInfo} and {@link ServiceDescriptor} which
 22  
  * compose the two different pieces of information about a service endpoint.
 23  
  * 
 24  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 25  
  *
 26  
  */
 27  0
 @XmlRootElement(name = ServiceEndpoint.Constants.ROOT_ELEMENT_NAME)
 28  
 @XmlAccessorType(XmlAccessType.NONE)
 29  
 @XmlType(name = ServiceEndpoint.Constants.TYPE_NAME, propOrder = {
 30  
                 ServiceEndpoint.Elements.INFO,
 31  
                 ServiceEndpoint.Elements.DESCRIPTOR,
 32  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 33  
 })
 34  0
 public final class ServiceEndpoint extends AbstractDataTransferObject implements ServiceEndpointContract {
 35  
 
 36  
         private static final long serialVersionUID = -2295962329997871877L;
 37  
     
 38  
         @XmlElement(name = Elements.INFO, required = false)
 39  
     private final ServiceInfo info;
 40  
         
 41  
     @XmlElement(name = Elements.DESCRIPTOR, required = false)
 42  
     private final ServiceDescriptor descriptor;
 43  
     
 44  0
     @SuppressWarnings("unused")
 45  
     @XmlAnyElement
 46  
     private final Collection<Element> _futureElements = null;
 47  
 
 48  
     /**
 49  
      * Private constructor used only by JAXB.
 50  
      */
 51  0
     private ServiceEndpoint() {
 52  0
         this.info = null;
 53  0
             this.descriptor = null;
 54  0
     }
 55  
     
 56  0
     private ServiceEndpoint(Builder builder) {
 57  0
         this.info = builder.getInfo().build();
 58  0
         this.descriptor = builder.getDescriptor().build();
 59  0
     }
 60  
     
 61  
     @Override
 62  
     public ServiceInfo getInfo() {
 63  0
         return this.info;
 64  
     }
 65  
     
 66  
     @Override
 67  
     public ServiceDescriptor getDescriptor() {
 68  0
         return this.descriptor;
 69  
     }
 70  
 
 71  
     /**
 72  
      * A builder which can be used to construct {@link ServiceEndpoint} instances.  Enforces the constraints of the {@link ServiceEndpointContract}.
 73  
      */
 74  0
     public final static class Builder implements Serializable, ModelBuilder, ServiceEndpointContract {
 75  
 
 76  
                 private static final long serialVersionUID = -1783718474634197837L;
 77  
 
 78  
                 private ServiceInfo.Builder info;
 79  
         private ServiceDescriptor.Builder descriptor;
 80  
 
 81  0
         private Builder(ServiceInfo.Builder info, ServiceDescriptor.Builder descriptor) {
 82  0
             setInfo(info);
 83  0
             setDescriptor(descriptor);
 84  0
         }
 85  
 
 86  
         public static Builder create(ServiceInfo.Builder info, ServiceDescriptor.Builder descriptor) {
 87  0
             return new Builder(info, descriptor);
 88  
         }
 89  
 
 90  
         public static Builder create(ServiceEndpointContract contract) {
 91  0
             if (contract == null) {
 92  0
                 throw new IllegalArgumentException("contract was null");
 93  
             }
 94  0
             Builder builder = create(ServiceInfo.Builder.create(contract.getInfo()), ServiceDescriptor.Builder.create(contract.getDescriptor()));
 95  0
             return builder;
 96  
         }
 97  
 
 98  
         public ServiceEndpoint build() {
 99  0
             return new ServiceEndpoint(this);
 100  
         }
 101  
 
 102  
         @Override
 103  
         public ServiceInfo.Builder getInfo() {
 104  0
             return this.info;
 105  
         }
 106  
         
 107  
         @Override
 108  
         public ServiceDescriptor.Builder getDescriptor() {
 109  0
             return this.descriptor;
 110  
         }
 111  
         
 112  
         public void setInfo(ServiceInfo.Builder info) {
 113  0
             if (info == null) {
 114  0
                     throw new IllegalArgumentException("info was null");
 115  
             }
 116  0
             this.info = info;
 117  0
         }
 118  
 
 119  
         public void setDescriptor(ServiceDescriptor.Builder descriptor) {
 120  0
                 if (descriptor == null) {
 121  0
                     throw new IllegalArgumentException("descriptor was null");
 122  
             }
 123  0
             this.descriptor = descriptor;
 124  0
         }
 125  
         
 126  
     }
 127  
 
 128  
 
 129  
     /**
 130  
      * Defines some internal constants used on this class.
 131  
      */
 132  0
     static class Constants {
 133  
 
 134  
         final static String ROOT_ELEMENT_NAME = "serviceEndpoint";
 135  
         final static String TYPE_NAME = "ServiceEndpointType";
 136  
 
 137  
     }
 138  
 
 139  
 
 140  
     /**
 141  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 142  
      */
 143  0
     static class Elements {
 144  
 
 145  
         final static String INFO = "info";
 146  
         final static String DESCRIPTOR = "descriptor";
 147  
 
 148  
     }
 149  
     
 150  
 }