From b58c1dd43952b428392b0f1e222f8bf89c5f793f Mon Sep 17 00:00:00 2001 From: Andreas Buchen Date: Sun, 23 Feb 2014 20:52:35 +0100 Subject: [PATCH] Removed obsolete code, fixed some issues reported by Sonar --- .../portfolio/ui/util/CellEditorFactory.java | 2 +- .../security/DividendTransaction.java | 50 +----------------- .../security/SecurityPerformanceRecord.java | 2 +- .../security/SecurityPerformanceSnapshot.java | 51 ++++++++----------- 4 files changed, 23 insertions(+), 82 deletions(-) diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/CellEditorFactory.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/CellEditorFactory.java index 0bc2855fbd..b2e3a24e81 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/CellEditorFactory.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/CellEditorFactory.java @@ -309,7 +309,7 @@ public void apply() private interface Modifier { - static final Object UNMODIFIED = new Object(); + Object UNMODIFIED = new Object(); Object getValue(Object element) throws Exception; diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/DividendTransaction.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/DividendTransaction.java index f2c64d5779..43cf6d6efc 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/DividendTransaction.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/DividendTransaction.java @@ -13,9 +13,6 @@ public class DividendTransaction extends Transaction private long fifoCost; - private boolean isDiv12; - private int divEventId; - public DividendTransaction() {} @@ -70,27 +67,7 @@ public double getPersonalDividendYield() return amount / (double) fifoCost; } - public boolean getIsDiv12() - { - return isDiv12; - } - - public void setIsDiv12(boolean isDiv12) - { - this.isDiv12 = isDiv12; - } - - public int getDivEventId() - { - return divEventId; - } - - public void setDivEventId(int divEventId) - { - this.divEventId = divEventId; - } - - static public long amountFractionPerShare(long amount, long shares) + static long amountFractionPerShare(long amount, long shares) { if (shares == 0) return 0; @@ -98,29 +75,4 @@ static public long amountFractionPerShare(long amount, long shares) return Math.round((double) (amount * (Values.AmountFraction.factor() / Values.Amount.factor()) * Values.Share .divider()) / (double) shares); } - - static public long amountPerShare(long amount, long shares) - { - if (shares != 0) - { - return Math.round((double) amount / (double) shares * Values.Share.divider()); - } - else - { - return 0; - } - } - - static public long amountTimesShares(long price, long shares) - { - if (shares != 0) - { - return Math.round((double) price * (double) shares / Values.Share.divider()); - } - else - { - return 0; - } - } - } diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceRecord.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceRecord.java index 737654afc4..88ff48c1f3 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceRecord.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceRecord.java @@ -13,7 +13,7 @@ import name.abuchen.portfolio.snapshot.PerformanceIndex; import name.abuchen.portfolio.snapshot.ReportingPeriod; -public class SecurityPerformanceRecord implements Adaptable +public final class SecurityPerformanceRecord implements Adaptable { public enum Periodicity { diff --git a/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceSnapshot.java b/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceSnapshot.java index a85694f172..336d24c529 100644 --- a/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceSnapshot.java +++ b/name.abuchen.portfolio/src/name/abuchen/portfolio/snapshot/security/SecurityPerformanceSnapshot.java @@ -91,37 +91,26 @@ private static void extractSecurityRelatedAccountTransactions(Account account, D { for (AccountTransaction t : account.getTransactions()) { - if (t.getDate().getTime() > startDate.getTime() && t.getDate().getTime() <= endDate.getTime()) - { - switch (t.getType()) - { - case INTEREST: - case DIVIDENDS: - if (t.getSecurity() != null) - { - DividendTransaction dt = new DividendTransaction(); - dt.setDate(t.getDate()); - dt.setSecurity(t.getSecurity()); - dt.setAccount(account); - dt.setAmount(t.getAmount()); - dt.setShares(t.getShares()); - dt.setNote(t.getNote()); - records.get(t.getSecurity()).addTransaction(dt); - } - break; - case FEES: - case TAXES: - case DEPOSIT: - case REMOVAL: - case BUY: - case SELL: - case TRANSFER_IN: - case TRANSFER_OUT: - break; - default: - throw new UnsupportedOperationException(); - } - } + if (t.getSecurity() == null) + continue; + + if (t.getType() != AccountTransaction.Type.DIVIDENDS && t.getType() != AccountTransaction.Type.INTEREST) + continue; + + if (t.getDate().getTime() <= startDate.getTime()) + continue; + + if (t.getDate().getTime() > endDate.getTime()) + continue; + + DividendTransaction dt = new DividendTransaction(); + dt.setDate(t.getDate()); + dt.setSecurity(t.getSecurity()); + dt.setAccount(account); + dt.setAmount(t.getAmount()); + dt.setShares(t.getShares()); + dt.setNote(t.getNote()); + records.get(t.getSecurity()).addTransaction(dt); } }