http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java index 9f05f52..916786c 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/SensorApi.java @@ -46,113 +46,105 @@ import com.wordnik.swagger.core.ApiParam; @Consumes(MediaType.APPLICATION_JSON) public interface SensorApi { - @GET - @ApiOperation(value = "Fetch the sensor list for a specific application entity", - responseClass = "brooklyn.rest.domain.SensorSummary", - multiValueResponse = true) - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - public List<SensorSummary> list( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken - ) ; + @GET + @ApiOperation(value = "Fetch the sensor list for a specific application entity", + responseClass = "brooklyn.rest.domain.SensorSummary", + multiValueResponse = true) + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + public List<SensorSummary> list( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken); - @GET - @Path("/current-state") - @ApiOperation(value = "Fetch sensor values in batch", notes="Returns a map of sensor name to value") - public Map<String, Object> batchSensorRead( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Return raw sensor data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw - ) ; + @GET + @Path("/current-state") + @ApiOperation(value = "Fetch sensor values in batch", notes="Returns a map of sensor name to value") + public Map<String, Object> batchSensorRead( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Return raw sensor data instead of display values", required = false) + @QueryParam("raw") @DefaultValue("false") final Boolean raw); - @GET - @Path("/{sensor}") - @ApiOperation(value = "Fetch sensor value (json)", responseClass = "Object") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - public Object get( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Sensor name", required = true) - @PathParam("sensor") String sensorName, - @ApiParam(value = "Return raw sensor data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw - ) ; + @GET + @Path("/{sensor}") + @ApiOperation(value = "Fetch sensor value (json)", responseClass = "Object") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or sensor") + }) + public Object get( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Sensor name", required = true) + @PathParam("sensor") String sensorName, + @ApiParam(value = "Return raw sensor data instead of display values", required = false) + @QueryParam("raw") @DefaultValue("false") final Boolean raw); - // this method is used if user has requested plain (ie not converting to json) - @GET - @Path("/{sensor}") - @ApiOperation(value = "Fetch sensor value (text/plain)", responseClass = "String") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - @Produces(MediaType.TEXT_PLAIN) - public String getPlain( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Sensor name", required = true) - @PathParam("sensor") String sensorName, - @ApiParam(value = "Return raw sensor data instead of display values", required = false) - @QueryParam("raw") @DefaultValue("false") final Boolean raw - ) ; + // this method is used if user has requested plain (ie not converting to json) + @GET + @Path("/{sensor}") + @ApiOperation(value = "Fetch sensor value (text/plain)", responseClass = "String") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or sensor") + }) + @Produces(MediaType.TEXT_PLAIN) + public String getPlain( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Sensor name", required = true) + @PathParam("sensor") String sensorName, + @ApiParam(value = "Return raw sensor data instead of display values", required = false) + @QueryParam("raw") @DefaultValue("false") final Boolean raw); - @POST - @ApiOperation(value = "Manually set multiple sensor values") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application or entity") - }) - @SuppressWarnings("rawtypes") - public void setFromMap( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Map of sensor names to values", required = true) - Map newValues - ) ; + @POST + @ApiOperation(value = "Manually set multiple sensor values") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application or entity") + }) + @SuppressWarnings("rawtypes") + public void setFromMap( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Map of sensor names to values", required = true) + Map newValues); - @POST - @Path("/{sensor}") - @ApiOperation(value = "Manually set a sensor value") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - public void set( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Sensor name", required = true) - @PathParam("sensor") String sensorName, - @ApiParam(value = "Value to set") - Object newValue - ) ; - - @DELETE - @Path("/{sensor}") - @ApiOperation(value = "Manually clear a sensor value") - @ApiErrors(value = { - @ApiError(code = 404, reason = "Could not find application, entity or sensor") - }) - public void delete( - @ApiParam(value = "Application ID or name", required = true) - @PathParam("application") final String application, - @ApiParam(value = "Entity ID or name", required = true) - @PathParam("entity") final String entityToken, - @ApiParam(value = "Sensor name", required = true) - @PathParam("sensor") String sensorName - ) ; + @POST + @Path("/{sensor}") + @ApiOperation(value = "Manually set a sensor value") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or sensor") + }) + public void set( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Sensor name", required = true) + @PathParam("sensor") String sensorName, + @ApiParam(value = "Value to set") + Object newValue); + @DELETE + @Path("/{sensor}") + @ApiOperation(value = "Manually clear a sensor value") + @ApiErrors(value = { + @ApiError(code = 404, reason = "Could not find application, entity or sensor") + }) + public void delete( + @ApiParam(value = "Application ID or name", required = true) + @PathParam("application") final String application, + @ApiParam(value = "Entity ID or name", required = true) + @PathParam("entity") final String entityToken, + @ApiParam(value = "Sensor name", required = true) + @PathParam("sensor") String sensorName); }
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java index 246e31a..add51c4 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java @@ -61,18 +61,18 @@ public interface ServerApi { @ApiOperation(value = "Terminate this Brooklyn server instance") @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) public void shutdown( - @ApiParam(name = "stopAppsFirst", value = "Whether to stop running applications before shutting down") - @FormParam("stopAppsFirst") @DefaultValue("false") boolean stopAppsFirst, - @ApiParam(name = "forceShutdownOnError", value ="Force shutdown if apps fail to stop or timeout") - @FormParam("forceShutdownOnError") @DefaultValue("false") boolean forceShutdownOnError, - @ApiParam(name = "shutdownTimeout", value = "A maximum delay to wait for apps to gracefully stop before giving up or forcibly exiting, 0 to wait infinitely") - @FormParam("shutdownTimeout") @DefaultValue("20s") String shutdownTimeout, - @ApiParam(name = "requestTimeout", value = "Maximum time to block the request for the shutdown to finish, 0 to wait infinitely") - @FormParam("requestTimeout") @DefaultValue("20s") String requestTimeout, - @ApiParam(name = "delayForHttpReturn", value = "The delay before exiting the process, to permit the REST response to be returned") - @FormParam("delayForHttpReturn") @DefaultValue("5s") String delayForHttpReturn, - @ApiParam(name = "delayMillis", value = "Deprecated, analogous to delayForHttpReturn") - @FormParam("delayMillis") Long delayMillis); + @ApiParam(name = "stopAppsFirst", value = "Whether to stop running applications before shutting down") + @FormParam("stopAppsFirst") @DefaultValue("false") boolean stopAppsFirst, + @ApiParam(name = "forceShutdownOnError", value ="Force shutdown if apps fail to stop or timeout") + @FormParam("forceShutdownOnError") @DefaultValue("false") boolean forceShutdownOnError, + @ApiParam(name = "shutdownTimeout", value = "A maximum delay to wait for apps to gracefully stop before giving up or forcibly exiting, 0 to wait infinitely") + @FormParam("shutdownTimeout") @DefaultValue("20s") String shutdownTimeout, + @ApiParam(name = "requestTimeout", value = "Maximum time to block the request for the shutdown to finish, 0 to wait infinitely") + @FormParam("requestTimeout") @DefaultValue("20s") String requestTimeout, + @ApiParam(name = "delayForHttpReturn", value = "The delay before exiting the process, to permit the REST response to be returned") + @FormParam("delayForHttpReturn") @DefaultValue("5s") String delayForHttpReturn, + @ApiParam(name = "delayMillis", value = "Deprecated, analogous to delayForHttpReturn") + @FormParam("delayMillis") Long delayMillis); @GET @Path("/version") @@ -83,15 +83,15 @@ public interface ServerApi { @GET @Path("/status") @ApiOperation(value = "Returns the status of this Brooklyn instance [DEPRECATED; see ../ha/state]", - responseClass = "String", - multiValueResponse = false) + responseClass = "String", + multiValueResponse = false) public String getStatus(); @Deprecated /** @deprecated since 0.7.0 use /ha/states */ @GET @Path("/highAvailability") @ApiOperation(value = "Returns the status of all Brooklyn instances in the management plane [DEPRECATED; see ../ha/states]", - responseClass = "brooklyn.rest.domain.HighAvailabilitySummary") + responseClass = "brooklyn.rest.domain.HighAvailabilitySummary") public HighAvailabilitySummary getHighAvailability(); @GET @@ -114,7 +114,7 @@ public interface ServerApi { @GET @Path("/ha/states") @ApiOperation(value = "Returns the HA states and detail for all nodes in this management plane", - responseClass = "brooklyn.rest.domain.HighAvailabilitySummary") + responseClass = "brooklyn.rest.domain.HighAvailabilitySummary") public HighAvailabilitySummary getHighAvailabilityPlaneStates(); @GET @@ -135,7 +135,7 @@ public interface ServerApi { @ApiOperation(value = "Retrieves the persistence store data, as an archive") public Response exportPersistenceData( @ApiParam(name = "origin", value = "Whether to take from LOCAL or REMOTE state; default to AUTO detect, " - + "using LOCAL as master and REMOTE for other notes") + + "using LOCAL as master and REMOTE for other notes") @QueryParam("origin") @DefaultValue("AUTO") String origin); // TODO would be nice to allow setting, as a means to recover / control more easily than messing with persistent stores @@ -156,7 +156,8 @@ public interface ServerApi { @GET @Path("/user") - @ApiOperation(value = "Return user information for this Brooklyn instance", responseClass = "String", multiValueResponse = false) + @ApiOperation(value = "Return user information for this Brooklyn instance", + responseClass = "String", multiValueResponse = false) public String getUser(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java index bee083b..905e0fc 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/api/VersionApi.java @@ -36,7 +36,7 @@ import javax.ws.rs.core.MediaType; public interface VersionApi { @GET - @ApiOperation(value = "Return version identifier information for this Brooklyn instance; deprecated, use /server/version", responseClass = "String", multiValueResponse = false) - public String getVersion() ; - + @ApiOperation(value = "Return version identifier information for this Brooklyn instance; deprecated, use /server/version", + responseClass = "String", multiValueResponse = false) + public String getVersion(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java index 2675880..f85468f 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/ApplicationSpec.java @@ -34,142 +34,145 @@ import com.google.common.collect.ImmutableSet; public class ApplicationSpec implements HasName { - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String name; - private String type; - private Set<EntitySpec> entities; - private Set<String> locations; - private Map<String,String> config; - - public Builder from(ApplicationSpec spec) { - this.name = spec.name; - this.entities = spec.entities; - this.locations = spec.locations; - return this; + public static Builder builder() { + return new Builder(); } - public Builder name(String name) { - this.name = name; - return this; + public static class Builder { + private String name; + private String type; + private Set<EntitySpec> entities; + private Set<String> locations; + private Map<String, String> config; + + public Builder from(ApplicationSpec spec) { + this.name = spec.name; + this.entities = spec.entities; + this.locations = spec.locations; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public Builder entities(Set<EntitySpec> entities) { + this.entities = entities; + return this; + } + + public Builder locations(Set<String> locations) { + this.locations = locations; + return this; + } + + public Builder config(Map<String, String> config) { + this.config = config; + return this; + } + + public ApplicationSpec build() { + return new ApplicationSpec(name, type, entities, locations, config); + } } - public Builder type(String type) { - this.type = type; - return this; - } + private final String name; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String type; + @JsonSerialize(include = Inclusion.NON_NULL) + private final Set<EntitySpec> entities; + private final Set<String> locations; + @JsonSerialize(include = Inclusion.NON_EMPTY) + private final Map<String, String> config; - public Builder entities(Set<EntitySpec> entities) { - this.entities = entities; - return this; + public ApplicationSpec( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("entities") Set<EntitySpec> entities, + @JsonProperty("locations") Collection<String> locations, + @JsonProperty("config") Map<String, String> config) { + this.name = name; + this.type = type; + if (entities==null) { + this.entities = null; + } else { + this.entities = (entities.isEmpty() && type!=null) ? null : ImmutableSet.copyOf(entities); } + this.locations = ImmutableSet.copyOf(checkNotNull(locations, "locations must be provided for an application spec")); + this.config = config == null ? Collections.<String, String>emptyMap() : ImmutableMap.<String, String>copyOf(config); + if (this.entities!=null && this.type!=null) throw new IllegalStateException("cannot supply both type and entities for an application spec"); + // valid for both to be null, e.g. for an anonymous type +// if (this.entities==null && this.type==null) throw new IllegalStateException("must supply either type or entities for an application spec"); + } - public Builder locations(Set<String> locations) { - this.locations = locations; - return this; + @Override + public String getName() { + return name; } - public Builder config(Map<String,String> config) { - this.config = config; - return this; + public String getType() { + return type; } - public ApplicationSpec build() { - return new ApplicationSpec(name, type, entities, locations, config); + public Set<EntitySpec> getEntities() { + return entities; } - } - - private final String name; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String type; - @JsonSerialize(include=Inclusion.NON_NULL) - private final Set<EntitySpec> entities; - private final Set<String> locations; - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final Map<String, String> config; - - public ApplicationSpec( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("entities") Set<EntitySpec> entities, - @JsonProperty("locations") Collection<String> locations, - @JsonProperty("config") Map<String, String> config - ) { - this.name = name; - this.type = type; - if (entities==null) this.entities = null; - else this.entities = (entities.isEmpty() && type!=null) ? null : ImmutableSet.copyOf(entities); - this.locations = ImmutableSet.copyOf(checkNotNull(locations, "locations must be provided for an application spec")); - this.config = config == null ? Collections.<String, String>emptyMap() : ImmutableMap.<String, String>copyOf(config); - if (this.entities!=null && this.type!=null) throw new IllegalStateException("cannot supply both type and entities for an application spec"); - // valid for both to be null, e.g. for an anonymous type -// if (this.entities==null && this.type==null) throw new IllegalStateException("must supply either type or entities for an application spec"); - } - @Override - public String getName() { - return name; - } - - public String getType() { - return type; -} - - public Set<EntitySpec> getEntities() { - return entities; - } + public Set<String> getLocations() { + return locations; + } - public Set<String> getLocations() { - return locations; - } + public Map<String, String> getConfig() { + return config; + } - public Map<String, String> getConfig() { - return config; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ApplicationSpec that = (ApplicationSpec) o; - - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (type != null ? !type.equals(that.type) : that.type != null) - return false; - if (entities != null ? !entities.equals(that.entities) : that.entities != null) - return false; - if (locations != null ? !locations.equals(that.locations) : that.locations != null) - return false; - if (config != null ? !config.equals(that.config) : that.config != null) - return false; - - return true; - } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + ApplicationSpec that = (ApplicationSpec) o; + + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + if (type != null ? !type.equals(that.type) : that.type != null) + return false; + if (entities != null ? !entities.equals(that.entities) : that.entities != null) + return false; + if (locations != null ? !locations.equals(that.locations) : that.locations != null) + return false; + if (config != null ? !config.equals(that.config) : that.config != null) + return false; + + return true; + } - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (entities != null ? entities.hashCode() : 0); - result = 31 * result + (locations != null ? locations.hashCode() : 0); - result = 31 * result + (config != null ? config.hashCode() : 0); - return result; - } + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (entities != null ? entities.hashCode() : 0); + result = 31 * result + (locations != null ? locations.hashCode() : 0); + result = 31 * result + (config != null ? config.hashCode() : 0); + return result; + } - @Override - public String toString() { - return "ApplicationSpec{" + - "name='" + name + '\'' + - ", type=" + type + - ", entitySpecs=" + entities + - ", locations=" + locations + - ", config=" + config + - '}'; + @Override + public String toString() { + return "ApplicationSpec{" + + "name='" + name + '\'' + + ", type=" + type + + ", entitySpecs=" + entities + + ", locations=" + locations + + ", config=" + config + + '}'; } - } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java index c523b7d..2c02c70 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/ConfigSummary.java @@ -38,135 +38,132 @@ import com.google.common.collect.ImmutableMap; public abstract class ConfigSummary implements HasName { - private final String name; - private final String type; - @JsonSerialize(include=Inclusion.NON_NULL) - private final Object defaultValue; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String description; - @JsonSerialize - private final boolean reconfigurable; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String label; - @JsonSerialize(include=Inclusion.NON_NULL) - private final Double priority; - @JsonSerialize(include=Inclusion.NON_NULL) - private final List<Map<String, String>> possibleValues; - - protected ConfigSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") Object defaultValue, - @JsonProperty("reconfigurable") boolean reconfigurable, - @JsonProperty("label") String label, - @JsonProperty("priority") Double priority, - @JsonProperty("possibleValues") List<Map<String, String>> possibleValues - ) { - this.name = name; - this.type = type; - this.description = description; - this.defaultValue = defaultValue; - this.reconfigurable = reconfigurable; - this.label = label; - this.priority = priority; - this.possibleValues = possibleValues; - } - - protected ConfigSummary(ConfigKey<?> config) { - this(config, null, null); - } - - @SuppressWarnings("rawtypes") - protected ConfigSummary(ConfigKey<?> config, String label, Double priority) { - this.name = config.getName(); - this.description = config.getDescription(); - this.reconfigurable = config.isReconfigurable(); - - /* Use String, to guarantee it is serializable; otherwise get: - * No serializer found for class brooklyn.policy.autoscaling.AutoScalerPolicy$3 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[9]->brooklyn.rest.domain.PolicyConfigSummary["defaultValue"]) - * at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52) - */ - this.label = label; - this.priority = priority; - if (config.getType().isEnum()) { - this.type = Enum.class.getName(); - this.defaultValue = (config.getDefaultValue() == null) ? null : ((Enum)config.getDefaultValue()).name(); - this.possibleValues = FluentIterable - .from(Arrays.asList((Enum[])(config.getType().getEnumConstants()))) - .transform(new Function<Enum, Map<String, String>>() { - @Nullable - @Override - public Map<String, String> apply(@Nullable Enum input) { - return ImmutableMap.of( - "value", input != null ? input.name() : null, - "description", input != null ? input.toString() : null - ); - } - }) - .toList(); - } else { - this.type = config.getTypeName(); - this.defaultValue = Jsonya.convertToJsonPrimitive(config.getDefaultValue()); - this.possibleValues = null; + private final String name; + private final String type; + @JsonSerialize(include = Inclusion.NON_NULL) + private final Object defaultValue; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String description; + @JsonSerialize + private final boolean reconfigurable; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String label; + @JsonSerialize(include = Inclusion.NON_NULL) + private final Double priority; + @JsonSerialize(include = Inclusion.NON_NULL) + private final List<Map<String, String>> possibleValues; + + protected ConfigSummary( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("description") String description, + @JsonProperty("defaultValue") Object defaultValue, + @JsonProperty("reconfigurable") boolean reconfigurable, + @JsonProperty("label") String label, + @JsonProperty("priority") Double priority, + @JsonProperty("possibleValues") List<Map<String, String>> possibleValues) { + this.name = name; + this.type = type; + this.description = description; + this.defaultValue = defaultValue; + this.reconfigurable = reconfigurable; + this.label = label; + this.priority = priority; + this.possibleValues = possibleValues; } - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDescription() { - return description; - } - - public boolean isReconfigurable() { - return reconfigurable; - } - - public Object getDefaultValue() { - // note constructor has converted to string, so this is safe for clients to use - return defaultValue; - } - - public String getLabel() { - return label; - } - - public Double getPriority() { - return priority; - } - - public List<Map<String, String>> getPossibleValues() { - return possibleValues; - } - - public abstract Map<String, URI> getLinks(); - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ConfigSummary that = (ConfigSummary) o; - - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - return result; - } - - @Override - public abstract String toString(); + + protected ConfigSummary(ConfigKey<?> config) { + this(config, null, null); + } + + @SuppressWarnings("rawtypes") + protected ConfigSummary(ConfigKey<?> config, String label, Double priority) { + this.name = config.getName(); + this.description = config.getDescription(); + this.reconfigurable = config.isReconfigurable(); + + /* Use String, to guarantee it is serializable; otherwise get: + * No serializer found for class brooklyn.policy.autoscaling.AutoScalerPolicy$3 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[9]->brooklyn.rest.domain.PolicyConfigSummary["defaultValue"]) + * at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52) + */ + this.label = label; + this.priority = priority; + if (config.getType().isEnum()) { + this.type = Enum.class.getName(); + this.defaultValue = (config.getDefaultValue() == null) ? null : ((Enum) config.getDefaultValue()).name(); + this.possibleValues = FluentIterable + .from(Arrays.asList((Enum[])(config.getType().getEnumConstants()))) + .transform(new Function<Enum, Map<String, String>>() { + @Nullable + @Override + public Map<String, String> apply(@Nullable Enum input) { + return ImmutableMap.of( + "value", input != null ? input.name() : null, + "description", input != null ? input.toString() : null); + }}) + .toList(); + } else { + this.type = config.getTypeName(); + this.defaultValue = Jsonya.convertToJsonPrimitive(config.getDefaultValue()); + this.possibleValues = null; + } + } + + @Override + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public String getDescription() { + return description; + } + + public boolean isReconfigurable() { + return reconfigurable; + } + + public Object getDefaultValue() { + // note constructor has converted to string, so this is safe for clients to use + return defaultValue; + } + + public String getLabel() { + return label; + } + + public Double getPriority() { + return priority; + } + + public List<Map<String, String>> getPossibleValues() { + return possibleValues; + } + + public abstract Map<String, URI> getLinks(); + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ConfigSummary that = (ConfigSummary) o; + + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + return result; + } + + @Override + public abstract String toString(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java index 6adebd8..fcc1d39 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/EffectorSummary.java @@ -31,156 +31,152 @@ import com.google.common.collect.ImmutableMap; public class EffectorSummary implements HasName { - public static class ParameterSummary<T> implements HasName { + public static class ParameterSummary<T> implements HasName { + private final String name; + private final String type; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String description; + private final T defaultValue; + + public ParameterSummary ( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("description") String description, + @JsonProperty("defaultValue") T defaultValue) { + this.name = name; + this.type = type; + this.description = description; + this.defaultValue = defaultValue; + } + + @Override + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public String getDescription() { + return description; + } + + public T getDefaultValue() { + return defaultValue; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ParameterSummary<?> that = (ParameterSummary<?>) o; + + return Objects.equal(this.name, that.name) + && Objects.equal(this.type, that.type) + && Objects.equal(this.description, that.description) + && Objects.equal(this.defaultValue, that.defaultValue); + } + + @Override + public int hashCode() { + return Objects.hashCode(name, type, description, defaultValue); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .omitNullValues() + .add("name", name) + .add("type", type) + .add("description", description) + .add("defaultValue", defaultValue) + .toString(); + } + } + private final String name; - private final String type; - @JsonSerialize(include=Inclusion.NON_NULL) + private final String returnType; + private final Set<ParameterSummary<?>> parameters; + @JsonSerialize(include = Inclusion.NON_NULL) private final String description; - private final T defaultValue; - - public ParameterSummary ( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") T defaultValue - ) { - this.name = name; - this.type = type; - this.description = description; - this.defaultValue = defaultValue; + @JsonSerialize(include = Inclusion.NON_NULL) + private final Map<String, URI> links; + + public EffectorSummary( + @JsonProperty("name") String name, + @JsonProperty("returnType") String returnType, + @JsonProperty("parameters") Set<ParameterSummary<?>> parameters, + @JsonProperty("description") String description, + @JsonProperty("links") Map<String, URI> links) { + this.name = name; + this.description = description; + this.returnType = returnType; + this.parameters = parameters; + this.links = links != null ? ImmutableMap.copyOf(links) : null; } @Override public String getName() { - return name; + return name; } - public String getType() { - return type; + public String getDescription() { + return description; } - public String getDescription() { - return description; + public String getReturnType() { + return returnType; } - - public T getDefaultValue() { - return defaultValue; + + public Set<ParameterSummary<?>> getParameters() { + return parameters; + } + + public Map<String, URI> getLinks() { + return links; } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ParameterSummary<?> that = (ParameterSummary<?>) o; - - return Objects.equal(this.name, that.name) && - Objects.equal(this.type, that.type) && - Objects.equal(this.description, that.description) && - Objects.equal(this.defaultValue, that.defaultValue); - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + EffectorSummary that = (EffectorSummary) o; + + if (description != null ? !description.equals(that.description) : that.description != null) + return false; + if (links != null ? !links.equals(that.links) : that.links != null) + return false; + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null) + return false; + if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null) + return false; + + return true; } @Override public int hashCode() { - return Objects.hashCode(name, type, description, defaultValue); + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (returnType != null ? returnType.hashCode() : 0); + result = 31 * result + (parameters != null ? parameters.hashCode() : 0); + result = 31 * result + (links != null ? links.hashCode() : 0); + return result; } @Override public String toString() { - return Objects.toStringHelper(this) - .omitNullValues() - .add("name", name) - .add("type", type) - .add("description", description) - .add("defaultValue", defaultValue) - .toString(); + return "EffectorSummary{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", returnType='" + returnType + '\'' + + ", parameters=" + parameters + + ", links=" + links + + '}'; } - - } - - private final String name; - private final String returnType; - private final Set<ParameterSummary<?>> parameters; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String description; - @JsonSerialize(include=Inclusion.NON_NULL) - private final Map<String, URI> links; - - public EffectorSummary( - @JsonProperty("name") String name, - @JsonProperty("returnType") String returnType, - @JsonProperty("parameters") Set<ParameterSummary<?>> parameters, - @JsonProperty("description") String description, - @JsonProperty("links") Map<String, URI> links - ) { - this.name = name; - this.description = description; - this.returnType = returnType; - this.parameters = parameters; - this.links = links != null ? ImmutableMap.copyOf(links) : null; - } - - @Override - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public String getReturnType() { - return returnType; - } - - public Set<ParameterSummary<?>> getParameters() { - return parameters; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EffectorSummary that = (EffectorSummary) o; - - if (description != null ? !description.equals(that.description) : that.description != null) - return false; - if (links != null ? !links.equals(that.links) : that.links != null) - return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null) - return false; - if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (returnType != null ? returnType.hashCode() : 0); - result = 31 * result + (parameters != null ? parameters.hashCode() : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "EffectorSummary{" + - "name='" + name + '\'' + - ", description='" + description + '\'' + - ", returnType='" + returnType + '\'' + - ", parameters=" + parameters + - ", links=" + links + - '}'; - } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java index 4911d9a..367ff5d 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntityConfigSummary.java @@ -30,40 +30,38 @@ import java.util.Map; public class EntityConfigSummary extends ConfigSummary { - @JsonSerialize(include=Inclusion.NON_NULL) - private final Map<String, URI> links; + @JsonSerialize(include = Inclusion.NON_NULL) + private final Map<String, URI> links; - public EntityConfigSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") Object defaultValue, - @JsonProperty("reconfigurable") boolean reconfigurable, - @JsonProperty("label") String label, - @JsonProperty("priority") Double priority, - @JsonProperty("possibleValues") List<Map<String, String>> possibleValues, - @JsonProperty("links") Map<String, URI> links - ) { - super(name, type, description, defaultValue, reconfigurable, label, priority, possibleValues); - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } + public EntityConfigSummary( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("description") String description, + @JsonProperty("defaultValue") Object defaultValue, + @JsonProperty("reconfigurable") boolean reconfigurable, + @JsonProperty("label") String label, + @JsonProperty("priority") Double priority, + @JsonProperty("possibleValues") List<Map<String, String>> possibleValues, + @JsonProperty("links") Map<String, URI> links) { + super(name, type, description, defaultValue, reconfigurable, label, priority, possibleValues); + this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); + } - public EntityConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) { - super(config, label, priority); - this.links = links!=null ? ImmutableMap.copyOf(links) : null; - } + public EntityConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) { + super(config, label, priority); + this.links = links != null ? ImmutableMap.copyOf(links) : null; + } - @Override - public Map<String, URI> getLinks() { - return links; - } - - @Override - public String toString() { - return "EntityConfigSummary{" + - "name='" + getName() + '\'' + - ", type='" + getType() + '\'' + - '}'; - } + @Override + public Map<String, URI> getLinks() { + return links; + } + @Override + public String toString() { + return "EntityConfigSummary{" + + "name='" + getName() + '\'' + + ", type='" + getType() + '\'' + + '}'; + } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java index 9264329..f90d896 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySpec.java @@ -27,72 +27,71 @@ import java.util.Map; public class EntitySpec implements HasName { - private final String name; - private final String type; - private final Map<String, String> config; - - public EntitySpec(String type) { - this(null, type); - } - - public EntitySpec(String name, String type) { - this(name, type, Collections.<String, String>emptyMap()); - } - - public EntitySpec( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("config") Map<String, String> config - ) { - this.type = checkNotNull(type, "type"); - this.name = (name == null) ? type : name; - this.config = (config != null) ? ImmutableMap.copyOf(config) : ImmutableMap.<String, String>of(); - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public Map<String, String> getConfig() { - return config; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - EntitySpec entitySpec = (EntitySpec) o; - - if (config != null ? !config.equals(entitySpec.config) : entitySpec.config != null) - return false; - if (name != null ? !name.equals(entitySpec.name) : entitySpec.name != null) - return false; - if (type != null ? !type.equals(entitySpec.type) : entitySpec.type != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (config != null ? config.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "EntitySpec{" + - "name='" + name + '\'' + - ", type='" + type + '\'' + - ", config=" + config + - '}'; - } + private final String name; + private final String type; + private final Map<String, String> config; + + public EntitySpec(String type) { + this(null, type); + } + + public EntitySpec(String name, String type) { + this(name, type, Collections.<String, String> emptyMap()); + } + + public EntitySpec( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("config") Map<String, String> config) { + this.type = checkNotNull(type, "type"); + this.name = (name == null) ? type : name; + this.config = (config != null) ? ImmutableMap.copyOf(config) : ImmutableMap.<String, String> of(); + } + + @Override + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public Map<String, String> getConfig() { + return config; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + EntitySpec entitySpec = (EntitySpec) o; + + if (config != null ? !config.equals(entitySpec.config) : entitySpec.config != null) + return false; + if (name != null ? !name.equals(entitySpec.name) : entitySpec.name != null) + return false; + if (type != null ? !type.equals(entitySpec.type) : entitySpec.type != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (config != null ? config.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "EntitySpec{" + + "name='" + name + '\'' + + ", type='" + type + '\'' + + ", config=" + config + + '}'; + } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java index 3118986..e3e67d4 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java @@ -29,67 +29,66 @@ import java.util.Map; public class EntitySummary implements HasId, HasName { - private final String id; - private final String name; - private final String type; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String catalogItemId; - private final Map<String, URI> links; + private final String id; + private final String name; + private final String type; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String catalogItemId; + private final Map<String, URI> links; - public EntitySummary( - @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("catalogItemId") String catalogItemId, - @JsonProperty("links") Map<String, URI> links - ) { - this.type = type; - this.id = id; - this.name = name; - this.catalogItemId = catalogItemId; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } + public EntitySummary( + @JsonProperty("id") String id, + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("catalogItemId") String catalogItemId, + @JsonProperty("links") Map<String, URI> links) { + this.type = type; + this.id = id; + this.name = name; + this.catalogItemId = catalogItemId; + this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); + } - public String getType() { - return type; - } + public String getType() { + return type; + } - @Override - public String getId() { - return id; - } - - @Override - public String getName() { - return name; - } - - public String getCatalogItemId() { - return catalogItemId; -} - - public Map<String, URI> getLinks() { - return links; - } + @Override + public String getId() { + return id; + } - @Override - public boolean equals(Object o) { - return (o instanceof EntitySummary) && id.equals(((EntitySummary)o).getId()); - } + @Override + public String getName() { + return name; + } - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } + public String getCatalogItemId() { + return catalogItemId; + } + + public Map<String, URI> getLinks() { + return links; + } + + @Override + public boolean equals(Object o) { + return (o instanceof EntitySummary) && id.equals(((EntitySummary) o).getId()); + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } - @Override - public String toString() { - return "EntitySummary{" + - "id='" + id + '\'' + - ", name=" + name + - ", type=" + type + - ", catalogItemId=" + catalogItemId + - ", links=" + links + - '}'; + @Override + public String toString() { + return "EntitySummary{" + + "id='" + id + '\'' + + ", name=" + name + + ", type=" + type + + ", catalogItemId=" + catalogItemId + + ", links=" + links + + '}'; } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java index 33c6f3e..915f80e 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/HighAvailabilitySummary.java @@ -40,102 +40,100 @@ public class HighAvailabilitySummary { @JsonProperty("nodeUri") URI nodeUri, @JsonProperty("status") String status, @JsonProperty("localTimestamp") Long localTimestamp, - @JsonProperty("remoteTimestamp") Long remoteTimestamp - ) { - this.nodeId = nodeId; - this.nodeUri = nodeUri; - this.status = status; - this.localTimestamp = localTimestamp; - this.remoteTimestamp = remoteTimestamp; - } - - public String getNodeId() { - return nodeId; - } - - public URI getNodeUri() { - return nodeUri; - } - - public String getStatus() { - return status; - } - - public Long getLocalTimestamp() { - return localTimestamp; - } - - public Long getRemoteTimestamp() { - return remoteTimestamp; - } - - @Override - public boolean equals(Object o) { - return (o instanceof HaNodeSummary) && Objects.equal(nodeId, ((HaNodeSummary)o).getNodeId()); - } - - @Override - public int hashCode() { - return Objects.hashCode(nodeId); - } - - @Override - public String toString() { - return "HighAvailabilitySummary{" + - "nodeId='" + nodeId + '\'' + - ", status='" + status + '\'' + - '}'; - } + @JsonProperty("remoteTimestamp") Long remoteTimestamp) { + this.nodeId = nodeId; + this.nodeUri = nodeUri; + this.status = status; + this.localTimestamp = localTimestamp; + this.remoteTimestamp = remoteTimestamp; + } + + public String getNodeId() { + return nodeId; + } + + public URI getNodeUri() { + return nodeUri; + } + + public String getStatus() { + return status; + } + + public Long getLocalTimestamp() { + return localTimestamp; + } + + public Long getRemoteTimestamp() { + return remoteTimestamp; + } + + @Override + public boolean equals(Object o) { + return (o instanceof HaNodeSummary) && Objects.equal(nodeId, ((HaNodeSummary) o).getNodeId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(nodeId); + } + + @Override + public String toString() { + return "HighAvailabilitySummary{" + + "nodeId='" + nodeId + '\'' + + ", status='" + status + '\'' + + '}'; + } } - + private final String ownId; private final String masterId; private final Map<String, HaNodeSummary> nodes; private final Map<String, URI> links; public HighAvailabilitySummary( - @JsonProperty("ownId") String ownId, - @JsonProperty("masterId") String masterId, - @JsonProperty("nodes") Map<String, HaNodeSummary> nodes, - @JsonProperty("links") Map<String, URI> links - ) { - this.ownId = ownId; - this.masterId = masterId; - this.nodes = (nodes == null) ? ImmutableMap.<String, HaNodeSummary>of() : nodes; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); + @JsonProperty("ownId") String ownId, + @JsonProperty("masterId") String masterId, + @JsonProperty("nodes") Map<String, HaNodeSummary> nodes, + @JsonProperty("links") Map<String, URI> links) { + this.ownId = ownId; + this.masterId = masterId; + this.nodes = (nodes == null) ? ImmutableMap.<String, HaNodeSummary>of() : nodes; + this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); } public String getOwnId() { - return ownId; + return ownId; } public String getMasterId() { - return masterId; + return masterId; } - + public Map<String, HaNodeSummary> getNodes() { - return nodes; + return nodes; } - + public Map<String, URI> getLinks() { - return links; + return links; } @Override public boolean equals(Object o) { - return (o instanceof HighAvailabilitySummary) && ownId.equals(((HighAvailabilitySummary)o).getOwnId()); + return (o instanceof HighAvailabilitySummary) && ownId.equals(((HighAvailabilitySummary) o).getOwnId()); } @Override public int hashCode() { - return ownId != null ? ownId.hashCode() : 0; + return ownId != null ? ownId.hashCode() : 0; } @Override public String toString() { - return "HighAvailabilitySummary{" + - "ownId='" + ownId + '\'' + - ", links=" + links + - '}'; + return "HighAvailabilitySummary{" + + "ownId='" + ownId + '\'' + + ", links=" + links + + '}'; } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java index c9bbe25..d4a9c1a 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSpec.java @@ -34,61 +34,60 @@ import com.google.common.collect.ImmutableMap; /** @deprecated since 0.7.0 location spec objects will not be used from the client, instead pass yaml location spec strings */ public class LocationSpec implements HasName, HasConfig { - @JsonSerialize(include=Inclusion.NON_NULL) - private final String name; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String spec; - - @JsonSerialize(include=Inclusion.NON_EMPTY) - private final Map<String, ?> config; - - public static LocationSpec localhost() { - return new LocationSpec("localhost", "localhost", null); - } - - public LocationSpec( - @JsonProperty("name") String name, - @JsonProperty("spec") String spec, - @JsonProperty("config") @Nullable Map<String, ?> config - ) { - this.name = name; - this.spec = spec; - this.config = (config == null) ? Collections.<String, String>emptyMap() : ImmutableMap.copyOf(config); - } - - @Override - public String getName() { - return name; -} - - public String getSpec() { - return spec; - } - - public Map<String, ?> getConfig() { - return config; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - LocationSpec that = (LocationSpec) o; - return Objects.equal(name, that.name) && Objects.equal(spec, that.spec) && Objects.equal(config, that.config); - } - - @Override - public int hashCode() { - return Objects.hashCode(spec, name, config); - } - - @Override - public String toString() { - return "LocationSpec{" + - "name='" + name + '\'' + - "spec='" + spec + '\'' + - ", config=" + config + - '}'; - } + @JsonSerialize(include = Inclusion.NON_NULL) + private final String name; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String spec; + + @JsonSerialize(include = Inclusion.NON_EMPTY) + private final Map<String, ?> config; + + public static LocationSpec localhost() { + return new LocationSpec("localhost", "localhost", null); + } + + public LocationSpec( + @JsonProperty("name") String name, + @JsonProperty("spec") String spec, + @JsonProperty("config") @Nullable Map<String, ?> config) { + this.name = name; + this.spec = spec; + this.config = (config == null) ? Collections.<String, String> emptyMap() : ImmutableMap.copyOf(config); + } + + @Override + public String getName() { + return name; + } + + public String getSpec() { + return spec; + } + + public Map<String, ?> getConfig() { + return config; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + LocationSpec that = (LocationSpec) o; + return Objects.equal(name, that.name) && Objects.equal(spec, that.spec) && Objects.equal(config, that.config); + } + + @Override + public int hashCode() { + return Objects.hashCode(spec, name, config); + } + + @Override + public String toString() { + return "LocationSpec{" + + "name='" + name + '\'' + + "spec='" + spec + '\'' + + ", config=" + config + + '}'; + } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java index 935ad01..64300b3 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/LocationSummary.java @@ -34,62 +34,61 @@ import com.google.common.collect.ImmutableMap; public class LocationSummary extends LocationSpec implements HasName, HasId { - private final String id; - - /** only intended for instantiated Locations, not definitions */ - @JsonSerialize(include=Inclusion.NON_NULL) - private final String type; - private final Map<String, URI> links; - - public LocationSummary( - @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("spec") String spec, - @JsonProperty("type") String type, - @JsonProperty("config") @Nullable Map<String, ?> config, - @JsonProperty("links") Map<String, URI> links - ) { - super(name, spec, config); - this.id = checkNotNull(id); - this.type = type; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } + private final String id; - @Override - public String getId() { - return id; - } + /** only intended for instantiated Locations, not definitions */ + @JsonSerialize(include = Inclusion.NON_NULL) + private final String type; + private final Map<String, URI> links; - public String getType() { - return type; - } - - public Map<String, URI> getLinks() { - return links; - } + public LocationSummary( + @JsonProperty("id") String id, + @JsonProperty("name") String name, + @JsonProperty("spec") String spec, + @JsonProperty("type") String type, + @JsonProperty("config") @Nullable Map<String, ?> config, + @JsonProperty("links") Map<String, URI> links) { + super(name, spec, config); + this.id = checkNotNull(id); + this.type = type; + this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); + } - @Override - public boolean equals(Object o) { - if (!super.equals(o)) return false; - LocationSummary that = (LocationSummary) o; - return Objects.equal(id, that.id); - } + @Override + public String getId() { + return id; + } - @Override - public int hashCode() { - return Objects.hashCode(id, links); - } + public String getType() { + return type; + } + + public Map<String, URI> getLinks() { + return links; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) return false; + LocationSummary that = (LocationSummary) o; + return Objects.equal(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, links); + } - @Override - public String toString() { - return "LocationSummary{" + - "id='" + getId() + '\'' + - "name='" + getName() + '\'' + - "spec='" + getSpec() + '\'' + - "type='" + getType() + '\'' + - ", config=" + getConfig() + - ", links=" + links + - '}'; + @Override + public String toString() { + return "LocationSummary{" + + "id='" + getId() + '\'' + + "name='" + getName() + '\'' + + "spec='" + getSpec() + '\'' + + "type='" + getType() + '\'' + + ", config=" + getConfig() + + ", links=" + links + + '}'; } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java index 0088d9f..fe70a61 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicyConfigSummary.java @@ -29,31 +29,30 @@ import com.google.common.collect.ImmutableMap; public class PolicyConfigSummary extends ConfigSummary { - @JsonSerialize(include=Inclusion.NON_NULL) - private final Map<String, URI> links; - - public PolicyConfigSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("defaultValue") Object defaultValue, - @JsonProperty("reconfigurable") boolean reconfigurable, - @JsonProperty("links") Map<String, URI> links - ) { - super(name, type, description, defaultValue, reconfigurable, null, null, null); - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - @Override - public Map<String, URI> getLinks() { - return links; - } + @JsonSerialize(include = Inclusion.NON_NULL) + private final Map<String, URI> links; + + public PolicyConfigSummary( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("description") String description, + @JsonProperty("defaultValue") Object defaultValue, + @JsonProperty("reconfigurable") boolean reconfigurable, + @JsonProperty("links") Map<String, URI> links) { + super(name, type, description, defaultValue, reconfigurable, null, null, null); + this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); + } + + @Override + public Map<String, URI> getLinks() { + return links; + } - @Override - public String toString() { - return "PolicyConfigSummary{" + - "name='" + getName() + '\'' + - ", type='" + getType() + '\'' + - '}'; + @Override + public String toString() { + return "PolicyConfigSummary{" + + "name='" + getName() + '\'' + + ", type='" + getType() + '\'' + + '}'; } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java index cf7df6b..97fa7ff 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java @@ -18,90 +18,88 @@ */ package brooklyn.rest.domain; -import com.google.common.collect.ImmutableMap; +import java.net.URI; +import java.util.Map; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonSerialize; import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; -import java.net.URI; -import java.util.Map; +import com.google.common.collect.ImmutableMap; public class PolicySummary implements HasName, HasId { - private final String id; - private final String name; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String catalogItemId; - private final Status state; - private final Map<String, URI> links; - - public PolicySummary( - @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("catalogItemId") String catalogItemId, - @JsonProperty("state") Status state, - @JsonProperty("links") Map<String, URI> links - ) { - this.id = id; - this.name = name; - this.catalogItemId = catalogItemId; - this.state = state; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - @Override - public String getId() { - return id; - } - - @Override - public String getName() { - return name; - } - - public String getCatalogItemId() { - return catalogItemId; - } - - public Status getState() { - return state; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PolicySummary that = (PolicySummary) o; - - if (id != null ? !id.equals(that.id) : that.id != null) - return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (id != null ? id.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ConfigSummary{" + - "name='" + name + '\'' + - ", id='" + id + '\'' + - ", catalogItemId='" + catalogItemId + '\'' + - ", links=" + links + - '}'; - } + private final String id; + private final String name; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String catalogItemId; + private final Status state; + private final Map<String, URI> links; + + public PolicySummary( + @JsonProperty("id") String id, + @JsonProperty("name") String name, + @JsonProperty("catalogItemId") String catalogItemId, + @JsonProperty("state") Status state, + @JsonProperty("links") Map<String, URI> links) { + this.id = id; + this.name = name; + this.catalogItemId = catalogItemId; + this.state = state; + this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); + } + + @Override + public String getId() { + return id; + } + + @Override + public String getName() { + return name; + } + + public String getCatalogItemId() { + return catalogItemId; + } + + public Status getState() { + return state; + } + + public Map<String, URI> getLinks() { + return links; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PolicySummary that = (PolicySummary) o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (id != null ? id.hashCode() : 0); + return result; + } + @Override + public String toString() { + return "ConfigSummary{" + + "name='" + name + '\'' + + ", id='" + id + '\'' + + ", catalogItemId='" + catalogItemId + '\'' + + ", links=" + links + + '}'; + } } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java index fe3c27a..01d7c09 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/ScriptExecutionSummary.java @@ -24,15 +24,15 @@ import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; public class ScriptExecutionSummary { - @JsonSerialize(include=Inclusion.NON_NULL) + @JsonSerialize(include = Inclusion.NON_NULL) private final Object result; - @JsonSerialize(include=Inclusion.NON_EMPTY) + @JsonSerialize(include = Inclusion.NON_EMPTY) private final String problem; - @JsonSerialize(include=Inclusion.NON_EMPTY) + @JsonSerialize(include = Inclusion.NON_EMPTY) private final String stdout; - @JsonSerialize(include=Inclusion.NON_EMPTY) + @JsonSerialize(include = Inclusion.NON_EMPTY) private final String stderr; - + public ScriptExecutionSummary( @JsonProperty("result") Object result, @JsonProperty("problem") String problem, @@ -56,9 +56,8 @@ public class ScriptExecutionSummary { public String getStderr() { return stderr; } - + public String getStdout() { return stdout; } - } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f7aa7627/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java ---------------------------------------------------------------------- diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java index a6cdb4d..7af9e0b 100644 --- a/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java +++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/SensorSummary.java @@ -29,78 +29,76 @@ import com.google.common.collect.ImmutableMap; public class SensorSummary implements HasName { - private final String name; - private final String type; - @JsonSerialize(include=Inclusion.NON_NULL) - private final String description; - @JsonSerialize(include=Inclusion.NON_NULL) - private final Map<String, URI> links; - - public SensorSummary( - @JsonProperty("name") String name, - @JsonProperty("type") String type, - @JsonProperty("description") String description, - @JsonProperty("links") Map<String, URI> links - ) { - this.name = name; - this.type = type; - this.description = description; - this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links); - } - - @Override - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDescription() { - return description; - } - - public Map<String, URI> getLinks() { - return links; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SensorSummary that = (SensorSummary) o; - - if (description != null ? !description.equals(that.description) : that.description != null) - return false; - if (links != null ? !links.equals(that.links) : that.links != null) - return false; - if (name != null ? !name.equals(that.name) : that.name != null) - return false; - if (type != null ? !type.equals(that.type) : that.type != null) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (links != null ? links.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "SensorSummary{" + - "name='" + name + '\'' + - ", type='" + type + '\'' + - ", description='" + description + '\'' + - ", links=" + links + - '}'; - } - + private final String name; + private final String type; + @JsonSerialize(include = Inclusion.NON_NULL) + private final String description; + @JsonSerialize(include = Inclusion.NON_NULL) + private final Map<String, URI> links; + + public SensorSummary( + @JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("description") String description, + @JsonProperty("links") Map<String, URI> links) { + this.name = name; + this.type = type; + this.description = description; + this.links = (links == null) ? ImmutableMap.<String, URI> of() : ImmutableMap.copyOf(links); + } + + @Override + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public String getDescription() { + return description; + } + + public Map<String, URI> getLinks() { + return links; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SensorSummary that = (SensorSummary) o; + + if (description != null ? !description.equals(that.description) : that.description != null) + return false; + if (links != null ? !links.equals(that.links) : that.links != null) + return false; + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + if (type != null ? !type.equals(that.type) : that.type != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (links != null ? links.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SensorSummary{" + + "name='" + name + '\'' + + ", type='" + type + '\'' + + ", description='" + description + '\'' + + ", links=" + links + + '}'; + } }
