Skip to content

Commit

Permalink
Refactoring (in DialogContext): Nutze Konstruktor statt statischer …
Browse files Browse the repository at this point in the history
…Methode, die dann nur K'tor aufruft

Laut Historie in Git kam die Klasse `DialogContext` mit Commit
500f075 und hatte dort bereits die statische
Methode `create` sowie einen privaten Konstruktur ohne Parameter, der dadurch
gekapselt wird.

Jedoch ruft `create` ausschließlich der Konstruktur auf und setzt die
übergebenen Parameter in der neu erzeugten Objektinstanz. Es existiert keine
zusätzliche Logik (z.B. Singleton o.ä.), wodurch diese Indirektion notwendig
wäre.
  • Loading branch information
ruderphilipp committed Jan 23, 2022
1 parent 7072e1f commit d8f87a6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
15 changes: 3 additions & 12 deletions src/main/java/org/kapott/hbci/dialog/DialogContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,12 @@ public class DialogContext
* @param passport der Passport.
* @return der neue Context.
*/
public static DialogContext create(HBCIKernelImpl kernel, HBCIPassportInternal passport)
public DialogContext(HBCIKernelImpl kernel, HBCIPassportInternal passport)
{
DialogContext ctx = new DialogContext();
ctx.kernel = kernel;
ctx.passport = passport;
return ctx;
this.kernel = kernel;
this.passport = passport;
}

/**
* ct.
*/
private DialogContext()
{
}

/**
* Liefert den Kernel.
* @return der Kernel. Kann NULL sein.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kapott/hbci/manager/HBCIDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private HBCIMsgStatus doDialogInit()
HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_DIALOG_INIT,null);

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(kernel,mainPassport);
final DialogContext ctx = new DialogContext(kernel,mainPassport);
ctx.setDialog(this);
ctx.setAnonymous(this.isAnon);

Expand Down Expand Up @@ -174,7 +174,7 @@ private HBCIMsgStatus[] doJobs()
final HBCIKernelImpl k = (HBCIKernelImpl) h.getKernel();
final HBCIPassportInternal p = (HBCIPassportInternal) h.getPassport();

final DialogContext ctx = DialogContext.create(k,p);
final DialogContext ctx = new DialogContext(k,p);
ctx.setDialog(this);
ctx.setAnonymous(this.isAnon);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kapott/hbci/manager/HBCIInstitute.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void fetchBPD()
HBCIUtils.log("Aktualisiere Bankparameter (BPD)",HBCIUtils.LOG_INFO);

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);
ctx.setAnonymous(true);

// Dialog-Initialisierung senden
Expand Down Expand Up @@ -342,7 +342,7 @@ public void fetchKeys()
HBCIUtils.log("Rufe Institutsschlüssel ab",HBCIUtils.LOG_INFO);

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);
ctx.setAnonymous(true);

// Dialog-Initialisierung senden
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/kapott/hbci/manager/HBCIUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void sendAndActivateNewUserKeys(HBCIKey[] sigKey,HBCIKey[] encKey)
HBCIUtilsInternal.getCallback().status(passport,HBCICallback.STATUS_DIALOG_INIT,null);

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);

// Dialog-Initialisierung senden
final HBCIDialogInit init = new HBCIDialogInit();
Expand Down Expand Up @@ -436,7 +436,7 @@ public void fetchSysId()
// Sync
{
// Dialog-Synchronisierung senden
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);
final HBCIDialogSync sync = new HBCIDialogSync(Mode.SYS_ID);
final HBCIMsgStatus ret = sync.execute(ctx);
final Properties result = ret.getData();
Expand Down Expand Up @@ -481,7 +481,7 @@ public void fetchSigId()
passport.setSigId(new Long("9999999999999999"));

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);

// Dialog-Synchronisierung senden
final HBCIDialogSync sync = new HBCIDialogSync(Mode.SIG_ID);
Expand Down Expand Up @@ -614,7 +614,7 @@ public void fetchUPD()
}

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);
ctx.setAnonymous(this.isAnon);

// Dialog-Initialisierung senden
Expand Down Expand Up @@ -665,7 +665,7 @@ public void sync(boolean force)
////////////////////////////////////////
// TAN-Medienbezeichnung abrufen - machen wir noch vor den UPD. Weil wir dafuer ja ggf. bereits das TAN-Verfahren brauchen (wir rufen dort ja auch KInfo ab)
{
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);
HBCIProcess p = new HBCIProcessTanMedia(force);
p.execute(ctx);
}
Expand All @@ -685,7 +685,7 @@ public void sync(boolean force)
// Zum Schluss noch die SEPA-Infos abrufen
if (Feature.SYNC_SEPAINFO.isEnabled())
{
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);
HBCIProcess p = new HBCIProcessSepaInfo(force);
p.execute(ctx);
}
Expand Down Expand Up @@ -720,7 +720,7 @@ public void lockKeys()
HBCIUtils.log("Sperre Benutzerschlüssel",HBCIUtils.LOG_INFO);

// Dialog-Context erzeugen
final DialogContext ctx = DialogContext.create(this.kernel,this.passport);
final DialogContext ctx = new DialogContext(this.kernel,this.passport);

// Dialog-Initialisierung senden
final HBCIDialogInit init = new HBCIDialogInit();
Expand Down

0 comments on commit d8f87a6

Please sign in to comment.