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 * Definiteness forms.
028 *
029 * @author <a href="https://revetkn.com">Mark Allen</a>
030 * @since 2.1.0
031 */
032public enum Definiteness implements LanguageForm {
033  /**
034   * Definite form, such as "the book" or Arabic nouns with the definite article.
035   */
036  DEFINITE,
037  /**
038   * Indefinite form, such as "a book".
039   */
040  INDEFINITE,
041  /**
042   * Construct or bound-state form used by languages such as Arabic and Hebrew.
043   */
044  CONSTRUCT;
045
046  @NonNull
047  private static final Map<@NonNull String, @NonNull Definiteness> DEFINITENESS_BY_NAME;
048
049  static {
050    DEFINITENESS_BY_NAME = Collections.unmodifiableMap(Arrays.stream(
051        Definiteness.values()).collect(Collectors.toMap(definiteness -> definiteness.name(), definiteness -> definiteness)));
052  }
053
054  /**
055   * Gets the mapping of definiteness names to definiteness values.
056   *
057   * @return the mapping of definiteness names to definiteness values, not null
058   */
059  @NonNull
060  static Map<@NonNull String, @NonNull Definiteness> getDefinitenessByName() {
061    return DEFINITENESS_BY_NAME;
062  }
063}