Skip to content

Commit 12b88e3

Browse files
ngonzalezpazFCjavier-godoy
authored andcommitted
style: fix code smells
1 parent b1a68d0 commit 12b88e3

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/main/java/com/flowingcode/vaadin/addons/simpletimer/SimpleTimer.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
import com.vaadin.flow.dom.PropertyChangeListener;
3737
import com.vaadin.flow.shared.Registration;
3838
import java.io.Serializable;
39+
import java.math.BigDecimal;
40+
import java.util.concurrent.CompletableFuture;
41+
import java.util.concurrent.TimeUnit;
3942

4043
/**
4144
* @author Leonardo Scardanzan / Flowing Code
@@ -45,12 +48,16 @@
4548
public class SimpleTimer extends Component implements HasSize, HasStyle, Serializable {
4649

4750
private static final long serialVersionUID = 1L;
51+
private static final int START_TIME_S = 60;
52+
private static final String DISPLAY = "display";
53+
private static final String INLINE = "inline";
54+
private static final String CURRENT_TIME = "currentTime";
4855

4956
/**
5057
* Creates a timer with a start time of 60
5158
*/
5259
public SimpleTimer() {
53-
this(60);
60+
this(START_TIME_S);
5461
}
5562

5663
/**
@@ -59,7 +66,7 @@ public SimpleTimer() {
5966
* @param startTime value in seconds for the start time
6067
*/
6168
public SimpleTimer(final Number startTime) {
62-
getElement().getStyle().set("display", "inline");
69+
getElement().getStyle().set(DISPLAY, INLINE);
6370
setStartTime(startTime);
6471
}
6572

@@ -70,7 +77,7 @@ public SimpleTimer(final Number startTime) {
7077
*/
7178
public void setStartTime(final Number startTime) {
7279
getElement().setProperty("startTime", startTime.doubleValue());
73-
getElement().setProperty("currentTime", startTime.doubleValue());
80+
getElement().setProperty(CURRENT_TIME, startTime.doubleValue());
7481
reset();
7582
}
7683

@@ -150,7 +157,7 @@ public boolean isRunning() {
150157
*/
151158
@Synchronize("is-running-changed")
152159
public BigDecimal getCurrentTime() {
153-
return BigDecimal.valueOf(getElement().getProperty("currentTime", 0d));
160+
return BigDecimal.valueOf(getElement().getProperty(CURRENT_TIME, 0d));
154161
}
155162

156163
/**
@@ -175,7 +182,7 @@ public Registration addCurrentTimeChangeListener(PropertyChangeListener listener
175182
listener = ev -> {
176183
};
177184
}
178-
return getElement().addPropertyChangeListener("currentTime", "current-time-changed", listener).throttle(millis);
185+
return getElement().addPropertyChangeListener(CURRENT_TIME, "current-time-changed", listener).throttle(millis);
179186
}
180187

181188
/**
@@ -203,12 +210,12 @@ public Registration addTimerEndEvent(final ComponentEventListener<TimerEndedEven
203210

204211
@Override
205212
public boolean isVisible() {
206-
return getStyle().get("display").equals("inline");
213+
return getStyle().get(DISPLAY).equals(INLINE);
207214
}
208215

209216
@Override
210217
public void setVisible(boolean visible) {
211-
getStyle().set("display",visible?"inline":"none");
218+
getStyle().set(DISPLAY,visible?INLINE:"none");
212219
}
213220

214221
}

0 commit comments

Comments
 (0)