[507] | 1 | package gov.hhs.fha.nhinc.subscription.repository.data;
|
---|
| 2 |
|
---|
| 3 | import gov.hhs.fha.nhinc.subscription.repository.SubscriptionRepositoryException;
|
---|
| 4 | import java.io.Serializable;
|
---|
| 5 | import java.util.ArrayList;
|
---|
| 6 | import java.util.Iterator;
|
---|
| 7 | import java.util.List;
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * Data class for a subscription reference
|
---|
| 11 | *
|
---|
| 12 | * @author Neil Webb
|
---|
| 13 | */
|
---|
| 14 | public class SubscriptionReference implements Serializable
|
---|
| 15 | {
|
---|
| 16 | private static final long serialVersionUID = -5693688804432186068L;
|
---|
| 17 | private String subscriptionManagerEndpointAddress;
|
---|
| 18 | private List<ReferenceParameter> referenceParameters;
|
---|
| 19 |
|
---|
| 20 | public String getSubscriptionManagerEndpointAddress()
|
---|
| 21 | {
|
---|
| 22 | return subscriptionManagerEndpointAddress;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public void setSubscriptionManagerEndpointAddress(String subscriptionManagerEndpointAddress)
|
---|
| 26 | {
|
---|
| 27 | this.subscriptionManagerEndpointAddress = subscriptionManagerEndpointAddress;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public List<ReferenceParameter> getReferenceParameters()
|
---|
| 31 | {
|
---|
| 32 | if (referenceParameters == null)
|
---|
| 33 | {
|
---|
| 34 | referenceParameters = new ArrayList<ReferenceParameter>();
|
---|
| 35 | }
|
---|
| 36 | return referenceParameters;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | public void setReferenceParameters(List<ReferenceParameter> referenceParameters)
|
---|
| 40 | {
|
---|
| 41 | this.referenceParameters = referenceParameters;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | public void addReferenceParameter(ReferenceParameter refParam) throws SubscriptionRepositoryException
|
---|
| 45 | {
|
---|
| 46 | if (refParam == null)
|
---|
| 47 | {
|
---|
| 48 | throw new SubscriptionRepositoryException("Attempted to add null reference parameter");
|
---|
| 49 | }
|
---|
| 50 | getReferenceParameters().add(refParam);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | public void removeReferenceParameter(ReferenceParameter refParam)
|
---|
| 54 | {
|
---|
| 55 | if (refParam != null)
|
---|
| 56 | {
|
---|
| 57 | Iterator<ReferenceParameter> iter = getReferenceParameters().iterator();
|
---|
| 58 | while (iter.hasNext())
|
---|
| 59 | {
|
---|
| 60 | ReferenceParameter rp = iter.next();
|
---|
| 61 | if (refParam.equals(rp))
|
---|
| 62 | {
|
---|
| 63 | iter.remove();
|
---|
| 64 | break;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | @Override
|
---|
| 71 | public boolean equals(Object obj)
|
---|
| 72 | {
|
---|
| 73 | if (obj == null)
|
---|
| 74 | {
|
---|
| 75 | return false;
|
---|
| 76 | }
|
---|
| 77 | if (getClass() != obj.getClass())
|
---|
| 78 | {
|
---|
| 79 | return false;
|
---|
| 80 | }
|
---|
| 81 | final SubscriptionReference other = (SubscriptionReference) obj;
|
---|
| 82 | if (this.subscriptionManagerEndpointAddress != other.subscriptionManagerEndpointAddress && (this.subscriptionManagerEndpointAddress == null || !this.subscriptionManagerEndpointAddress.equals(other.subscriptionManagerEndpointAddress)))
|
---|
| 83 | {
|
---|
| 84 | System.out.println("Subscription manager endpoint address did not equal");
|
---|
| 85 | System.out.println("This subscription manager endpoint address: " + this.subscriptionManagerEndpointAddress);
|
---|
| 86 | System.out.println("Other subscription manager endpoint address: " + other.subscriptionManagerEndpointAddress);
|
---|
| 87 | return false;
|
---|
| 88 | }
|
---|
| 89 | if (this.referenceParameters != other.referenceParameters && (this.referenceParameters == null || !this.referenceParameters.equals(other.referenceParameters)))
|
---|
| 90 | {
|
---|
| 91 | System.out.println("Reference parameters did not equal");
|
---|
| 92 | return false;
|
---|
| 93 | }
|
---|
| 94 | return true;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | @Override
|
---|
| 98 | public int hashCode()
|
---|
| 99 | {
|
---|
| 100 | int hash = 7;
|
---|
| 101 | hash = 97 * hash + (this.subscriptionManagerEndpointAddress != null ? this.subscriptionManagerEndpointAddress.hashCode() : 0);
|
---|
| 102 | hash = 97 * hash + (this.referenceParameters != null ? this.referenceParameters.hashCode() : 0);
|
---|
| 103 | return hash;
|
---|
| 104 | }
|
---|
| 105 | }
|
---|