@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FeatureId other = (FeatureId) obj; if (params == null) { if (other.params != null) return false; } else if (!params.equals(other.params)) return false; if (specId == null) { if (other.specId != null) return false; } else if (!specId.equals(other.specId)) return false; return true; }
public static SpecId fromString(String str) throws ProvisioningDescriptionException { return new SpecId(str); }
public FeatureConfig setSpecName(String specName) throws ProvisioningDescriptionException { this.specId = SpecId.fromString(specName); return this; }
private Set<ResolvedSpecId> resolveSpecIds(Set<ResolvedSpecId> resolvedIds, Set<SpecId> specs) throws ProvisioningException { for (SpecId specId : specs) { resolvedIds = CollectionUtils.add(resolvedIds, getFeatureSpec(specId.getName()).id); } return resolvedIds; }
public static void addFeatureConfig(ElementNode parentE, FeatureConfig fc, String ns) { final ElementNode fcE = addElement(parentE, Element.FEATURE.getLocalName(), ns); addAttribute(fcE, Attribute.SPEC, fc.getSpecId().toString()); if(fc.getParentRef() != null) { addAttribute(fcE, Attribute.PARENT_REF, fc.getParentRef()); } addFeatureConfigBody(fcE, null, fc, ns); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((params == null) ? 0 : params.hashCode()); result = prime * result + ((specId == null) ? 0 : specId.hashCode()); return result; }
private Set<ResolvedFeatureId> resolveExcludedIds(Set<ResolvedFeatureId> resolvedIds, Map<FeatureId, String> features) throws ProvisioningException { for (Map.Entry<FeatureId, String> excluded : features.entrySet()) { final FeatureId excludedId = excluded.getKey(); final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(excludedId.getSpec().getName()); if(parentFeature != null) { resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, excluded.getValue(), excludedId.getParams())); } else { resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveFeatureId(excludedId.getParams())); } } return resolvedIds; }
for(SpecId spec : dep.getExcludedSpecs()) { final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns); addAttribute(excludeE, Attribute.SPEC, spec.toString()); for(SpecId spec : dep.getIncludedSpecs()) { final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns); addAttribute(includeE, Attribute.SPEC, spec.toString());
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((origin == null) ? 0 : origin.hashCode()); result = prime * result + ((feature == null) ? 0 : feature.hashCode()); result = prime * result + (include ? 1231 : 1237); result = prime * result + ((mappedParams == null) ? 0 : mappedParams.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + (nillable ? 1231 : 1237); return result; }
if (other.feature != null) return false; } else if (!feature.equals(other.feature)) return false; if (include != other.include)
final FeatureDependencySpec depSpec = depSpecs.iterator().next(); final FeaturePackRuntimeBuilder depFp = depSpec.getOrigin() == null ? rt.layout.getFeaturePack(id.producer) : rt.getOrigin(depSpec.getOrigin()); final ResolvedFeatureSpec depResolvedSpec = rt.getFeatureSpec(depFp, depSpec.getFeatureId().getSpec().getName()); return Collections.singletonMap(depResolvedSpec.resolveFeatureId(depSpec.getFeatureId().getParams()), depSpec); for (FeatureDependencySpec userDep : depSpecs) { final FeaturePackRuntimeBuilder depFp = userDep.getOrigin() == null ? ownFp : rt.getOrigin(userDep.getOrigin()); final ResolvedFeatureSpec depResolvedSpec = rt.getFeatureSpec(depFp, userDep.getFeatureId().getSpec().getName()); final ResolvedFeatureId depId = depResolvedSpec.resolveFeatureId(userDep.getFeatureId().getParams()); final FeatureDependencySpec specDep = result.put(depId, userDep);
public FeatureConfig(String specName) throws ProvisioningDescriptionException { this.specId = SpecId.fromString(specName); }
for(FeatureReferenceSpec ref : featureSpec.getFeatureRefs()) { final ElementNode refE = addElement(refsE, Element.REFERENCE); final String feature = ref.getFeature().toString(); if(ref.getOrigin() != null) { addAttribute(refE, Attribute.DEPENDENCY, ref.getOrigin());
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((deps == null) ? 0 : deps.hashCode()); result = prime * result + ((origin == null) ? 0 : origin.hashCode()); result = prime * result + ((items == null) ? 0 : items.hashCode()); result = prime * result + ((params == null) ? 0 : params.hashCode()); result = prime * result + ((parentRef == null) ? 0 : parentRef.hashCode()); result = prime * result + ((resetParams == null) ? 0 : resetParams.hashCode()); result = prime * result + ((specId == null) ? 0 : specId.hashCode()); result = prime * result + ((unsetParams == null) ? 0 : unsetParams.hashCode()); return result; }
if (other.specId != null) return false; } else if (!specId.equals(other.specId)) return false; if (unsetParams == null) {
private Map<ResolvedFeatureId, FeatureConfig> resolveIncludedIds(Map<ResolvedFeatureId, FeatureConfig> includedFeatures, Map<FeatureId, FeatureConfig> features) throws ProvisioningException { for (Map.Entry<FeatureId, FeatureConfig> included : features.entrySet()) { final FeatureConfig fc = new FeatureConfig(included.getValue()); final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(fc.getSpecId().getName()); if (parentFeature != null) { includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, fc.getParentRef(), fc.getParams()), fc); } else { includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveFeatureId(fc.getParams()), fc); } } return includedFeatures; }
private FeatureReferenceSpec(String origin, String name, String featureSpec, boolean nillable, boolean include, Map<String, String> paramMapping) throws ProvisioningDescriptionException { this.origin = origin; this.name = name; this.feature = SpecId.fromString(featureSpec); this.nillable = nillable; this.include = include; this.mappedParams = CollectionUtils.unmodifiable(paramMapping); }
@SuppressWarnings("unchecked") public B removeFeature(FeatureId id) throws ProvisioningDescriptionException { int index = -1; // Although that is a list, we have a single ConfigModel for a given ConfigId for (int i = 0; i < items.size(); i++) { ConfigItem ci = items.get(i); if (ci instanceof FeatureConfig) { FeatureConfig conf = (FeatureConfig) ci; if (conf.getSpecId().equals(id.getSpec())) { boolean eq = true; for (Entry<String, String> entry : id.getParams().entrySet()) { String val = conf.getParam(entry.getKey()); if (val == null || !val.equals(entry.getValue())) { eq = false; break; } } if (eq) { index = i; break; } } } } if (index == -1) { throw new ProvisioningDescriptionException("Feature " + id + " is not added"); } items = CollectionUtils.remove(items, index); return (B) this; }
final ResolvedFeatureSpec refResolvedSpec = getFeatureSpec(refSpec.getFeature().getName()); final List<ResolvedFeatureId> refIds = spec.resolveRefId(parentFeature, refSpec, refResolvedSpec); if (!refIds.isEmpty()) {
@SuppressWarnings("unchecked") public B includeSpec(String spec) throws ProvisioningDescriptionException { final SpecId specId = SpecId.fromString(spec); if(excludedSpecs.contains(specId)) { throw new ProvisioningDescriptionException(specId + " spec has been explicitly excluded"); } includedSpecs = CollectionUtils.addLinked(includedSpecs, specId); return (B) this; }