01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.server.queue;
22
23 import org.apache.qpid.server.exchange.Exchange;
24 import org.apache.qpid.framing.AMQShortString;
25 import org.apache.qpid.framing.FieldTable;
26 import org.apache.qpid.AMQException;
27
28 public class ExchangeBinding
29 {
30 private final Exchange _exchange;
31 private final AMQShortString _routingKey;
32 private final FieldTable _arguments;
33
34 private static final FieldTable EMPTY_ARGUMENTS = new FieldTable();
35
36 ExchangeBinding(AMQShortString routingKey, Exchange exchange)
37 {
38 this(routingKey, exchange, EMPTY_ARGUMENTS);
39 }
40
41 ExchangeBinding(AMQShortString routingKey, Exchange exchange, FieldTable arguments)
42 {
43 _routingKey = routingKey == null ? AMQShortString.EMPTY_STRING : routingKey;
44 _exchange = exchange;
45 _arguments = arguments == null ? EMPTY_ARGUMENTS : arguments;
46 }
47
48 void unbind(AMQQueue queue) throws AMQException
49 {
50 _exchange.deregisterQueue(_routingKey, queue, _arguments);
51 }
52
53 public Exchange getExchange()
54 {
55 return _exchange;
56 }
57
58 public AMQShortString getRoutingKey()
59 {
60 return _routingKey;
61 }
62
63 public FieldTable getArguments()
64 {
65 return _arguments;
66 }
67
68 public int hashCode()
69 {
70 return (_exchange == null ? 0 : _exchange.hashCode())
71 + (_routingKey == null ? 0 : _routingKey.hashCode());
72 }
73
74 public boolean equals(Object o)
75 {
76 if (!(o instanceof ExchangeBinding))
77 {
78 return false;
79 }
80 ExchangeBinding eb = (ExchangeBinding) o;
81 return _exchange.equals(eb._exchange)
82 && _routingKey.equals(eb._routingKey);
83 }
84 }
|