Skip to content

Commit

Permalink
JavaDoc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko committed Apr 17, 2018
1 parent 337d516 commit a57c2b8
Show file tree
Hide file tree
Showing 56 changed files with 2,010 additions and 952 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,87 @@
*/
package ninja.leaping.configurate;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Iterator;

/**
* The value in a {@link ConfigurationNode}.
*/
abstract class ConfigValue {

/**
* The node this value "belongs" to.
*/
@NonNull
protected final SimpleConfigurationNode holder;

protected ConfigValue(SimpleConfigurationNode holder) {
protected ConfigValue(@NonNull SimpleConfigurationNode holder) {
this.holder = holder;
}

/**
* Gets the value encapsulated by this instance
*
* @return The value
*/
@Nullable
abstract Object getValue();
abstract void setValue(Object value);

/**
* put a child, or null to remove value at key
* Sets the value encapsulated by this instance
*
* @param value The value
*/
abstract void setValue(@Nullable Object value);

/**
* Put a child value, or null to remove value at that key
*
* @param key The key
* @param value The node to put at key
* @return Existing node at key, if present
*/
@Nullable
abstract SimpleConfigurationNode putChild(@NonNull Object key, @Nullable SimpleConfigurationNode value);

/**
* Put a child value, if one isn't already present at that key
*
* @param key the key
* @param value the node to put at key
* @return existing node at key, if present
* @param key The key
* @param value The node to put at key
* @return Existing node at key, if present
*/
abstract SimpleConfigurationNode putChild(Object key, SimpleConfigurationNode value);
abstract SimpleConfigurationNode putChildIfAbsent(Object key, SimpleConfigurationNode value);
@Nullable
abstract SimpleConfigurationNode putChildIfAbsent(@NonNull Object key, @Nullable SimpleConfigurationNode value);

/**
* gets the currently present child.
* returns null if no child is present
* Gets the currently present child for the given key. Returns null if no child is present
*
* @param key the key to get child at
* @return the child if any
* @param key The key to get child at
* @return The child if any
*/
abstract SimpleConfigurationNode getChild(Object key);
@Nullable
abstract SimpleConfigurationNode getChild(@Nullable Object key);

/**
* Returns an iterable over all child nodes
*
* @return An iterator
*/
@NonNull
abstract Iterable<SimpleConfigurationNode> iterateChildren();

/**
* Clears the set value (or any attached child values) from this value
*/
void clear() {
for (Iterator<SimpleConfigurationNode> it = iterateChildren().iterator(); it.hasNext();) {
SimpleConfigurationNode node = it.next();
node.attached = false;
it.remove();
if (node.getParentAttached().equals(holder)) {
if (node.getParentEnsureAttached().equals(holder)) {
node.clear();
}
}
Expand Down
Loading

0 comments on commit a57c2b8

Please sign in to comment.