45 /**
46 * @serial
47 * @since 1.4
48 */
49 private String defaultName;
50 /**
51 * @serial
52 * @since 1.4
53 */
54 private String inputName;
55
56 /**
57 * Construct a {@code NameCallback} with a prompt.
58 *
59 * @param prompt the prompt used to request the name.
60 *
61 * @exception IllegalArgumentException if {@code prompt} is null
62 * or if {@code prompt} has a length of 0.
63 */
64 public NameCallback(String prompt) {
65 if (prompt == null || prompt.length() == 0)
66 throw new IllegalArgumentException();
67 this.prompt = prompt;
68 }
69
70 /**
71 * Construct a {@code NameCallback} with a prompt
72 * and default name.
73 *
74 * @param prompt the prompt used to request the information.
75 *
76 * @param defaultName the name to be used as the default name displayed
77 * with the prompt.
78 *
79 * @exception IllegalArgumentException if {@code prompt} is null,
80 * if {@code prompt} has a length of 0,
81 * if {@code defaultName} is null,
82 * or if {@code defaultName} has a length of 0.
83 */
84 public NameCallback(String prompt, String defaultName) {
85 if (prompt == null || prompt.length() == 0 ||
86 defaultName == null || defaultName.length() == 0)
87 throw new IllegalArgumentException();
88
89 this.prompt = prompt;
90 this.defaultName = defaultName;
91 }
92
93 /**
94 * Get the prompt.
95 *
96 * @return the prompt.
97 */
98 public String getPrompt() {
99 return prompt;
100 }
101
102 /**
103 * Get the default name.
104 *
105 * @return the default name, or null if this {@code NameCallback}
106 * was not instantiated with a {@code defaultName}.
|
45 /**
46 * @serial
47 * @since 1.4
48 */
49 private String defaultName;
50 /**
51 * @serial
52 * @since 1.4
53 */
54 private String inputName;
55
56 /**
57 * Construct a {@code NameCallback} with a prompt.
58 *
59 * @param prompt the prompt used to request the name.
60 *
61 * @exception IllegalArgumentException if {@code prompt} is null
62 * or if {@code prompt} has a length of 0.
63 */
64 public NameCallback(String prompt) {
65 if (prompt == null || prompt.isEmpty())
66 throw new IllegalArgumentException();
67 this.prompt = prompt;
68 }
69
70 /**
71 * Construct a {@code NameCallback} with a prompt
72 * and default name.
73 *
74 * @param prompt the prompt used to request the information.
75 *
76 * @param defaultName the name to be used as the default name displayed
77 * with the prompt.
78 *
79 * @exception IllegalArgumentException if {@code prompt} is null,
80 * if {@code prompt} has a length of 0,
81 * if {@code defaultName} is null,
82 * or if {@code defaultName} has a length of 0.
83 */
84 public NameCallback(String prompt, String defaultName) {
85 if (prompt == null || prompt.isEmpty() ||
86 defaultName == null || defaultName.isEmpty())
87 throw new IllegalArgumentException();
88
89 this.prompt = prompt;
90 this.defaultName = defaultName;
91 }
92
93 /**
94 * Get the prompt.
95 *
96 * @return the prompt.
97 */
98 public String getPrompt() {
99 return prompt;
100 }
101
102 /**
103 * Get the default name.
104 *
105 * @return the default name, or null if this {@code NameCallback}
106 * was not instantiated with a {@code defaultName}.
|