|
5 | 5 | import graphql.util.TraverserContext; |
6 | 6 |
|
7 | 7 | import java.util.ArrayList; |
| 8 | +import java.util.Collections; |
8 | 9 | import java.util.List; |
9 | 10 |
|
10 | 11 | public class DirectiveDefinition extends AbstractNode<DirectiveDefinition> implements Definition<DirectiveDefinition>, NamedNode<DirectiveDefinition> { |
@@ -82,4 +83,59 @@ public String toString() { |
82 | 83 | public TraversalControl accept(TraverserContext<Node> context, NodeVisitor visitor) { |
83 | 84 | return visitor.visitDirectiveDefinition(this, context); |
84 | 85 | } |
| 86 | + |
| 87 | + public static Builder newDirectiveDefinition() { |
| 88 | + return new Builder(); |
| 89 | + } |
| 90 | + |
| 91 | + |
| 92 | + public static final class Builder implements NodeBuilder { |
| 93 | + private SourceLocation sourceLocation; |
| 94 | + private List<Comment> comments = Collections.emptyList(); |
| 95 | + private String name; |
| 96 | + private Description description; |
| 97 | + private List<InputValueDefinition> inputValueDefinitions; |
| 98 | + private List<DirectiveLocation> directiveLocations; |
| 99 | + |
| 100 | + private Builder() { |
| 101 | + } |
| 102 | + |
| 103 | + public Builder sourceLocation(SourceLocation sourceLocation) { |
| 104 | + this.sourceLocation = sourceLocation; |
| 105 | + return this; |
| 106 | + } |
| 107 | + |
| 108 | + public Builder comments(List<Comment> comments) { |
| 109 | + this.comments = comments; |
| 110 | + return this; |
| 111 | + } |
| 112 | + |
| 113 | + public Builder name(String name) { |
| 114 | + this.name = name; |
| 115 | + return this; |
| 116 | + } |
| 117 | + |
| 118 | + public Builder description(Description description) { |
| 119 | + this.description = description; |
| 120 | + return this; |
| 121 | + } |
| 122 | + |
| 123 | + public Builder inputValueDefinitions(List<InputValueDefinition> inputValueDefinitions) { |
| 124 | + this.inputValueDefinitions = inputValueDefinitions; |
| 125 | + return this; |
| 126 | + } |
| 127 | + |
| 128 | + public Builder directiveLocations(List<DirectiveLocation> directiveLocations) { |
| 129 | + this.directiveLocations = directiveLocations; |
| 130 | + return this; |
| 131 | + } |
| 132 | + |
| 133 | + public DirectiveDefinition build() { |
| 134 | + DirectiveDefinition directiveDefinition = new DirectiveDefinition(name, inputValueDefinitions, directiveLocations); |
| 135 | + directiveDefinition.setSourceLocation(sourceLocation); |
| 136 | + directiveDefinition.setComments(comments); |
| 137 | + directiveDefinition.setDescription(description); |
| 138 | + return directiveDefinition; |
| 139 | + } |
| 140 | + } |
85 | 141 | } |
0 commit comments