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 gender forms. 028 * 029 * @author <a href="https://revetkn.com">Mark Allen</a> 030 */ 031public enum Gender implements LanguageForm { 032 /** 033 * Masculine gender. 034 */ 035 MASCULINE, 036 /** 037 * Feminine gender. 038 */ 039 FEMININE, 040 /** 041 * Common gender (masculine + feminine), e.g. Swedish/Danish/Dutch "en" words. 042 */ 043 COMMON, 044 /** 045 * Neutral/unspecified gender. 046 */ 047 NEUTER; 048 049 @NonNull 050 private static final Map<@NonNull String, @NonNull Gender> GENDERS_BY_NAME; 051 052 static { 053 GENDERS_BY_NAME = Collections.unmodifiableMap(Arrays.stream( 054 Gender.values()).collect(Collectors.toMap(gender -> gender.name(), gender -> gender))); 055 } 056 057 /** 058 * Gets the mapping of gender names to gender values. 059 * 060 * @return the mapping of gender names to gender values, not null 061 */ 062 @NonNull 063 static Map<@NonNull String, @NonNull Gender> getGendersByName() { 064 return GENDERS_BY_NAME; 065 } 066}