Author: cziegeler
Date: Fri Jul 28 16:33:30 2017
New Revision: 1803301

URL: http://svn.apache.org/viewvc?rev=1803301&view=rev
Log:
Update javadocs

Modified:
    
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java
    
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java
    
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java
    
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java
    
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java
    
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java

Modified: 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java?rev=1803301&r1=1803300&r2=1803301&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java
 (original)
+++ 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Application.java
 Fri Jul 28 16:33:30 2017
@@ -27,7 +27,7 @@ import java.util.List;
  *   <li>Configurations
  *   <li>Framework properties
  *   <li>Extensions
- *   <li>Feature ids
+ *   <li>Feature ids (of the features making up this application)
  * </ul>
  */
 public class Application {
@@ -105,7 +105,7 @@ public class Application {
      * Set the framework id
      * @param framework The framework id
      */
-    public void setFramework(ArtifactId framework) {
+    public void setFramework(final ArtifactId framework) {
         this.framework = framework;
     }
 

Modified: 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java?rev=1803301&r1=1803300&r2=1803301&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java
 (original)
+++ 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Capability.java
 Fri Jul 28 16:33:30 2017
@@ -75,36 +75,26 @@ public class Capability {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((attributes == null) ? 0 : 
attributes.hashCode());
-        result = prime * result + ((directives == null) ? 0 : 
directives.hashCode());
-        result = prime * result + ((namespace == null) ? 0 : 
namespace.hashCode());
+        result = prime * result + attributes.hashCode();
+        result = prime * result + directives.hashCode();
+        result = prime * result + namespace.hashCode();
         return result;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
-        if (getClass() != obj.getClass())
-            return false;
-        Capability other = (Capability) obj;
-        if (attributes == null) {
-            if (other.attributes != null)
-                return false;
-        } else if (!attributes.equals(other.attributes))
-            return false;
-        if (directives == null) {
-            if (other.directives != null)
-                return false;
-        } else if (!directives.equals(other.directives))
-            return false;
-        if (namespace == null) {
-            if (other.namespace != null)
-                return false;
-        } else if (!namespace.equals(other.namespace))
+        }
+        final Capability other = (Capability) obj;
+        if (!attributes.equals(other.attributes)
+            || !directives.equals(other.directives)
+            || !namespace.equals(other.namespace)) {
             return false;
+        }
         return true;
     }
 }

Modified: 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java?rev=1803301&r1=1803300&r2=1803301&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java
 (original)
+++ 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Extension.java
 Fri Jul 28 16:33:30 2017
@@ -37,16 +37,28 @@ public class Extension {
     /** Common extension name to specify the content packages for Apache 
Sling. */
     public static final String NAME_CONTENT_PACKAGES = "content-packages";
 
+    /** The extension type */
     private final ExtensionType type;
 
+    /** The extension name. */
     private final String name;
 
-    private final List<Artifact> artifacts = new ArrayList<>();
+    /** The list of artifacts (if type artifacts) */
+    private final List<Artifact> artifacts;
 
+    /** The text or json (if corresponding type) */
     private String text;
 
+    /** Whether the artifact is required. */
     private final boolean required;
 
+    /**
+     * Create a new extension
+     * @param t The type of the extension
+     * @param name The name of the extension
+     * @param required Whether the extension is required or optional
+     * @throws IllegalArgumentException If name or t are {@code null}
+     */
     public Extension(final ExtensionType t,
             final String name,
             final boolean required) {
@@ -56,12 +68,50 @@ public class Extension {
         this.type = t;
         this.name = name;
         this.required = required;
+        if ( t == ExtensionType.ARTIFACTS ) {
+            this.artifacts = new ArrayList<>();
+        } else {
+            this.artifacts = null;
+        }
     }
 
+    /**
+     * Get the extension type
+     * @return The type
+     */
     public ExtensionType getType() {
         return this.type;
     }
 
+    /**
+     * Get the extension name
+     * @return The name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Return whether the extension is required or optional
+     * @return Return {@code true} if the extension is required.
+     */
+    public boolean isRequired() {
+        return this.required;
+    }
+
+    /**
+     * Return whether the extension is required or optional
+     * @return Return {@code true} if the extension is optional.
+     */
+    public boolean isOptional() {
+        return !this.isRequired();
+    }
+
+    /**
+     * Get the text of the extension
+     * @return The text
+     * @throws IllegalStateException if the type is not {@code 
ExtensionType#TEXT}
+     */
     public String getText() {
         if ( type != ExtensionType.TEXT ) {
             throw new IllegalStateException();
@@ -69,13 +119,23 @@ public class Extension {
         return text;
     }
 
-    public void setText(String text) {
+    /**
+     * Set the text of the extension
+     * @param text The text
+     * @throws IllegalStateException if the type is not {@code 
ExtensionType#TEXT}
+     */
+    public void setText(final String text) {
         if ( type != ExtensionType.TEXT ) {
             throw new IllegalStateException();
         }
         this.text = text;
     }
 
+    /**
+     * Get the JSON of the extension
+     * @return The JSON
+     * @throws IllegalStateException if the type is not {@code 
ExtensionType#JSON}
+     */
     public String getJSON() {
         if ( type != ExtensionType.JSON ) {
             throw new IllegalStateException();
@@ -83,6 +143,11 @@ public class Extension {
         return text;
     }
 
+    /**
+     * Set the JSON of the extension
+     * @param text The JSON
+     * @throws IllegalStateException if the type is not {@code 
ExtensionType#JSON}
+     */
     public void setJSON(String text) {
         if ( type != ExtensionType.JSON ) {
             throw new IllegalStateException();
@@ -90,10 +155,11 @@ public class Extension {
         this.text = text;
     }
 
-    public String getName() {
-        return name;
-    }
-
+    /**
+     * Get the artifacts of the extension
+     * @return The artifacts
+     * @throws IllegalStateException if the type is not {@code 
ExtensionType#ARTIFACTS}
+     */
     public List<Artifact> getArtifacts() {
         if ( type != ExtensionType.ARTIFACTS ) {
             throw new IllegalStateException();
@@ -101,14 +167,6 @@ public class Extension {
         return artifacts;
     }
 
-    public boolean isRequired() {
-        return this.required;
-    }
-
-    public boolean isOptional() {
-        return !this.isRequired();
-    }
-
     @Override
     public int hashCode() {
         return name.hashCode();

Modified: 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java?rev=1803301&r1=1803300&r2=1803301&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java
 (original)
+++ 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Feature.java
 Fri Jul 28 16:33:30 2017
@@ -121,78 +121,161 @@ public class Feature implements Comparab
         return this.bundles;
     }
 
+    /**
+     * Get the configurations.
+     * The returned object is modifiable.
+     * @return The configurations
+     */
     public Configurations getConfigurations() {
         return this.configurations;
     }
 
+    /**
+     * Get the framework properties
+     * The returned object is modifiable.
+     * @return The framework properties
+     */
     public KeyValueMap getFrameworkProperties() {
         return this.frameworkProperties;
     }
 
+    /**
+     * Get the list of requirements.
+     * The returned object is modifiable.
+     * @return The list of requirements
+     */
     public List<Requirement> getRequirements() {
         return requirements;
     }
 
+    /**
+     * Get the list of capabilities.
+     * The returned object is modifiable.
+     * @return The list of capabilities
+     */
     public List<Capability> getCapabilities() {
         return capabilities;
     }
 
+    /**
+     * Get the list of includes.
+     * The returned object is modifiable.
+     * @return The list of includes
+     */
     public List<Include> getIncludes() {
         return includes;
     }
 
+    /**
+     * Get the list of extensions.
+     * The returned object is modifiable.
+     * @return The list of extensions
+     */
     public Extensions getExtensions() {
         return this.extensions;
     }
 
+    /**
+     * Get the title
+     * @return The title or {@code null}
+     */
     public String getTitle() {
         return title;
     }
 
-    public void setTitle(String title) {
+    /**
+     * Set the title
+     * @param title The title
+     */
+    public void setTitle(final String title) {
         this.title = title;
     }
 
+    /**
+     * Get the description
+     * @return The description or {@code null}
+     */
     public String getDescription() {
         return description;
     }
 
-    public void setDescription(String description) {
+    /**
+     * Set the description
+     * @param description The description
+     */
+    public void setDescription(final String description) {
         this.description = description;
     }
 
+    /**
+     * Get the vendor
+     * @return The vendor or {@code null}
+     */
     public String getVendor() {
         return vendor;
     }
 
-    public void setVendor(String vendor) {
+    /**
+     * Set the vendor
+     * @param vendor The vendor
+     */
+    public void setVendor(final String vendor) {
         this.vendor = vendor;
     }
 
+    /**
+     * Get the license
+     * @return The license or {@code null}
+     */
     public String getLicense() {
         return license;
     }
 
-    public void setLicense(String license) {
+    /**
+     * Set the vendor
+     * @param license The license
+     */
+    public void setLicense(final String license) {
         this.license = license;
     }
 
+    /**
+     * Set the upgrade of information
+     * @param id The artifact id
+     */
     public void setUpgradeOf(final ArtifactId id) {
         this.upgradeOf = id;
     }
 
+    /**
+     * Get the artifact id of the upgrade of information
+     * @return The artifact id or {@code null}
+     */
     public ArtifactId getUpgradeOf() {
         return this.upgradeOf;
     }
 
+    /**
+     * Get the list of upgrades applied to this feature
+     * The returned object is modifiable.
+     * @return The list of upgrades
+     */
     public List<ArtifactId> getUpgrades() {
         return this.upgrades;
     }
 
+    /**
+     * Check whether the feature is already assembled
+     * @return {@code true} if it is assembled, {@code false} if it needs to 
be assembled
+     */
     public boolean isAssembled() {
         return assembled;
     }
 
+    /**
+     * Set the assembled flag
+     * @param flag The flag
+     */
     public void setAssembled(final boolean flag) {
         this.assembled = flag;
     }
@@ -205,6 +288,11 @@ public class Feature implements Comparab
         return copy(this.getId());
     }
 
+    /**
+     * Create a copy of the feature with a different id
+     * @param id The new id
+     * @return The copy of the feature with the new id
+     */
     public Feature copy(final ArtifactId id) {
         final Feature result = new Feature(id);
 
@@ -238,17 +326,52 @@ public class Feature implements Comparab
         // framework properties
         result.getFrameworkProperties().putAll(this.getFrameworkProperties());
 
-        // requirements (TODO copy requirement)
-        result.getRequirements().addAll(this.getRequirements());
+        // requirements
+        for(final Requirement r : this.getRequirements()) {
+            final Requirement c = new Requirement(r.getNamespace());
+            c.getAttributes().putAll(r.getAttributes());
+            c.getDirectives().putAll(r.getDirectives());
+            result.getRequirements().add(c);
+        }
 
-        // capabilities (TODO copy capability)
-        result.getCapabilities().addAll(this.getCapabilities());
+        // capabilities
+        for(final Capability r : this.getCapabilities()) {
+            final Capability c = new Capability(r.getNamespace());
+            c.getAttributes().putAll(r.getAttributes());
+            c.getDirectives().putAll(r.getDirectives());
+            result.getCapabilities().add(c);
+        }
+
+        // includes
+        for(final Include i : this.getIncludes()) {
+            final Include c = new Include(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(c.getArtifactExtensionRemovals());
 
-        // includes (TODO copy include)
-        result.getIncludes().addAll(this.getIncludes());
+            result.getIncludes().add(c);
+        }
 
-        // extensions (TODO copy extension)
-        result.getExtensions().addAll(this.getExtensions());
+        // extensions
+        for(final Extension e : this.getExtensions()) {
+            final Extension c = new Extension(e.getType(), e.getName(), 
e.isRequired());
+            switch ( c.getType() ) {
+                case ARTIFACTS : for(final Artifact a : e.getArtifacts()) {
+                                     final Artifact x = new 
Artifact(a.getId());
+                                     x.getMetadata().putAll(a.getMetadata());
+                                     c.getArtifacts().add(x);
+                                 }
+                                 break;
+                case JSON : c.setJSON(e.getJSON());
+                            break;
+                case TEXT : c.setText(e.getText());
+                            break;
+            }
+            result.getExtensions().add(c);
+        }
 
         return result;
     }

Modified: 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java?rev=1803301&r1=1803300&r2=1803301&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java
 (original)
+++ 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Include.java
 Fri Jul 28 16:33:30 2017
@@ -29,6 +29,8 @@ import java.util.Map;
  *   <li>Framework properties
  *   <li>Extensions or artifacts from extensions
  * </ul>
+ *
+ *  TODO - requirement, capabilities
  */
 public class Include implements Comparable<Include> {
 

Modified: 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java
URL: 
http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java?rev=1803301&r1=1803300&r2=1803301&view=diff
==============================================================================
--- 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java
 (original)
+++ 
sling/whiteboard/cziegeler/feature/src/main/java/org/apache/sling/feature/Requirement.java
 Fri Jul 28 16:33:30 2017
@@ -82,20 +82,19 @@ public class Requirement {
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
+        }
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
+        }
         final Requirement other = (Requirement) obj;
-        if (!attributes.equals(other.attributes))
-            return false;
-        if (!directives.equals(other.directives))
-            return false;
-        if (!namespace.equals(other.namespace))
+        if (!attributes.equals(other.attributes)
+            || !directives.equals(other.directives)
+            || !namespace.equals(other.namespace)) {
             return false;
+        }
         return true;
     }
 }


Reply via email to