#1888: I18nEnum.kt

projectforge-common/src/main/java/org/projectforge/common/i18n/I18nEnum.kt Interface, projectforge-common/.../i18n/I18nEnum.kt 52 lines · 17 code · 30 comments · 5 blank
Marker interface for enums with i18n keys. Provides a companion factory that resolves enum constants by name, with error logging for unmatched values.

Design

Enums implement this interface by providing i18nKey — a localization key used by the UI and history display to translate enum values. The companion factory I18nEnum.create(clazz: Class<*>, value: String?) uses reflection to find the matching enum constant by toString() name comparison, logging a warning if no match is found.

Usage Context

Primarily used by HistoryService and the display-layer converters. When a history entry attribute holds an enum value (e.g., TaskStatus.N), the system uses I18nEnum.create() to reconstruct the enum constant, then reads its i18nKey for localized display.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
365059990 HistoryService and I18nEnum: fix for unknown enum values.
c526c1bbb I18nEnum, IUserRightId -> Kotlin.
7c79f1922 Copyright of source header -> 2020.
dd5ca38ac CopyRight of all java file-header updated or created.
2d86a8cd6 PROJECTFORGE-2306 Refactorings for keeping access check at update time
9ebb88522 Initial commit