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