Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove redundant local variable #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/de/willuhn/jameica/hbci/gui/input/AddressInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,10 @@ public void handleEvent(Event event)
*/
public void setText(String s)
{
String before = s;
String after = HBCIProperties.clean(s,validChars);
// Alle Zeichen rauswerfen, die nicht zulaessig sind.
super.setText(after);
if (before != null && !before.equals(after))
String cleaned = HBCIProperties.clean(s,validChars);
super.setText(cleaned);
if (s != null && !s.equals(cleaned))
GUI.getView().setErrorText(i18n.tr("Im Namen wurden nicht zul�ssige Zeichen entfernt"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import de.willuhn.jameica.hbci.messaging.ObjectMessage;
import de.willuhn.jameica.hbci.reminder.ReminderStorageProviderHibiscus;
import de.willuhn.jameica.hbci.rmi.HBCIDBService;
import de.willuhn.jameica.hbci.rmi.HibiscusDBObject;
import de.willuhn.jameica.hbci.rmi.Konto;
import de.willuhn.jameica.hbci.rmi.SammelTransfer;
import de.willuhn.jameica.hbci.rmi.SammelTransferBuchung;
Expand Down Expand Up @@ -95,8 +94,7 @@ else if (l.ausgefuehrt())
item.setForeground(Color.COMMENT.getSWTColor());

// Checken, ob der Auftrag einen Reminder hat oder ob es ein geclonter Auftrag ist
HibiscusDBObject o = (HibiscusDBObject) l;

This comment was marked as resolved.

String uuid = MetaKey.REMINDER_UUID.get(o);
String uuid = MetaKey.REMINDER_UUID.get(l);
if (uuid != null)
{
try
Expand All @@ -110,7 +108,7 @@ else if (l.ausgefuehrt())
Logger.error("unable to determine reminder",e);
}
}
else if (MetaKey.REMINDER_TEMPLATE.get(o) != null)
else if (MetaKey.REMINDER_TEMPLATE.get(l) != null)
{
item.setImage(4,SWTUtil.getImage("edit-copy.png"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public void format(TableItem item) {
item.setForeground(Color.COMMENT.getSWTColor());

// Checken, ob der Auftrag einen Reminder hat oder ob es ein geclonter Auftrag ist
HibiscusDBObject o = (HibiscusDBObject) l;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Durch Entfernen der lokalen Variable o, wird die Semantik der Identität bei ihrer Verwendung gebrochen. Der Code sollte daher an dieser Stelle bleiben, wie er war.

Copy link
Contributor Author

@ruderphilipp ruderphilipp Jan 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hallo @meigelb,
ehrlich gesagt, verstehe ich nicht, was Du mit "die Semantik der Identität bei ihrer Verwendung" ausdrücken möchtest.

Die Aussage ist "checke ob l ein Klon ist", wozu in Zeile 119 die UUID und in Zeile 133 das Template verwendet wird.

Damit der Code compiliert, ist der Downcast nicht notwendig, da die Variable l vom Typ SepaSammelTransfer ist, welches wiederum ein HibiscusDBObject ist, und somit automatisch beim Funktionsaufruf entsprechend gecastet wird:

public interface SepaSammelTransfer<T extends SepaSammelTransferBuchung> extends HibiscusDBObject, Terminable, Duplicatable, SepaPayment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, ich weiß auch nicht, was ich damals dort gesehen habe. Aus heutiger Sicht passt es. Vielleicht habe ich nicht erkannt, dass l ein Objekt vom Typ SepaSammelTransfer ist, sondern das als eine 1 gelesen. Danke fürs kritische Hinterfragen.

String uuid = MetaKey.REMINDER_UUID.get(o);
String uuid = MetaKey.REMINDER_UUID.get(l);
if (uuid != null)
{
try
Expand All @@ -131,7 +130,7 @@ public void format(TableItem item) {
Logger.error("unable to determine reminder",e);
}
}
else if (MetaKey.REMINDER_TEMPLATE.get(o) != null)
else if (MetaKey.REMINDER_TEMPLATE.get(l) != null)
{
item.setImage(4,SWTUtil.getImage("edit-copy.png"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public void handleAction(Object context) throws ApplicationException
{
if (context == null || !(context instanceof Entry))
return;
Entry e = (Entry) context;
selected = e;
selected = (Entry) context;
close();
}
});
Expand All @@ -92,8 +91,7 @@ public void handleAction(Object context) throws ApplicationException
if (o == null || !(o instanceof Entry))
return;

Entry e = (Entry) context;
selected = e;
selected = (Entry) context;
close();
}
},null,false,"ok.png");
Expand Down
3 changes: 1 addition & 2 deletions src/de/willuhn/jameica/hbci/server/UmsatzTypImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ public Object getAttribute(String arg0) throws RemoteException
return null;
try
{
Integer i = Integer.valueOf(n);
return i;
return new Integer(n);
}
catch (Exception e)
{
Expand Down
3 changes: 1 addition & 2 deletions src/de/willuhn/jameica/hbci/server/VersionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public static int delete(HBCIDBService service, String name) throws RemoteExcept
if (name == null || name.length() == 0)
throw new RemoteException("no name given");

int i = service.executeUpdate("delete from version where name = ?",name);
return i;
return service.executeUpdate("delete from version where name = ?",name);
}
}