Skip to content

Commit

Permalink
update to Java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
mathisdt committed Jun 12, 2019
1 parent 8c7ce1b commit ac8b773
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Expand Down
12 changes: 9 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
language: java

jdk:
- oraclejdk8
- openjdk11

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</scm>

<properties>
<version.java>1.8</version.java>
<version.java>11</version.java>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.class>org.zephyrsoft.hibiscuswatcher.Starter</main.class>

Expand Down
63 changes: 32 additions & 31 deletions src/main/java/org/zephyrsoft/hibiscuswatcher/model/Account.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.zephyrsoft.hibiscuswatcher.model;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Iterator;
Expand All @@ -11,128 +12,128 @@

/**
* A bank account.
*
*
* @author Mathis Dirksen-Thedens
*/
public class Account implements Comparable<Account>, Iterable<Posting> {

private static final int FRACTION_DIGITS = 2;

private String name = "";
private String iban = "";
private String id = "";
private BigDecimal balance = new BigDecimal(0);
private String currency = "";
private String balanceDate = "";
private List<Posting> postings = new LinkedList<>();

public Account(String name, String iban) {
setName(name);
setIban(iban);
}

public boolean addPosting(Posting arg0) {
return postings.add(arg0);
}

public void clearPostings() {
postings.clear();
}

public Posting getPosting(int arg0) {
return postings.get(arg0);
}

public boolean hasPostings() {
return !postings.isEmpty();
}

public int postingsCount() {
return postings.size();
}

public String getDisplayName() {
return name + (nameAndIbanFilled() ? " / " : "") + iban;
}

private boolean nameAndIbanFilled() {
return name != null && !name.isEmpty() && iban != null && !iban.isEmpty();
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getIban() {
return iban;
}

public String getIbanWithoutChecksum() {
return iban == null || iban.length() < 5 ? iban : iban.substring(0, 2) + iban.substring(4);
}

public void setIban(String iban) {
this.iban = iban;
}

public String getID() {
return id;
}

public void setID(String id) {
this.id = id;
}

public BigDecimal getBalance() {
return balance;
}

public String getFormattedBalance() {
return getFormattedBalance(balance, currency);
}

public static String getFormattedBalance(BigDecimal amount, String currency) {
NumberFormat df = new DecimalFormat("0.00");
return df.format(amount.setScale(FRACTION_DIGITS, BigDecimal.ROUND_HALF_UP)) + " " + currency;
return df.format(amount.setScale(FRACTION_DIGITS, RoundingMode.HALF_UP)) + " " + currency;
}

public void setBalance(BigDecimal balance) {
this.balance = balance;
}

public String getCurrency() {
return currency;
}

public void setCurrency(String currency) {
this.currency = currency;
}

public String getBalanceDate() {
return balanceDate;
}

public void setBalanceDate(String balanceDate) {
this.balanceDate = balanceDate;
}

@Override
public int compareTo(Account o) {
return ComparisonChain.start().compare(getName(), o.getName()).compare(getIbanWithoutChecksum(),
o.getIbanWithoutChecksum()).result();
}

@Override
public Iterator<Posting> iterator() {
return postings.iterator();
}

public int getPostingCount() {
return postings.size();
}

}

0 comments on commit ac8b773

Please sign in to comment.