public class ObjectRule extends Rule
| Constructor and Description |
|---|
ObjectRule() |
ObjectRule(boolean strict) |
| Modifier and Type | Method and Description |
|---|---|
void |
additionalProperties(boolean allowsAdditionalProperties) |
Node |
apply(Node node)
Applies the rule to the node using the following criteria
- if rule does not match returns an ErrorNode and stops processing
- if rule matches, applies rules to children
- if rule contains a NodeFactory, returns the result of it
- else returns node
Only structure rules (
ObjectRule, ArrayRule, KeyValueRule) replace child nodes. |
List<? extends Rule> |
getChildren() |
String |
getDescription()
Returns a description of this rule
|
protected Node |
getResult(Node node) |
List<Suggestion> |
getSuggestions(List<Node> pathToRoot,
ParsingContext context)
Returns the list of suggestions after navigating through the path
|
List<Suggestion> |
getSuggestions(Node node,
ParsingContext context)
Returns the suggestions of this specific rule
|
boolean |
matches(Node node)
Check if the current rule matches the specified node
|
ObjectRule |
named(String ruleName) |
ObjectRule |
then(Class<? extends Node> clazz)
Sets the clazz of the node that is going to be created to replaced the matched node of this rule.
|
ObjectRule |
then(NodeFactory factory)
Sets the factory of the node that is going to be created to replaced the matched node of this rule.
|
ObjectRule |
with(ConditionalRules conditional)
Defines conditional fields based on a condition.
|
ObjectRule |
with(ExclusiveKeys exclusive)
Defines the mutually exclusive fields
|
ObjectRule |
with(int index,
KeyValueRule field)
Adds a field to this object rule at a given order
|
ObjectRule |
with(KeyValueRule field)
Adds a field to this object rule
|
ObjectRule |
withAll(KeyValueRule... fields)
Adds all a field to this object rule
|
cleanFactory, createNodeUsingFactory, getFactory, ruleName, toStringpublic List<? extends Rule> getChildren()
getChildren in class Rulepublic ObjectRule named(String ruleName)
@Nonnull public List<Suggestion> getSuggestions(Node node, ParsingContext context)
RulegetSuggestions in class Rulenode - The nodecontext - The parse contextpublic boolean matches(@Nonnull Node node)
Rule@Nonnull public Node apply(@Nonnull Node node)
RuleObjectRule, ArrayRule, KeyValueRule) replace child nodes.public ObjectRule then(Class<? extends Node> clazz)
Rulepublic ObjectRule then(NodeFactory factory)
Rulepublic ObjectRule with(KeyValueRule field)
field - The field defined to this objectpublic ObjectRule withAll(KeyValueRule... fields)
fields - The fields defined to this objectpublic ObjectRule with(int index, KeyValueRule field)
field - The field defined to this objectindex - the indexpublic List<Suggestion> getSuggestions(List<Node> pathToRoot, ParsingContext context)
RulegetSuggestions in class RulepathToRoot - The path of nodes to get of the node from where we want the suggestionscontext - The parse contextpublic String getDescription()
RulegetDescription in class Rulepublic void additionalProperties(boolean allowsAdditionalProperties)
public ObjectRule with(ConditionalRules conditional)
conditional - The conditional fieldspublic ObjectRule with(ExclusiveKeys exclusive)
exclusive - The exclusive rulesCopyright © 2017. All rights reserved.