• 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.events;
15 
16 /**
17  * The implicit flag of a scalar event is a pair of boolean values that indicate if the tag may be
18  * omitted when the scalar is emitted in a plain and non-plain style correspondingly.
19  *
20  * @see <a href="http://pyyaml.org/wiki/PyYAMLDocumentation#Events">Events</a>
21  */
22 public class ImplicitTuple {
23 
24   private final boolean plain;
25   private final boolean nonPlain;
26 
ImplicitTuple(boolean plain, boolean nonplain)27   public ImplicitTuple(boolean plain, boolean nonplain) {
28     this.plain = plain;
29     this.nonPlain = nonplain;
30   }
31 
32   /**
33    * @return true when tag may be omitted when the scalar is emitted in a plain style.
34    */
canOmitTagInPlainScalar()35   public boolean canOmitTagInPlainScalar() {
36     return plain;
37   }
38 
39   /**
40    * @return true when tag may be omitted when the scalar is emitted in a non-plain style.
41    */
canOmitTagInNonPlainScalar()42   public boolean canOmitTagInNonPlainScalar() {
43     return nonPlain;
44   }
45 
bothFalse()46   public boolean bothFalse() {
47     return !plain && !nonPlain;
48   }
49 
50   @Override
toString()51   public String toString() {
52     return "implicit=[" + plain + ", " + nonPlain + "]";
53   }
54 }
55