blob: 420efe91cc1c226a4367c4f2408f21804b49b373 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus.routing;
/**
* This class represents a route directive within a {@link Hop}'s selector. This will be replaced by the named route
* when evaluated. If the route is not present in the running protocol's routing table, routing will fail.
*
* @author Simon Thoresen Hult
*/
public class RouteDirective implements HopDirective {
private final String name;
/**
* Constructs a new directive to insert a route.
*
* @param name The name of the route to insert.
*/
public RouteDirective(String name) {
this.name = name;
}
@Override
public boolean matches(HopDirective dir) {
return dir instanceof RouteDirective && name.equals(((RouteDirective)dir).name);
}
/**
* Returns the name of the route to insert.
*
* @return The route name.
*/
public String getName() {
return name;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof RouteDirective)) {
return false;
}
RouteDirective rhs = (RouteDirective)obj;
if (!name.equals(rhs.name)) {
return false;
}
return true;
}
@Override
public String toString() {
return "route:" + name;
}
@Override
public String toDebugString() {
return "RouteDirective(name = '" + name + "')";
}
@Override
public int hashCode() {
return name != null ? name.hashCode() : 0;
}
}
|