/
aleksandrazimut
/
TimerCountdownDesktop
Обзор
Документация
Войти
/
aleksandrazimut
/
TimerCountdownDesktop
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/com/timerapp/model/TimerConfig.java
194 строки
7 KB
Aleksandr Azimut
init commit
17 дек 2025, 21:59
17 дек 2025, 21:59
3c602f1
Код
Авторство
О чём код?
package com.timerapp.model; /** * Класс конфигурации таймера с паттерном Builder. * Позволяет гибко настраивать параметры приложения. */ public class TimerConfig { private final String backgroundPath; // Путь к изображению фона private final String iconPath; // Путь к иконке private final String soundPath; // Путь к звуковому файлу private final boolean soundEnabled; // Включен ли звук private final String[] customPresets; // Пользовательские пресеты времени private final String themeName; // Название выбранной темы private final String buttonGradient; // Градиент кнопок private final String buttonColor; // Цвет кнопок (если градиент = None) private final String buttonTextColor; // Цвет текста кнопок private final double buttonOpacity; // Прозрачность кнопок private final String timerTextColor; // Цвет текста таймера private final String progressBarColor; // Цвет прогресс-бара private final int userRating; // Рейтинг пользователя (0-5) // Приватный конструктор для Builder паттерна private TimerConfig(Builder builder) { this.backgroundPath = builder.backgroundPath; this.iconPath = builder.iconPath; this.soundPath = builder.soundPath; this.soundEnabled = builder.soundEnabled; this.customPresets = builder.customPresets; this.themeName = builder.themeName; this.buttonGradient = builder.buttonGradient; this.buttonColor = builder.buttonColor; this.buttonTextColor = builder.buttonTextColor; this.buttonOpacity = builder.buttonOpacity; this.timerTextColor = builder.timerTextColor; this.progressBarColor = builder.progressBarColor; this.userRating = builder.userRating; } // Геттеры public String getBackgroundPath() { return backgroundPath; } public String getIconPath() { return iconPath; } public String getSoundPath() { return soundPath; } public boolean isSoundEnabled() { return soundEnabled; } public String[] getCustomPresets() { return customPresets; } public String getThemeName() { return themeName; } public String getButtonGradient() { return buttonGradient; } public String getButtonColor() { return buttonColor; } public String getButtonTextColor() { return buttonTextColor; } public String getTimerTextColor() { return timerTextColor; } public String getProgressBarColor() { return progressBarColor; } public double getButtonOpacity() { return buttonOpacity; } public int getUserRating() { return userRating; } /** * Builder класс для создания TimerConfig */ public static class Builder { private String backgroundPath = ""; private String iconPath = ""; private String soundPath = ""; private boolean soundEnabled = true; private String[] customPresets = new String[0]; private String themeName = "London"; // По умолчанию тема London private String buttonGradient = "None"; // По умолчанию без градиента private String buttonColor = "#4a5568"; // Серый по умолчанию private String buttonTextColor = "#FFFFFF"; // Белый текст по умолчанию private double buttonOpacity = 1.0; // Полностью непрозрачные private String timerTextColor = "#FFFFFF"; // Белый текст по умолчанию private String progressBarColor = "#4CAF50"; // Зеленый по умолчанию private int userRating = 0; // По умолчанию рейтинг не поставлен public Builder() { // Конструктор по умолчанию } public Builder setBackgroundPath(String backgroundPath) { this.backgroundPath = backgroundPath; return this; } public Builder setIconPath(String iconPath) { this.iconPath = iconPath; return this; } public Builder setSoundPath(String soundPath) { this.soundPath = soundPath; return this; } public Builder setSoundEnabled(boolean soundEnabled) { this.soundEnabled = soundEnabled; return this; } public Builder setCustomPresets(String[] customPresets) { this.customPresets = customPresets; return this; } public Builder setThemeName(String themeName) { this.themeName = themeName; return this; } public Builder setButtonGradient(String buttonGradient) { this.buttonGradient = buttonGradient; return this; } public Builder setButtonColor(String buttonColor) { this.buttonColor = buttonColor; return this; } public Builder setButtonTextColor(String buttonTextColor) { this.buttonTextColor = buttonTextColor; return this; } public Builder setTimerTextColor(String timerTextColor) { this.timerTextColor = timerTextColor; return this; } public Builder setProgressBarColor(String progressBarColor) { this.progressBarColor = progressBarColor; return this; } public Builder setButtonOpacity(double buttonOpacity) { this.buttonOpacity = buttonOpacity; return this; } public Builder setUserRating(int userRating) { this.userRating = userRating; return this; } public TimerConfig build() { return new TimerConfig(this); } } @Override public String toString() { return "TimerConfig{" + "backgroundPath='" + backgroundPath + '\'' + ", soundPath='" + soundPath + '\'' + ", soundEnabled=" + soundEnabled + ", customPresetsCount=" + customPresets.length + ", themeName='" + themeName + '\'' + '}'; } }