001/*
002 * Copyright 2017-2022 Product Mog LLC, 2022-2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.lokalized;
018
019import org.jspecify.annotations.NonNull;
020
021import java.util.Arrays;
022import java.util.Collections;
023import java.util.Map;
024import java.util.stream.Collectors;
025
026/**
027 * Language formality forms.
028 *
029 * @author <a href="https://revetkn.com">Mark Allen</a>
030 * @since 1.2.0
031 */
032public enum Formality implements LanguageForm {
033  /**
034   * Casual register.
035   *
036   * @since 2.1.0
037   */
038  CASUAL,
039  /**
040   * Informal register.
041   */
042  INFORMAL,
043  /**
044   * Formal register.
045   */
046  FORMAL,
047  /**
048   * Humble register.
049   *
050   * @since 2.1.0
051   */
052  HUMBLE,
053  /**
054   * Honorific register.
055   */
056  HONORIFIC;
057
058  @NonNull
059  private static final Map<@NonNull String, @NonNull Formality> FORMALITIES_BY_NAME;
060
061  static {
062    FORMALITIES_BY_NAME = Collections.unmodifiableMap(Arrays.stream(
063        Formality.values()).collect(Collectors.toMap(formality -> formality.name(), formality -> formality)));
064  }
065
066  /**
067   * Gets the mapping of formality names to formality values.
068   *
069   * @return the mapping of formality names to formality values, not null
070   */
071  @NonNull
072  static Map<@NonNull String, @NonNull Formality> getFormalitiesByName() {
073    return FORMALITIES_BY_NAME;
074  }
075}