Created
March 9, 2012 15:47
-
-
Save jukka/2007178 to your computer and use it in GitHub Desktop.
Draft interfaces for modifying trees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Builder interface for constructing new {@link NodeState node states}. | |
*/ | |
public interface NodeBuilder { | |
/** | |
* Sets or removes the named property. | |
* | |
* @param name property name | |
* @param encodedValue encoded value of the property, | |
* or <code>null</code> to remove the named property | |
*/ | |
void setProperty(String name, String encodedValue); | |
/** | |
* Sets or removes the named child node. | |
* | |
* @param name child node name | |
* @param childNode new child node state, | |
* or <code>null</code> to remove the named child node | |
*/ | |
void setChildNode(String name, NodeState childNode); | |
/** | |
* Returns an immutable node state that matches the current state of | |
* the builder. | |
* | |
* @return immutable node state | |
*/ | |
NodeState getNodeState(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Storage abstraction for content trees. At any given point in time | |
* the stored content tree is rooted at a single immutable node state. | |
* Changes in the tree are constructed using {@link NodeBuilder} instances | |
* based on the root and other node states in the tree. The state of the | |
* entire tree can then be changed by setting the resulting modified root | |
* node state as the new root of the tree. | |
* <p> | |
* This is a low-level interface that doesn't cover functionality like | |
* merging concurrent changes or rejecting new tree states based on some | |
* higher-level consistency constraints. | |
*/ | |
public interface NodeStore { | |
/** | |
* Returns the latest state of the content tree. | |
* | |
* @return root node state | |
*/ | |
NodeState getRoot(); | |
/** | |
* Updates the state of the content tree. | |
* | |
* @param newRoot new root node state | |
*/ | |
void setRoot(NodeState newRoot); | |
/** | |
* Returns a builder for constructing a new or modified node state. | |
* The builder is initialized with all the properties and child nodes | |
* from the given base node state, or with no properties or child nodes | |
* if no base node state is given. | |
* | |
* @param base base node state, | |
* or <code>null</code> to construct a new node state | |
* @return builder instance | |
*/ | |
NodeBuilder getNodeBuilder(NodeState base); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment