• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Google Inc.
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 
15 package com.google.googlejavaformat;
16 
17 import com.google.common.base.MoreObjects;
18 
19 /**
20  * A {@code CloseOp} closes a level. It is an {@link Op} in the sequence of {@link Op}s generated by
21  * {@link OpsBuilder}. When the sequence is turned into a {@link Doc} by {@link DocBuilder}, ranges
22  * delimited by {@link OpenOp}-{@code CloseOp} pairs turn into nested {@link Doc.Level}s.
23  */
24 public enum CloseOp implements Op {
25   CLOSE;
26 
27   /**
28    * Make a {@code CloseOp}, returning a singleton since they are all the same.
29    *
30    * @return the singleton {@code CloseOp}
31    */
make()32   public static Op make() {
33     return CLOSE;
34   }
35 
36   @Override
add(DocBuilder builder)37   public void add(DocBuilder builder) {
38     builder.close();
39   }
40 
41   @Override
toString()42   public String toString() {
43     return MoreObjects.toStringHelper(this).toString();
44   }
45 }
46