Skip to content
Permalink
Browse files
WIP - change semantics of parameter addition
api EntitySpec.parameters(...)  should *add* parameters, like the other methods;
since parameters have just been introduced it is fine to do this

also comments and tidy of other merges
  • Loading branch information
ahgittin committed Jan 14, 2016
1 parent 73f7e73 commit aa9a2d7be66863144449fe05079ddad97d19a457
Showing 2 changed files with 16 additions and 9 deletions.
@@ -40,6 +40,7 @@

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
@@ -107,8 +108,14 @@ public SpecT tags(Iterable<Object> tagsToAdd) {
return self();
}

/** adds the given parameters */
public SpecT parameters(List<? extends SpecParameter<?>> parameters) {
this.parameters = ImmutableList.copyOf(checkNotNull(parameters, "parameters"));
// parameters follows immutable pattern, unlike the other fields
Builder<SpecParameter<?>> result = ImmutableList.<SpecParameter<?>>builder();
if (this.parameters!=null)
result.addAll(this.parameters);
result.addAll( checkNotNull(parameters, "parameters") );
this.parameters = result.build();
return self();
}

@@ -248,18 +248,18 @@ private static void mergeWrapperParentSpecToChildEntity(EntitySpec<? extends App
if (Strings.isNonEmpty(wrapperParent.getDisplayName())) {
wrappedChild.displayName(wrapperParent.getDisplayName());
}
if (!wrapperParent.getLocations().isEmpty()) {
wrappedChild.locations(wrapperParent.getLocations());
}
if (!wrapperParent.getParameters().isEmpty()) {
wrappedChild.parameters(wrapperParent.getParameters());
}

wrappedChild.locations(wrapperParent.getLocations());

wrappedChild.parameters(wrapperParent.getParameters());

if (wrappedChild.getCatalogItemId()==null) {
wrappedChild.catalogItemId(wrapperParent.getCatalogItemId());
}

// NB: this clobbers child config; might prefer to deeply merge maps etc
// (but this should not be surprising, as unwrapping is often parameterising the nested blueprint, so outer config should dominate)
// NB: this clobber's child config; might prefer to deeply merge maps etc
// (or maybe even prevent the merge in these cases;
// not sure there is a compelling reason to have config on a pure-wrapper parent)
Map<ConfigKey<?>, Object> configWithoutWrapperMarker = Maps.filterKeys(wrapperParent.getConfig(), Predicates.not(Predicates.<ConfigKey<?>>equalTo(EntityManagementUtils.WRAPPER_APP_MARKER)));
wrappedChild.configure(configWithoutWrapperMarker);
wrappedChild.configure(wrapperParent.getFlags());

0 comments on commit aa9a2d7

Please sign in to comment.