mirror of https://github.com/reiseburo/beetle
Add brokerId to the Broker pojo
This commit is contained in:
parent
a42c0fa3dd
commit
0819fc3857
|
@ -0,0 +1,24 @@
|
|||
*Copyright (c) 2015 R. Tyler Croy, Lookout, Inc*
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -5,6 +5,8 @@ package com.github.reiseburo.beetle;
|
|||
*/
|
||||
public class Broker {
|
||||
private String host;
|
||||
|
||||
private String brokerId;
|
||||
private int port;
|
||||
private int jmxPort;
|
||||
|
||||
|
@ -20,10 +22,15 @@ public class Broker {
|
|||
return jmxPort;
|
||||
}
|
||||
|
||||
public String getBrokerId() {
|
||||
return brokerId;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int port;
|
||||
private int jmxPort;
|
||||
private String host;
|
||||
private String brokerId;
|
||||
|
||||
public Builder withHost(String hostName) {
|
||||
this.host = hostName;
|
||||
|
@ -40,6 +47,11 @@ public class Broker {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder withBrokerId(String id) {
|
||||
this.brokerId = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Broker build() {
|
||||
return new Broker(this);
|
||||
}
|
||||
|
@ -50,8 +62,14 @@ public class Broker {
|
|||
}
|
||||
|
||||
private Broker(Builder builder) {
|
||||
this.brokerId = builder.brokerId;
|
||||
this.host = builder.host;
|
||||
this.port = builder.port;
|
||||
this.jmxPort = builder.jmxPort;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return String.format("<Broker:%d (%s %s:%d [jmx:%d])>",
|
||||
hashCode(), brokerId, host, port, jmxPort);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,4 +48,16 @@ class BrokerBuilderSpec extends Specification {
|
|||
then:
|
||||
broker.jmxPort == port
|
||||
}
|
||||
|
||||
def "withBrokerId()"() {
|
||||
given:
|
||||
final String brokerId = 'roflcopter'
|
||||
Broker broker
|
||||
|
||||
when:
|
||||
broker = Broker.builder().withBrokerId(brokerId).build()
|
||||
|
||||
then:
|
||||
broker.brokerId == brokerId
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue