• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2008, SnakeYAML
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.yaml.snakeyaml.tokens;
15 
16 import java.util.List;
17 import org.yaml.snakeyaml.error.Mark;
18 import org.yaml.snakeyaml.error.YAMLException;
19 
20 public final class DirectiveToken<T> extends Token {
21 
22   private final String name;
23   private final List<T> value;
24 
DirectiveToken(String name, List<T> value, Mark startMark, Mark endMark)25   public DirectiveToken(String name, List<T> value, Mark startMark, Mark endMark) {
26     super(startMark, endMark);
27     this.name = name;
28     if (value != null && value.size() != 2) {
29       throw new YAMLException("Two strings must be provided instead of " + value.size());
30     }
31     this.value = value;
32   }
33 
getName()34   public String getName() {
35     return this.name;
36   }
37 
getValue()38   public List<T> getValue() {
39     return this.value;
40   }
41 
42   @Override
getTokenId()43   public Token.ID getTokenId() {
44     return ID.Directive;
45   }
46 }
47