com.g2forge.alexandria.wizard.UserPasswordInput Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ax-wizard Show documentation
Show all versions of ax-wizard Show documentation
Library for building command line and GUI wizards.
The newest version!
package com.g2forge.alexandria.wizard;
import java.io.Console;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class UserPasswordInput extends AInput {
protected static final Console console = System.console();
@Getter
protected final String prompt;
@Getter(lazy = true, value = AccessLevel.PROTECTED)
private final String value = computeValue();
protected String computeValue() {
if (console == null) {
final String[] retVal = UserStringInput.prompt(getPrompt(), null, new String[] { getPrompt() }, new boolean[] { false });
if (retVal == null) throw new InputUnspecifiedException();
return retVal[0];
}
return new String(console.readPassword("%s: ", getPrompt()));
}
@Override
public String get() {
return getValue();
}
@Override
public boolean isEmpty() {
return false;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy