brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #358: Allow REST API to return the pinned confi...
Date Thu, 29 Sep 2016 17:07:46 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/358#discussion_r81185833
  
    --- Diff: rest/rest-api/src/main/java/org/apache/brooklyn/rest/domain/EntityConfigSummary.java
---
    @@ -18,43 +18,82 @@
      */
     package org.apache.brooklyn.rest.domain;
     
    -import com.fasterxml.jackson.annotation.JsonProperty;
    -import com.fasterxml.jackson.databind.annotation.JsonSerialize;
    -import com.google.common.collect.ImmutableMap;
    -
    -import org.apache.brooklyn.config.ConfigKey;
    -
     import java.net.URI;
     import java.util.List;
     import java.util.Map;
     import java.util.Objects;
     
    +import javax.annotation.Nullable;
    +
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.util.text.StringPredicates;
    +
    +import com.fasterxml.jackson.annotation.JsonProperty;
    +import com.fasterxml.jackson.databind.annotation.JsonSerialize;
    +import com.google.common.base.Function;
    +import com.google.common.base.Predicate;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.Iterables;
    +
     public class EntityConfigSummary extends ConfigSummary {
     
         private static final long serialVersionUID = -1336134336883426030L;
     
         @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
    +    private final Boolean pinned;
    +
    +    @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
    +    private final List<String> constraints;
    +
    +    @JsonSerialize(include = JsonSerialize.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("reconfigurable") Boolean reconfigurable,
                 @JsonProperty("label") String label,
                 @JsonProperty("priority") Double priority,
                 @JsonProperty("possibleValues") List<Map<String, String>> possibleValues,
    +            @JsonProperty("pinned") Boolean pinned,
    +            @JsonProperty("constraints") List<String> constraints,
                 @JsonProperty("links") Map<String, URI> links) {
             super(name, type, description, defaultValue, reconfigurable, label, priority,
possibleValues);
    +        this.pinned = pinned;
    +        this.constraints = (constraints == null) ? ImmutableList.<String>of() :
ImmutableList.copyOf(constraints);
             this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links);
         }
     
    -    public EntityConfigSummary(ConfigKey<?> config, String label, Double priority,
Map<String, URI> links) {
    +    public EntityConfigSummary(ConfigKey<?> config, String label, Double priority,
Boolean pinned, Map<String, URI> links) {
             super(config, label, priority);
    +        this.pinned = pinned;
    +        this.constraints = ImmutableList.copyOf(Iterables.transform(config.getConstraints(),
new Function<Predicate, String>() {
    +            @Nullable
    +            @Override
    +            public String apply(@Nullable Predicate predicate) {
    +                if (predicate == null) {
    +                    return null;
    +                } else if (predicate.getClass().getName().equals(StringPredicates.isNonBlank().getClass().getName()))
{
    --- End diff --
    
    Could even compare the classes without going through the name, but doesn't really matter
in the end.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message