in src/main/java/org/apache/sling/feature/Feature.java [469:551]
public Feature copy(final ArtifactId id) {
final Feature result = new Feature(id);
// metadata
result.setLocation(this.getLocation());
result.setTitle(this.getTitle());
result.setDescription(this.getDescription());
result.setVendor(this.getVendor());
result.setLicense(this.getLicense());
result.setAssembled(this.isAssembled());
result.setFinal(this.isFinal());
result.setComplete(this.isComplete());
result.getCategories().addAll(this.getCategories());
result.setDocURL(this.getDocURL());
result.setSCMInfo(this.getSCMInfo());
// variables
result.getVariables().putAll(this.getVariables());
for(final String key : this.getVariables().keySet()) {
result.getVariableMetadata(key).putAll(this.getVariableMetadata(key));
}
// bundles
for(final Artifact b : this.getBundles()) {
result.getBundles().add(b.copy(b.getId()));
}
// configurations
for(final Configuration cfg : this.getConfigurations()) {
result.getConfigurations().add(cfg.copy(cfg.getPid()));
}
// framework properties
result.getFrameworkProperties().putAll(this.getFrameworkProperties());
for(final String key : this.getFrameworkProperties().keySet()) {
result.getFrameworkPropertyMetadata(key).putAll(this.getFrameworkPropertyMetadata(key));
}
// requirements
for (final MatchingRequirement r : this.getRequirements()) {
final MatchingRequirement c = new MatchingRequirementImpl(null, r.getNamespace(), r.getDirectives(),
r.getAttributes());
result.getRequirements().add(c);
}
// capabilities
for(final Capability r : this.getCapabilities()) {
final Capability c = new CapabilityImpl(null, r.getNamespace(), r.getDirectives(), r.getAttributes());
result.getCapabilities().add(c);
}
// prototype
final Prototype i = this.getPrototype();
if (i != null) {
final Prototype c = new Prototype(i.getId());
c.getBundleRemovals().addAll(i.getBundleRemovals());
c.getConfigurationRemovals().addAll(i.getConfigurationRemovals());
c.getExtensionRemovals().addAll(i.getExtensionRemovals());
c.getFrameworkPropertiesRemovals().addAll(i.getFrameworkPropertiesRemovals());
c.getArtifactExtensionRemovals().putAll(i.getArtifactExtensionRemovals());
result.setPrototype(c);
}
// extensions
for(final Extension e : this.getExtensions()) {
final Extension c = new Extension(e.getType(), e.getName(), e.getState());
switch ( c.getType() ) {
case ARTIFACTS : for(final Artifact a : e.getArtifacts()) {
c.getArtifacts().add(a.copy(a.getId()));
}
break;
case JSON : c.setJSON(e.getJSON());
break;
case TEXT : c.setText(e.getText());
break;
}
result.getExtensions().add(c);
}
return result;
}