Skip to content

Commit ab6b036

Browse files
add SmartTime.java generated by Xtend 2.20.0
1 parent e1a9368 commit ab6b036

File tree

1 file changed

+71
-56
lines changed

1 file changed

+71
-56
lines changed
Lines changed: 71 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,60 +13,75 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.utplsql.sqldev.ui.runner
16+
package org.utplsql.sqldev.ui.runner;
1717

18-
import java.text.DecimalFormat
18+
import java.text.DecimalFormat;
1919

20-
class SmartTime {
21-
var Double seconds
22-
var boolean smart = false
23-
24-
new() {
25-
super()
26-
}
27-
28-
new(Double seconds, boolean smart) {
29-
super()
30-
this.seconds = seconds
31-
this.smart = smart
32-
}
33-
34-
def setSeconds(Double seconds) {
35-
this.seconds = seconds
36-
}
37-
38-
def setSmart(boolean smart) {
39-
this.smart = smart
40-
}
41-
42-
def getSeconds() {
43-
return seconds
44-
}
45-
46-
override toString() {
47-
var String ret;
48-
if (seconds === null) {
49-
ret = null
50-
} else if (smart) {
51-
if (seconds >= 60*60) {
52-
val DecimalFormat formatter = new DecimalFormat("#0.00")
53-
ret = formatter.format(seconds / 60 / 60) + " h"
54-
} else if (seconds >= 60) {
55-
val DecimalFormat formatter = new DecimalFormat("#0.00")
56-
ret = formatter.format(seconds / 60) + " min"
57-
} else if (seconds >= 1) {
58-
val DecimalFormat formatter = new DecimalFormat("#0.000")
59-
ret = formatter.format(seconds) + " s"
60-
} else {
61-
val DecimalFormat formatter = new DecimalFormat("##0")
62-
ret = formatter.format(seconds * 1000) + " ms"
63-
}
64-
65-
} else {
66-
val DecimalFormat formatter = new DecimalFormat("##,##0.000")
67-
ret = formatter.format(seconds)
68-
}
69-
return ret
70-
}
71-
72-
}
20+
@SuppressWarnings("all")
21+
public class SmartTime {
22+
private Double seconds;
23+
24+
private boolean smart = false;
25+
26+
public SmartTime() {
27+
super();
28+
}
29+
30+
public SmartTime(final Double seconds, final boolean smart) {
31+
super();
32+
this.seconds = seconds;
33+
this.smart = smart;
34+
}
35+
36+
public Double setSeconds(final Double seconds) {
37+
return this.seconds = seconds;
38+
}
39+
40+
public boolean setSmart(final boolean smart) {
41+
return this.smart = smart;
42+
}
43+
44+
public Double getSeconds() {
45+
return this.seconds;
46+
}
47+
48+
@Override
49+
public String toString() {
50+
String ret = null;
51+
if ((this.seconds == null)) {
52+
ret = null;
53+
} else {
54+
if (this.smart) {
55+
if (((this.seconds).doubleValue() >= (60 * 60))) {
56+
final DecimalFormat formatter = new DecimalFormat("#0.00");
57+
String _format = formatter.format((((this.seconds).doubleValue() / 60) / 60));
58+
String _plus = (_format + " h");
59+
ret = _plus;
60+
} else {
61+
if (((this.seconds).doubleValue() >= 60)) {
62+
final DecimalFormat formatter_1 = new DecimalFormat("#0.00");
63+
String _format_1 = formatter_1.format(((this.seconds).doubleValue() / 60));
64+
String _plus_1 = (_format_1 + " min");
65+
ret = _plus_1;
66+
} else {
67+
if (((this.seconds).doubleValue() >= 1)) {
68+
final DecimalFormat formatter_2 = new DecimalFormat("#0.000");
69+
String _format_2 = formatter_2.format(this.seconds);
70+
String _plus_2 = (_format_2 + " s");
71+
ret = _plus_2;
72+
} else {
73+
final DecimalFormat formatter_3 = new DecimalFormat("##0");
74+
String _format_3 = formatter_3.format(((this.seconds).doubleValue() * 1000));
75+
String _plus_3 = (_format_3 + " ms");
76+
ret = _plus_3;
77+
}
78+
}
79+
}
80+
} else {
81+
final DecimalFormat formatter_4 = new DecimalFormat("##,##0.000");
82+
ret = formatter_4.format(this.seconds);
83+
}
84+
}
85+
return ret;
86+
}
87+
}

0 commit comments

Comments
 (0)