Browse Source

replace builder by stateless, threadsafe factory

Armin Schrenk 2 years ago
parent
commit
a92ebfdc7b

+ 3 - 8
src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyComponent.java

@@ -38,16 +38,11 @@ public interface RecoveryKeyComponent {
 		stage.show();
 	}
 
-	@Subcomponent.Builder
-	interface Builder {
 
-		@BindsInstance
-		Builder vault(@RecoveryKeyWindow Vault vault);
+	@Subcomponent.Factory
+	interface Factory {
 
-		@BindsInstance
-		Builder owner(@Named("keyRecoveryOwner") Stage owner);
-
-		RecoveryKeyComponent build();
+		RecoveryKeyComponent create(@BindsInstance @RecoveryKeyWindow Vault vault, @BindsInstance @Named("keyRecoveryOwner") Stage owner);
 	}
 
 }

+ 4 - 4
src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java

@@ -23,14 +23,14 @@ public class MasterkeyOptionsController implements FxController {
 	private final Vault vault;
 	private final Stage window;
 	private final ChangePasswordComponent.Builder changePasswordWindow;
-	private final RecoveryKeyComponent.Builder recoveryKeyWindow;
+	private final RecoveryKeyComponent.Factory recoveryKeyWindow;
 	private final ForgetPasswordComponent.Builder forgetPasswordWindow;
 	private final KeychainManager keychain;
 	private final ObservableValue<Boolean> passwordSaved;
 
 
 	@Inject
-	MasterkeyOptionsController(@VaultOptionsWindow Vault vault, @VaultOptionsWindow Stage window, ChangePasswordComponent.Builder changePasswordWindow, RecoveryKeyComponent.Builder recoveryKeyWindow, ForgetPasswordComponent.Builder forgetPasswordWindow, KeychainManager keychain) {
+	MasterkeyOptionsController(@VaultOptionsWindow Vault vault, @VaultOptionsWindow Stage window, ChangePasswordComponent.Builder changePasswordWindow, RecoveryKeyComponent.Factory recoveryKeyWindow, ForgetPasswordComponent.Builder forgetPasswordWindow, KeychainManager keychain) {
 		this.vault = vault;
 		this.window = window;
 		this.changePasswordWindow = changePasswordWindow;
@@ -51,12 +51,12 @@ public class MasterkeyOptionsController implements FxController {
 
 	@FXML
 	public void showRecoveryKey() {
-		recoveryKeyWindow.vault(vault).owner(window).build().showRecoveryKeyCreationWindow();
+		recoveryKeyWindow.create(vault, window).showRecoveryKeyCreationWindow();
 	}
 
 	@FXML
 	public void showRecoverVaultDialog() {
-		recoveryKeyWindow.vault(vault).owner(window).build().showRecoveryKeyRecoverWindow();
+		recoveryKeyWindow.create(vault, window).showRecoveryKeyRecoverWindow();
 	}
 
 	@FXML