From 3ba4660bbbd05e1d97edd4af9c71cf907eeb6e2a Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Tue, 8 Mar 2016 18:33:32 +1300 Subject: [PATCH] No effective change - format code --- .../com/avaje/tests/model/ivo/CMoney.java | 29 ++- .../tests/model/ivo/ExhangeCMoneyRate.java | 65 +++--- .../java/com/avaje/tests/model/ivo/Money.java | 211 +++++++++--------- .../java/com/avaje/tests/model/ivo/Oid.java | 60 ++--- .../java/com/avaje/tests/model/ivo/Rate.java | 190 ++++++++-------- .../com/avaje/tests/model/ivo/Segment.java | 24 +- .../tests/model/ivo/SimpleKnownImmutable.java | 42 ++-- .../com/avaje/tests/model/ivo/SysTime.java | 18 +- .../tests/model/ivo/TestCheckImmutable.java | 15 +- 9 files changed, 325 insertions(+), 329 deletions(-) diff --git a/src/test/java/com/avaje/tests/model/ivo/CMoney.java b/src/test/java/com/avaje/tests/model/ivo/CMoney.java index 011107317..a764d8696 100644 --- a/src/test/java/com/avaje/tests/model/ivo/CMoney.java +++ b/src/test/java/com/avaje/tests/model/ivo/CMoney.java @@ -4,25 +4,24 @@ import java.util.Currency; /** * Currency and Money. - * - * @author rbygrave * + * @author rbygrave */ public class CMoney { - private final Money amount; - private final Currency currency; - - public CMoney(Money amount, Currency currency) { - this.amount = amount; - this.currency = currency; - } + private final Money amount; + private final Currency currency; - public Money getAmount() { - return amount; - } + public CMoney(Money amount, Currency currency) { + this.amount = amount; + this.currency = currency; + } - public Currency getCurrency() { - return currency; - } + public Money getAmount() { + return amount; + } + + public Currency getCurrency() { + return currency; + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/ExhangeCMoneyRate.java b/src/test/java/com/avaje/tests/model/ivo/ExhangeCMoneyRate.java index 00634d1de..c267e43f3 100644 --- a/src/test/java/com/avaje/tests/model/ivo/ExhangeCMoneyRate.java +++ b/src/test/java/com/avaje/tests/model/ivo/ExhangeCMoneyRate.java @@ -1,4 +1,3 @@ - package com.avaje.tests.model.ivo; /** @@ -6,42 +5,42 @@ package com.avaje.tests.model.ivo; */ public class ExhangeCMoneyRate { - private final Rate rate; - private final CMoney cmoney; - - public ExhangeCMoneyRate(Rate rate, CMoney cmoney) { - this.rate = rate; - this.cmoney = cmoney; - } + private final Rate rate; + private final CMoney cmoney; - public Rate getRate() { - return rate; - } + public ExhangeCMoneyRate(Rate rate, CMoney cmoney) { + this.rate = rate; + this.cmoney = cmoney; + } - public CMoney getCmoney() { - return cmoney; - } + public Rate getRate() { + return rate; + } - @Override - public boolean equals(Object obj) { - if (obj instanceof ExhangeCMoneyRate){ - ExhangeCMoneyRate e = (ExhangeCMoneyRate)obj; - return e.rate.equals(rate) && e.cmoney.equals(cmoney); - } - return false; - } + public CMoney getCmoney() { + return cmoney; + } - @Override - public int hashCode() { - int hc = rate.hashCode(); - hc = hc * 31 + cmoney.hashCode(); - return hc; + @Override + public boolean equals(Object obj) { + if (obj instanceof ExhangeCMoneyRate) { + ExhangeCMoneyRate e = (ExhangeCMoneyRate) obj; + return e.rate.equals(rate) && e.cmoney.equals(cmoney); } + return false; + } + + @Override + public int hashCode() { + int hc = rate.hashCode(); + hc = hc * 31 + cmoney.hashCode(); + return hc; + } + + @Override + public String toString() { + return "rate=" + rate + " cmoney=" + cmoney; + } + - @Override - public String toString() { - return "rate="+rate+" cmoney="+cmoney; - } - - } diff --git a/src/test/java/com/avaje/tests/model/ivo/Money.java b/src/test/java/com/avaje/tests/model/ivo/Money.java index cabb85a94..0bcf3f002 100644 --- a/src/test/java/com/avaje/tests/model/ivo/Money.java +++ b/src/test/java/com/avaje/tests/model/ivo/Money.java @@ -9,134 +9,133 @@ import java.util.Iterator; /** * A representation of Money effectively wrapping BigDecimal. *

- * + *

*

- * @author rbygrave * + * @author rbygrave */ public final class Money implements Comparable, Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public static final Money ZERO = new Money(BigDecimal.ZERO); - - private final BigDecimal amount; - - public Money(BigDecimal amount) { - if (amount == null){ - throw new NullPointerException("amount can not be null"); - } - this.amount = amount; - } + public static final Money ZERO = new Money(BigDecimal.ZERO); - public Money(double val) { - this(BigDecimal.valueOf(val)); - } + private final BigDecimal amount; - public Money(String val) { - this(new BigDecimal(val)); + public Money(BigDecimal amount) { + if (amount == null) { + throw new NullPointerException("amount can not be null"); } + this.amount = amount; + } - public String toString() { - return amount.toString(); - } - - - - @Override - public int hashCode() { - return amount.hashCode(); - } + public Money(double val) { + this(BigDecimal.valueOf(val)); + } - @Override - public boolean equals(Object obj) { - if (obj instanceof Money){ - // use BigDecimal.compareTo to handle scale differences - return amount.compareTo(((Money)obj).getAmount()) == 0; - } - return false; - } + public Money(String val) { + this(new BigDecimal(val)); + } - public int compareTo(Money o) { - return amount.compareTo(o.amount); - } + public String toString() { + return amount.toString(); + } - public BigDecimal getAmount() { - return amount; - } - - public Money subtract(Money amt){ - BigDecimal b = amount.subtract(amt.amount); - return new Money(b); - } - - public Money subtract(Money amt, MathContext ctx){ - BigDecimal b = amount.subtract(amt.amount, ctx); - return new Money(b); - } - - public Money add(Money amt){ - BigDecimal b = amount.add(amt.amount); - return new Money(b); - } - public Money add(Money amt, MathContext ctx){ - BigDecimal b = amount.add(amt.amount, ctx); - return new Money(b); - } + @Override + public int hashCode() { + return amount.hashCode(); + } - public Money multiply(Money m){ - return multiply(m.amount); + @Override + public boolean equals(Object obj) { + if (obj instanceof Money) { + // use BigDecimal.compareTo to handle scale differences + return amount.compareTo(((Money) obj).getAmount()) == 0; } + return false; + } - public Money multiply(int val){ - return multiply(BigDecimal.valueOf(val)); - } + public int compareTo(Money o) { + return amount.compareTo(o.amount); + } - public Money multiply(float val){ - return multiply(BigDecimal.valueOf(val)); - } + public BigDecimal getAmount() { + return amount; + } - public Money multiply(double val){ - return multiply(BigDecimal.valueOf(val)); - } - - public Money multiply(BigDecimal m){ - BigDecimal b = amount.multiply(m); - return new Money(b); - } + public Money subtract(Money amt) { + BigDecimal b = amount.subtract(amt.amount); + return new Money(b); + } - public Money divide(BigDecimal divisor){ - BigDecimal b = amount.divide(divisor); - return new Money(b); - } - - public Money divide(BigDecimal divisor, MathContext ctx){ - BigDecimal b = amount.divide(divisor, ctx); - return new Money(b); - } + public Money subtract(Money amt, MathContext ctx) { + BigDecimal b = amount.subtract(amt.amount, ctx); + return new Money(b); + } - public static Money sum(Money... m){ - BigDecimal t = BigDecimal.ZERO; - for (Money money : m) { - t = t.add(money.amount); - } - return new Money(t); + public Money add(Money amt) { + BigDecimal b = amount.add(amt.amount); + return new Money(b); + } + + public Money add(Money amt, MathContext ctx) { + BigDecimal b = amount.add(amt.amount, ctx); + return new Money(b); + } + + public Money multiply(Money m) { + return multiply(m.amount); + } + + public Money multiply(int val) { + return multiply(BigDecimal.valueOf(val)); + } + + public Money multiply(float val) { + return multiply(BigDecimal.valueOf(val)); + } + + public Money multiply(double val) { + return multiply(BigDecimal.valueOf(val)); + } + + public Money multiply(BigDecimal m) { + BigDecimal b = amount.multiply(m); + return new Money(b); + } + + public Money divide(BigDecimal divisor) { + BigDecimal b = amount.divide(divisor); + return new Money(b); + } + + public Money divide(BigDecimal divisor, MathContext ctx) { + BigDecimal b = amount.divide(divisor, ctx); + return new Money(b); + } + + public static Money sum(Money... m) { + BigDecimal t = BigDecimal.ZERO; + for (Money money : m) { + t = t.add(money.amount); } - - public static Money sum(Iterator it){ - BigDecimal t = BigDecimal.ZERO; - while (it.hasNext()) { - t = t.add(it.next().amount); - } - return new Money(t); + return new Money(t); + } + + public static Money sum(Iterator it) { + BigDecimal t = BigDecimal.ZERO; + while (it.hasNext()) { + t = t.add(it.next().amount); } - - public static Money sum(Iterator it, MathContext ctx){ - BigDecimal t = BigDecimal.ZERO; - while (it.hasNext()) { - t = t.add(it.next().amount, ctx); - } - return new Money(t); + return new Money(t); + } + + public static Money sum(Iterator it, MathContext ctx) { + BigDecimal t = BigDecimal.ZERO; + while (it.hasNext()) { + t = t.add(it.next().amount, ctx); } + return new Money(t); + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/Oid.java b/src/test/java/com/avaje/tests/model/ivo/Oid.java index b28f4a3ed..6d8ebf808 100644 --- a/src/test/java/com/avaje/tests/model/ivo/Oid.java +++ b/src/test/java/com/avaje/tests/model/ivo/Oid.java @@ -3,43 +3,43 @@ package com.avaje.tests.model.ivo; public class Oid { - private final long value; + private final long value; - public Oid(long value) { - this.value = value; - } + public Oid(long value) { + this.value = value; + } - public String toString() { - return String.valueOf(value); - } + public String toString() { + return String.valueOf(value); + } - public long getValue() { - return value; - } + public long getValue() { + return value; + } - @Override - public int hashCode() { - return (int) (value ^ (value >>> 32)); - } + @Override + public int hashCode() { + return (int) (value ^ (value >>> 32)); + } - @Override - public boolean equals(Object o) { - if (o instanceof Oid) { - return ((Oid) o).value == value; - } - return false; + @Override + public boolean equals(Object o) { + if (o instanceof Oid) { + return ((Oid) o).value == value; } + return false; + } - public static Oid valueOf(String s) { - return new Oid(Integer.valueOf(s)); - } + public static Oid valueOf(String s) { + return new Oid(Integer.valueOf(s)); + } - public static Oid valueOf(long i) { - return new Oid(i); - } + public static Oid valueOf(long i) { + return new Oid(i); + } - public static Oid valueOf(Class cls, String s) { - Integer v = Integer.valueOf(s); - return new Oid(v); - } + public static Oid valueOf(Class cls, String s) { + Integer v = Integer.valueOf(s); + return new Oid(v); + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/Rate.java b/src/test/java/com/avaje/tests/model/ivo/Rate.java index 9cdbd8521..4523fd604 100644 --- a/src/test/java/com/avaje/tests/model/ivo/Rate.java +++ b/src/test/java/com/avaje/tests/model/ivo/Rate.java @@ -15,120 +15,120 @@ import java.math.MathContext; * Rates are typically used to multiple or divide against an amount. * For example, you can't ADD a Rate to Money. *

- * @author rbygrave * + * @author rbygrave */ public final class Rate implements Comparable, Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public static final Rate ZERO = new Rate(BigDecimal.ZERO); - public static final Rate ONE = new Rate(BigDecimal.ONE); - - private final BigDecimal value; - - public Rate(BigDecimal value) { - if (value == null){ - throw new NullPointerException("value can not be null"); - } - this.value = value; - } + public static final Rate ZERO = new Rate(BigDecimal.ZERO); + public static final Rate ONE = new Rate(BigDecimal.ONE); - public Rate(double val) { - this(BigDecimal.valueOf(val)); - } + private final BigDecimal value; - public Rate(String val) { - this(new BigDecimal(val)); + public Rate(BigDecimal value) { + if (value == null) { + throw new NullPointerException("value can not be null"); } + this.value = value; + } - public String toString() { - return value.toString(); - } - - public int compareTo(Rate o) { - return value.compareTo(o.value); - } - - @Override - public int hashCode() { - return value.hashCode(); - } + public Rate(double val) { + this(BigDecimal.valueOf(val)); + } - @Override - public boolean equals(Object obj) { - if (obj instanceof Rate){ - // use BigDecimal.compareTo to handle scale differences - return value.compareTo(((Rate)obj).getValue()) == 0; - } - return false; - } + public Rate(String val) { + this(new BigDecimal(val)); + } - public BigDecimal getValue() { - return value; - } - - public Rate subtract(Rate amt){ - BigDecimal b = value.subtract(amt.value); - return new Rate(b); - } - - public Rate subtract(Rate amt, MathContext ctx){ - BigDecimal b = value.subtract(amt.value, ctx); - return new Rate(b); - } - - public Rate add(Rate amt){ - BigDecimal b = value.add(amt.value); - return new Rate(b); - } + public String toString() { + return value.toString(); + } - public Rate add(Rate amt, MathContext ctx){ - BigDecimal b = value.add(amt.value, ctx); - return new Rate(b); - } + public int compareTo(Rate o) { + return value.compareTo(o.value); + } - /** - * A Rate times Money amount returns Money. - */ - public Money times(Money amount){ - return multiply(amount); - } + @Override + public int hashCode() { + return value.hashCode(); + } - public Money multiply(Money amount){ - BigDecimal b = value.multiply(amount.getAmount()); - return new Money(b); + @Override + public boolean equals(Object obj) { + if (obj instanceof Rate) { + // use BigDecimal.compareTo to handle scale differences + return value.compareTo(((Rate) obj).getValue()) == 0; } + return false; + } - public Rate multiply(Rate m){ - return multiply(m.value); - } + public BigDecimal getValue() { + return value; + } - public Rate multiply(int val){ - return multiply(BigDecimal.valueOf(val)); - } + public Rate subtract(Rate amt) { + BigDecimal b = value.subtract(amt.value); + return new Rate(b); + } - public Rate multiply(float val){ - return multiply(BigDecimal.valueOf(val)); - } + public Rate subtract(Rate amt, MathContext ctx) { + BigDecimal b = value.subtract(amt.value, ctx); + return new Rate(b); + } - public Rate multiply(double val){ - return multiply(BigDecimal.valueOf(val)); - } - - public Rate multiply(BigDecimal m){ - BigDecimal b = value.multiply(m); - return new Rate(b); - } + public Rate add(Rate amt) { + BigDecimal b = value.add(amt.value); + return new Rate(b); + } - public Rate divide(BigDecimal divisor){ - BigDecimal b = value.divide(divisor); - return new Rate(b); - } - - public Rate divide(BigDecimal divisor, MathContext ctx){ - BigDecimal b = value.divide(divisor, ctx); - return new Rate(b); - } + public Rate add(Rate amt, MathContext ctx) { + BigDecimal b = value.add(amt.value, ctx); + return new Rate(b); + } + + /** + * A Rate times Money amount returns Money. + */ + public Money times(Money amount) { + return multiply(amount); + } + + public Money multiply(Money amount) { + BigDecimal b = value.multiply(amount.getAmount()); + return new Money(b); + } + + public Rate multiply(Rate m) { + return multiply(m.value); + } + + public Rate multiply(int val) { + return multiply(BigDecimal.valueOf(val)); + } + + public Rate multiply(float val) { + return multiply(BigDecimal.valueOf(val)); + } + + public Rate multiply(double val) { + return multiply(BigDecimal.valueOf(val)); + } + + public Rate multiply(BigDecimal m) { + BigDecimal b = value.multiply(m); + return new Rate(b); + } + + public Rate divide(BigDecimal divisor) { + BigDecimal b = value.divide(divisor); + return new Rate(b); + } + + public Rate divide(BigDecimal divisor, MathContext ctx) { + BigDecimal b = value.divide(divisor, ctx); + return new Rate(b); + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/Segment.java b/src/test/java/com/avaje/tests/model/ivo/Segment.java index 0329f0169..53557ba5d 100644 --- a/src/test/java/com/avaje/tests/model/ivo/Segment.java +++ b/src/test/java/com/avaje/tests/model/ivo/Segment.java @@ -5,18 +5,18 @@ package com.avaje.tests.model.ivo; */ public class Segment { - private final String code; - - public Segment(String code){ - this.code = code; - } + private final String code; - public String getCode() { - return code; - } + public Segment(String code) { + this.code = code; + } + + public String getCode() { + return code; + } + + public String toString() { + return code; + } - public String toString() { - return code; - } - } diff --git a/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java b/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java index e0acb6340..e96f6839f 100644 --- a/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java +++ b/src/test/java/com/avaje/tests/model/ivo/SimpleKnownImmutable.java @@ -4,27 +4,27 @@ import com.avaje.ebeaninternal.server.type.reflect.KnownImmutable; public class SimpleKnownImmutable implements KnownImmutable { - public boolean isKnownImmutable(Class cls) { - - // Check for all allowed property types... - if (cls.isPrimitive() || String.class.equals(cls) || Object.class.equals(cls)) { - return true; - } - if (java.util.Date.class.equals(cls) || java.sql.Date.class.equals(cls) || java.sql.Timestamp.class.equals(cls)) { - // treat as immutable even through they are not strictly so - return true; - } - if (java.math.BigDecimal.class.equals(cls) || java.math.BigInteger.class.equals(cls)) { - // treat as immutable (contain non-final fields) - return true; - } + public boolean isKnownImmutable(Class cls) { - if (Integer.class.equals(cls) || Long.class.equals(cls) || Double.class.equals(cls) || Float.class.equals(cls) - || Short.class.equals(cls) || Byte.class.equals(cls) || Character.class.equals(cls) - || Boolean.class.equals(cls)) { - return true; - } - - return false; + // Check for all allowed property types... + if (cls.isPrimitive() || String.class.equals(cls) || Object.class.equals(cls)) { + return true; } + if (java.util.Date.class.equals(cls) || java.sql.Date.class.equals(cls) || java.sql.Timestamp.class.equals(cls)) { + // treat as immutable even through they are not strictly so + return true; + } + if (java.math.BigDecimal.class.equals(cls) || java.math.BigInteger.class.equals(cls)) { + // treat as immutable (contain non-final fields) + return true; + } + + if (Integer.class.equals(cls) || Long.class.equals(cls) || Double.class.equals(cls) || Float.class.equals(cls) + || Short.class.equals(cls) || Byte.class.equals(cls) || Character.class.equals(cls) + || Boolean.class.equals(cls)) { + return true; + } + + return false; + } } diff --git a/src/test/java/com/avaje/tests/model/ivo/SysTime.java b/src/test/java/com/avaje/tests/model/ivo/SysTime.java index 0d5e5460f..b3264aeaf 100644 --- a/src/test/java/com/avaje/tests/model/ivo/SysTime.java +++ b/src/test/java/com/avaje/tests/model/ivo/SysTime.java @@ -2,14 +2,14 @@ package com.avaje.tests.model.ivo; public class SysTime { - private final long millis; - - public SysTime(long millis){ - this.millis = millis; - } + private final long millis; + + public SysTime(long millis) { + this.millis = millis; + } + + public long getMillis() { + return millis; + } - public long getMillis() { - return millis; - } - } diff --git a/src/test/java/com/avaje/tests/model/ivo/TestCheckImmutable.java b/src/test/java/com/avaje/tests/model/ivo/TestCheckImmutable.java index cc91d7311..ae1f5a24e 100644 --- a/src/test/java/com/avaje/tests/model/ivo/TestCheckImmutable.java +++ b/src/test/java/com/avaje/tests/model/ivo/TestCheckImmutable.java @@ -1,18 +1,17 @@ package com.avaje.tests.model.ivo; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.util.Currency; - -import org.junit.Assert; -import org.junit.Test; - import com.avaje.ebean.BaseTestCase; import com.avaje.ebeaninternal.server.type.reflect.CheckImmutable; import com.avaje.ebeaninternal.server.type.reflect.CheckImmutableResponse; import com.avaje.ebeaninternal.server.type.reflect.ImmutableMeta; import com.avaje.ebeaninternal.server.type.reflect.ImmutableMetaFactory; +import org.junit.Assert; +import org.junit.Test; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.util.Currency; public class TestCheckImmutable extends BaseTestCase {