001/*
002 * Configurate
003 * Copyright (C) zml and Configurate contributors
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.spongepowered.configurate.yaml;
018
019import org.checkerframework.checker.nullness.qual.Nullable;
020import org.yaml.snakeyaml.DumperOptions;
021
022/**
023 * Representation of collections and mappings in a YAML document.
024 *
025 * @since 4.0.0
026 */
027public enum NodeStyle {
028
029    /**
030     * Always use <a href="https://yaml.org/spec/1.1/#id903421">block style</a>.
031     */
032    BLOCK(DumperOptions.FlowStyle.BLOCK),
033
034    /**
035     * Always use <a href="https://yaml.org/spec/1.1/#id902924">flow style</a>.
036     */
037    FLOW(DumperOptions.FlowStyle.FLOW)
038    ;
039
040    private final DumperOptions.FlowStyle snake;
041
042    NodeStyle(final DumperOptions.FlowStyle snake) {
043        this.snake = snake;
044    }
045
046    static DumperOptions.FlowStyle asSnakeYaml(final @Nullable NodeStyle style) {
047        return style == null ? DumperOptions.FlowStyle.AUTO : style.snake;
048    }
049
050}