diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..02ddd1f --- /dev/null +++ b/LICENSE.md @@ -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. diff --git a/src/main/java/com/github/reiseburo/beetle/Broker.java b/src/main/java/com/github/reiseburo/beetle/Broker.java index 9516082..3ed975b 100644 --- a/src/main/java/com/github/reiseburo/beetle/Broker.java +++ b/src/main/java/com/github/reiseburo/beetle/Broker.java @@ -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("", + hashCode(), brokerId, host, port, jmxPort); + } } diff --git a/src/test/groovy/com/github/reiseburo/beetle/BrokerSpec.groovy b/src/test/groovy/com/github/reiseburo/beetle/BrokerSpec.groovy index 0f7e17c..a87200f 100644 --- a/src/test/groovy/com/github/reiseburo/beetle/BrokerSpec.groovy +++ b/src/test/groovy/com/github/reiseburo/beetle/BrokerSpec.groovy @@ -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 + } }