#866: StyledTeamCalendar.kt

projectforge-business/src/main/kotlin/org/projectforge/business/calendar/StyledTeamCalendar.kt Type: Data class · Purpose: Calendar with styling · Source: projectforge-business/src/main/kotlin/org/projectforge/business/calendar/StyledTeamCalendar.kt 45 lines · 14 code · 28 comments · 3 blank
Extends TeamCalendar with CalendarStyle (color, appearance) and a visible flag. Used to decorate team calendar objects with rendering metadata for the calendar UI, without modifying the core team calendar model.

Class Hierarchy

StyledTeamCalendar inherits from TeamCalendar (see #862) by passing the parent's id, title, and access through the constructor. This is a Kotlin data-class-like pattern—the class is open but effectively a value wrapper.

PropertyTypeDescription
idLong?Inherited from TeamCalendar
titleString?Inherited from TeamCalendar
accessACCESS?Inherited from TeamCalendar
styleCalendarStyle?Visual style (color etc.) for calendar rendering
visibleBooleanWhether the calendar is visible (default true)

Companion Object

map()

fun map(calendars: List<TeamCalendar>, styleMap: CalendarStyleMap): List<StyledTeamCalendar>

Takes a list of TeamCalendar objects and a CalendarStyleMap keyed by calendar ID. Produces a corresponding list of StyledTeamCalendar instances, each decorated with its style from the map. Uses calendars.find { it.id == cal.id } to look up the matching source calendar for each entry.

Design Rationale

The separation into TeamCalendar (pure data) and StyledTeamCalendar (decorated with UI metadata) follows a clean decorator pattern. The base TeamCalendar class remains unaware of rendering concerns. The CalendarStyleMap lookup is applied in a batch via the companion map function, keeping the transformation logic centralized.

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.
7c79f1922 Copyright of source header -> 2020.
d3a178833 Wrong substitution of "calendar" -> "datetime" while refactoring, reverted commit from 12.12.2019.
8a009b006 StyledTeamCalendar initializes now also access right.
05244ff19 CopyRight of all Kotlin file-header updated or created.
46f71e71a WIP CalendarFilter: moved to business module.