2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.client;
19 import org.mxchange.jcore.exceptions.MenuInitializationException;
20 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
21 import org.mxchange.jcore.client.Client;
22 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
23 import org.mxchange.jcore.model.contact.Contact;
24 import org.mxchange.jcore.model.contact.gender.Gender;
27 * A special client interface for addressbook applications.
29 * @author Roland Haeder
31 public interface AddressbookClient extends Client {
34 * The user changes own name data
38 public void doChangeOwnNameData (final Contact contact);
41 * The user changes own address data
43 * @param contact Contact instance to change
45 public void doChangeOwnAddressData (final Contact contact);
48 * The user changes own other data
50 * @param contact Constact instance to change
52 public void doChangeOwnOtherData (final Contact contact);
55 * Allows the user to enter own data
57 * @return Finished Contact instance
59 public Contact doEnterOwnData ();
62 * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
64 * @param message Message to output
67 public Gender enterGender (final String message);
70 * Let the user choose what to change on the address: [n]ame, [a]ddress,
73 * @param contact Contact instance to let the user change data
74 * @throws UnhandledUserChoiceException If choice is not supported
76 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
79 * Asks the user for a choice and proceeds accordingly
81 * @throws UnhandledUserChoiceException If choice is not supported
82 * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the menu cannot be initialized
84 public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
87 * Asks the the user to enter a single character which must match validChars
89 * @param validChars Valid chars that are accepted
90 * @param message Message to user
91 * @return Allowed character
93 public char enterChar (final char[] validChars, final String message);
96 * Reads a string of minimum and maximum length from the user. An empty
97 * string should be generally not allowed, but might be okay for e.g.
100 * @param minLength Minimum length of the string to read
101 * @param maxLength Maximum length of the string to read
102 * @param message Message to user
103 * @param allowEmpty Whether empty strings are allowed
104 * @return Entered string by user or null if empty string is allowed
106 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
109 * Reads an integer (int) from the user
111 * @param minimum Minimum allowed number
112 * @param maximum Maximum allowed number
113 * @param message Message to user
114 * @return Entered string by user or null if empty string is allowed
116 public int enterInt (final int minimum, final int maximum, final String message);
119 * Setter for current menu choice
121 * @param currentMenu Current menu choice
123 public void setCurrentMenu (final String currentMenu);
126 * Some "Getter" for menu item
128 * @param accessKey Key to press to access this menu
129 * @param text Text to show to user
132 public SelectableMenuItem getMenuItem (final char accessKey, final String text);
135 * Shows given menu entry in client
137 * @param item Menu item to show
139 public void showEntry (final SelectableMenuItem item);
142 * Shows current menu selection to the user
144 public void showCurrentMenu ();