1 /*
2 * Copyright 2005-2010 the original author or authors.
3 *
4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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
17 package org.springframework.ws.soap.addressing.core;
18
19 import java.io.Serializable;
20 import java.net.URI;
21 import java.util.Collections;
22 import java.util.List;
23
24 import org.springframework.util.Assert;
25
26 import org.w3c.dom.Node;
27
28 /**
29 * Represents an Endpoint Reference, as defined in the WS-Addressing specification.
30 *
31 * @author Arjen Poutsma
32 * @see <a href="http://www.w3.org/TR/ws-addr-core/#eprs">Endpoint References</a>
33 * @since 1.5.0
34 */
35 public final class EndpointReference implements Serializable {
36
37 private static final long serialVersionUID = 8999416009328865260L;
38
39 private final URI address;
40
41 private final List<Node> referenceProperties;
42
43 private final List<Node> referenceParameters;
44
45 /**
46 * Creates a new instance of the {@link EndpointReference} class with the given address. The reference parameters
47 * and properties are empty.
48 *
49 * @param address the endpoint address
50 */
51 public EndpointReference(URI address) {
52 Assert.notNull(address, "address must not be null");
53 this.address = address;
54 this.referenceParameters = Collections.emptyList();
55 this.referenceProperties = Collections.emptyList();
56 }
57
58 /**
59 * Creates a new instance of the {@link EndpointReference} class with the given address, reference properties, and
60 * reference parameters.
61 *
62 * @param address the endpoint address
63 * @param referenceProperties the reference properties, as a list of {@link Node}
64 * @param referenceParameters the reference parameters, as a list of {@link Node}
65 */
66 public EndpointReference(URI address, List<Node> referenceProperties, List<Node> referenceParameters) {
67 Assert.notNull(address, "address must not be null");
68 Assert.notNull(referenceProperties, "referenceProperties must not be null");
69 Assert.notNull(referenceParameters, "referenceParameters must not be null");
70 this.address = address;
71 this.referenceProperties = referenceProperties;
72 this.referenceParameters = referenceParameters;
73 }
74
75 /** Returns the address of the endpoint. */
76 public URI getAddress() {
77 return address;
78 }
79
80 /** Returns the reference properties of the endpoint, as a list of {@link Node} objects. */
81 public List<Node> getReferenceProperties() {
82 return referenceProperties;
83 }
84
85 /** Returns the reference parameters of the endpoint, as a list of {@link Node} objects. */
86 public List<Node> getReferenceParameters() {
87 return referenceParameters;
88 }
89
90 public boolean equals(Object o) {
91 if (this == o) {
92 return true;
93 }
94 if (o != null && o instanceof EndpointReference) {
95 EndpointReference other = (EndpointReference) o;
96 return address.equals(other.address);
97 }
98 return false;
99 }
100
101 public int hashCode() {
102 return address.hashCode();
103 }
104
105 public String toString() {
106 return address.toString();
107 }
108 }