Categories: code reformat
This commit is contained in:
parent
cce505f381
commit
46ac54b723
@ -1,17 +1,17 @@
|
||||
package com.baeldung.category;
|
||||
package com.baeldung.category
|
||||
|
||||
class BaeldungCategory {
|
||||
|
||||
public static String capitalize(String self) {
|
||||
String capitalizedStr = self;
|
||||
static String capitalize(String self) {
|
||||
String capitalizedStr = self
|
||||
if (self.size() > 0) {
|
||||
capitalizedStr = self.substring(0, 1).toUpperCase() + self.substring(1);
|
||||
capitalizedStr = self.substring(0, 1).toUpperCase() + self.substring(1)
|
||||
}
|
||||
|
||||
return capitalizedStr
|
||||
}
|
||||
|
||||
public static double toThePower(Number self, Number exponent) {
|
||||
return Math.pow(self, exponent);
|
||||
static double toThePower(Number self, Number exponent) {
|
||||
return Math.pow(self, exponent)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package com.baeldung.category;
|
||||
|
||||
import groovy.lang.Category
|
||||
package com.baeldung.category
|
||||
|
||||
@Category(Number)
|
||||
class NumberCategory {
|
||||
|
||||
public Number cube() {
|
||||
return this*this*this
|
||||
Number cube() {
|
||||
return this**3
|
||||
}
|
||||
|
||||
public int divideWithRoundUp(BigDecimal divisor, boolean isRoundUp) {
|
||||
int divideWithRoundUp(BigDecimal divisor, boolean isRoundUp) {
|
||||
def mathRound = isRoundUp ? BigDecimal.ROUND_UP : BigDecimal.ROUND_DOWN
|
||||
|
||||
return (int) new BigDecimal(this).divide(divisor, 0, mathRound)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.baeldung.category
|
||||
|
||||
import groovy.time.*
|
||||
import groovy.time.TimeCategory
|
||||
import groovy.xml.DOMBuilder
|
||||
import groovy.xml.QName
|
||||
import groovy.xml.dom.DOMCategory
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
import groovy.xml.*
|
||||
import groovy.xml.dom.*
|
||||
import com.baeldung.category.BaeldungCategory
|
||||
import com.baeldung.category.NumberCategory
|
||||
|
||||
class CategoryUnitTest extends GroovyTestCase {
|
||||
|
||||
@ -97,5 +97,4 @@ class CategoryUnitTest extends GroovyTestCase {
|
||||
assert 150.9.divideWithRoundUp(12.1, false) == 12
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user