Commits

Dmytro Kovalchuk  committed 0216243 Draft

Javadoc for registry module

  • Participants
  • Parent commits d09c184

Comments (0)

Files changed (5)

File registry/src/main/java/net/anatolich/registry/AbstractItemNode.java

  */
 package net.anatolich.registry;
 
-import java.util.Collections;
-import java.util.Iterator;
-import net.anatolich.registry.AbstractNode;
-import net.anatolich.registry.Attributes;
-
 /**
- *
+ * Leaf node which cannot have child nodes.
  * @author Anatolich <anatolich@anatolich.net>
+ * @version 1.0 
  */
 public abstract class AbstractItemNode<T extends Attributes> extends AbstractNode<T> {
 
         super(name, attributes, position);
     }
 
+    /**
+     * Does nothing. Actually call of this method may signalize that something is 
+     * wrong with algorithm or configuration.
+     * @param node 
+     */
     @Override
     public final void addChild(AbstractNode node) {
     }
 
+    /**
+     * Does nothing.
+     * @param node 
+     */
     @Override
     public final void removeChild(AbstractNode node) {
     }

File registry/src/main/java/net/anatolich/registry/AbstractNode.java

 import java.util.Set;
 
 /**
- *
+ * Tree element that holds required data.
  * @author Anatolich <anatolich@anatolich.net>
+ * @version 1.0
  */
 public abstract class AbstractNode<T extends Attributes> {
 
         this.parent = parentNode;
     }
 
+    /**
+     * Gets position number. Node is closer to start of it's parent's node 
+     * children list when position is lower. 
+     * @return 
+     */
     public final int position() {
         return position;
     }
 
+    /**
+     * Comparator capable to correctly sort list of child nodes.
+     * @return 
+     */
     protected static Comparator<AbstractNode> positionComparator() {
         return new PositionalComparator();
     }
         return getParent() != null;
     }
 
+    /**
+     * Adds child node to current node. Parent reference for added node is set 
+     * to point to current node.
+     * @param node 
+     */
     public void addChild(AbstractNode node) {
         AbstractNode existingNode = getChild(node.getName());
         if( existingNode != null ){
         return children.size();
     }
 
+    /**
+     * Gets child node by name.
+     * @param name node name.
+     * @return node with provided name or null if node with specified name is 
+     * not present in child nodes list.
+     */
     public final AbstractNode getChild(String name) {
         for (AbstractNode node : children) {
             if (node.getName().equals(name)) {
         return null;
     }
 
+    /**
+     * Returns child node by it's sequential position in child node list. 
+     * @param index child node index. It's not {@link #position() } but simple index in list.
+     * @return child node specified by index. Will throw runtime exception when node index is not in range of child list.
+     */
     public final AbstractNode getChild(int index) {
         return children.get(index);
     }

File registry/src/main/java/net/anatolich/registry/Attributes.java

 import java.util.Map;
 
 /**
- *
+ * Holder for named attributes associated with registry nodes.
  * @author Anatolich <anatolich@anatolich.net>
  */
 public abstract class Attributes {
         return namedAttributes.get(key);
     }
 
+    /**
+     * Get instance of attribute specified by it's class
+     * @param <T> type 
+     * @param key class for which typed attribute is registered
+     * @return instance of typed attribute or null if no attribute registered.
+     */
     public final <T> T getAttribute(Class<T> key) {
         return (T) typedAttributes.get(key);
     }

File registry/src/main/java/net/anatolich/registry/Registry.java

 import java.util.List;
 
 /**
- *
+ * Registry that holds tree hierarchy of nodes. Registry allows to query 
+ * registry nodes by {@link Path}. Also registry allows to attach structure 
+ * change listeners either to whole registry or to part of it.
  * @author Anatolich <anatolich@anatolich.net>
+ * @version 1.0
  */
 public final class Registry implements NodeChangeListener {
     private final AbstractNode rootNode;
     }
     
     /**
-     * 
+     * Gets node by it's path in registry.
      * @param path
-     * @return 
+     * @return AbstractNode descendant that can be retrieved by specified path.
      * @throws EntryNotFoundException when registry entry for path not exist.
      */
     public AbstractNode getNodeByPath(Path path){

File registry/src/main/java/net/anatolich/registry/package-info.java

+/*
+ * Copyright 2012 Anatolich <anatolich@anatolich.net>.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.anatolich.registry;