All Downloads are FREE. Search and download functionalities are using the official Maven repository.

objectos.code.internal.Whitespace Maven / Gradle / Ivy

There is a newer version: 0.8.2
Show newest version
/*
 * Copyright (C) 2014-2023 Objectos Software LTDA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package objectos.code.internal;

/**
 * Represents instructions to emit whitespace in the generated Java source code.
 *
 * @since 0.4
 */
public enum Whitespace {

  /**
   * Indicates that a mandatory whitespace must be emitted.
   *
   * 

* For example, in the following field declaration: * *

   * private final String name;
* *

* This instruction would appear immediately after the {@code private}, * {@code final} and {@code String} words. */ MANDATORY, /** * Indicates that a whitespace is typically emitted though it is not strictly * required. * *

* For example, in the following assignment operator expression: * *

   * a = b
* *

* The spaces around the {@code =} operator are optional. */ OPTIONAL, /** * Indicates that an user-provided line separator must be emitted. */ NEW_LINE, /** * Indicates that the next language construct comes after a declaration * annotation. * *

* In the following method declaration: * *

   * @A
   * @B
   * public @Nullable String method() {
   *   ...
   * }
* *

* This instruction would appear after annotations {@code A} and {@code B}. * On the other hand, the instruction would not appear after the * annotation {@code Nullable}. */ AFTER_ANNOTATION, /** * Indicates that the first construct of a line will be written in the next * instruction. * *

* It is typically used to indicate that indentation, if any, should be * emitted. */ BEFORE_FIRST_LINE_CONTENT, /** * Indicates that the first member of a declaration will be written in the * next instructions. * *

* For example, in the following enum declaration: * *

   * enum Example {
   *   FOO;
   * }
* *

* This instruction would appear immediately after the opening right curly * bracket of the enum's body. */ BEFORE_FIRST_MEMBER, /** * Indicates that a member other than the first one will be written in the * next instructions. * *

* For example, in the following enum declaration: * *

   * enum Example {
   *   ONE,
   *
   *   TWO,
   *
   *   THREE;
   * }
* *

* This instruction would appear immediately after the two commas. */ BEFORE_NEXT_MEMBER, /** * Indicates that a Java statement is about to be written. * *

* For example, in the following method declaration: * *

   * void method() {
   *   a();
   *   b();
   *   c();
   * }
* *

* This instruction would appear before each of the method invocations. */ BEFORE_NEXT_STATEMENT, /** * Indicates that the next construct comes after a comma of a comma * separated list. * *

* For example, in the following method invocation expression: * *

   * foo(1, 2, 3)
* *

* This instruction would appear immediately before the values {@code 2} and * {@code 3}. */ BEFORE_NEXT_COMMA_SEPARATED_ITEM, /** * Indicates that closing right curly bracket of a non-empty body or block is * about to be emitted. */ BEFORE_NON_EMPTY_BLOCK_END, /** * Indicates that closing right curly bracket of an empty body or block is * about to be emitted. */ BEFORE_EMPTY_BLOCK_END; private static final Whitespace[] VALUES = values(); static Whitespace get(int index) { return VALUES[index]; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy