From 66aa4febaa361d2263f699ebdf32f5cf9f48b355 Mon Sep 17 00:00:00 2001 From: Alexander Maletin Date: Sat, 13 Nov 2021 21:48:33 +0500 Subject: [PATCH] Refactored code with Lombok --- lombok.config | 1 + pom.xml | 6 ++++++ src/main/java/ru/netology/domain/Radio.java | 22 +++++---------------- 3 files changed, 12 insertions(+), 17 deletions(-) create mode 100644 lombok.config diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..7a21e88 --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.addLombokGeneratedAnnotation = true diff --git a/pom.xml b/pom.xml index 496c685..111cc52 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,12 @@ 5.8.1 test + + org.projectlombok + lombok + 1.18.22 + provided + diff --git a/src/main/java/ru/netology/domain/Radio.java b/src/main/java/ru/netology/domain/Radio.java index 1c92602..8ddffdb 100644 --- a/src/main/java/ru/netology/domain/Radio.java +++ b/src/main/java/ru/netology/domain/Radio.java @@ -1,5 +1,10 @@ package ru.netology.domain; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Data public class Radio { private int numberOfStations = 10; private int currentStation; @@ -9,9 +14,6 @@ public class Radio { private int maxVolume = 100; private int minVolume = 0; - public Radio() { - } - public Radio(int numberOfStations) { if (numberOfStations > 0) { this.numberOfStations = numberOfStations; @@ -21,10 +23,6 @@ public Radio(int numberOfStations) { } } - public int getNumberOfStations() { - return numberOfStations; - } - public void setNumberOfStations(int numberOfStations) { if (numberOfStations > 0) { this.numberOfStations = numberOfStations; @@ -33,11 +31,6 @@ public void setNumberOfStations(int numberOfStations) { } } - // 1) станции - public int getCurrentStation() { - return currentStation; - } - public void setCurrentStation(int currentStation) { if (currentStation <= maxStation && currentStation >= minStation) { this.currentStation = currentStation; @@ -62,11 +55,6 @@ public void shiftPrevStation() { } } - // 2) звук - public int getCurrentVolume() { - return currentVolume; - } - public void setCurrentVolume(int currentVolume) { if (currentVolume <= maxVolume && currentVolume >= minVolume) { this.currentVolume = currentVolume;