From f39bdbe210524a1bd127a4534d2feffc2ac61467 Mon Sep 17 00:00:00 2001 From: Richard Downer Date: Mon, 5 Dec 2011 19:57:54 +0200 Subject: [PATCH] Add a Builder class for Alert --- .../org/jclouds/cloudstack/domain/Alert.java | 37 ++++++++++++++++++- .../parse/ListAlertsResponseTest.java | 3 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java index e7a45edf0c..03dad72f86 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Alert.java @@ -27,6 +27,41 @@ import java.util.Date; */ public class Alert implements Comparable { + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private long id; + private String description; + private Date sent; + private String type; + + public Builder id(long id) { + this.id = id; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder sent(Date sent) { + this.sent = sent; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public Alert build() { + return new Alert(id, description, sent, type); + } + } + private long id; private String description; private Date sent; @@ -36,7 +71,7 @@ public class Alert implements Comparable { Alert() { } - public Alert(long id, String description, Date sent, String type) { + private Alert(long id, String description, Date sent, String type) { this.id = id; this.description = description; this.sent = sent; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAlertsResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAlertsResponseTest.java index 1ebb150308..ab6963133b 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAlertsResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAlertsResponseTest.java @@ -74,7 +74,8 @@ public class ListAlertsResponseTest extends BaseSetParserTest { c.set(Calendar.HOUR_OF_DAY, 12); c.set(Calendar.MINUTE, 5); c.set(Calendar.SECOND, 2); - return ImmutableSet.of(new Alert(20, "Failed to deploy Vm with Id: 52", c.getTime(), "7")); + return ImmutableSet.of(Alert.builder() + .id(20).description("Failed to deploy Vm with Id: 52").sent(c.getTime()).type("7").build()); } }