]> git.mxchange.org Git - addressbook-lib.git/blob - src/org/mxchange/addressbook/client/AddressbookClient.java
7045abe51a66cadb4cdfe38399d24d64781226d3
[addressbook-lib.git] / src / org / mxchange / addressbook / client / AddressbookClient.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.addressbook.client;
18
19 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
20 import org.mxchange.jcore.client.Client;
21 import org.mxchange.jcore.exceptions.MenuInitializationException;
22 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
23 import org.mxchange.jcore.model.contact.Contact;
24 import org.mxchange.jcore.model.contact.gender.Gender;
25
26 /**
27  * A special client interface for addressbook applications.
28  * <p>
29  * @author Roland Haeder
30  */
31 public interface AddressbookClient extends Client {
32
33         /**
34          * The user changes own address data
35          * <p>
36          * @param contact Contact instance to change
37          */
38         public void doChangeOwnAddressData (final Contact contact);
39
40         /**
41          * The user changes own name data
42          * <p>
43          * @param contact
44          */
45         public void doChangeOwnNameData (final Contact contact);
46
47         /**
48          * The user changes own other data
49          * <p>
50          * @param contact Constact instance to change
51          */
52         public void doChangeOwnOtherData (final Contact contact);
53
54         /**
55          * Allows the user to enter own data
56          * <p>
57          * @return Finished Contact instance
58          */
59         public Contact doEnterOwnData ();
60
61         /**
62          * Asks the user for a choice and proceeds accordingly
63          * <p>
64          * @throws UnhandledUserChoiceException If choice is not supported
65          * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the menu cannot be initialized
66          */
67         public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
68
69         /**
70          * Asks the the user to enter a single character which must match validChars
71          * <p>
72          * @param       validChars Valid chars that are accepted
73          * @param       message Message to user
74          * @return      Allowed character
75          */
76         public char enterChar (final char[] validChars, final String message);
77
78         /**
79          * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
80          * <p>
81          * @param message Message to output
82          * @return Gender enum
83          */
84         public Gender enterGender (final String message);
85
86         /**
87          * Reads an integer (int) from the user
88          * <p>
89          * @param minimum Minimum allowed number
90          * @param maximum Maximum allowed number
91          * @param message       Message to user
92          * @return Entered string by user or null if empty string is allowed
93          */
94         public int enterInt (final int minimum, final int maximum, final String message);
95
96         /**
97          * Reads a string of minimum and maximum length from the user. An empty
98          * string should be generally not allowed, but might be okay for e.g.
99          * company name.
100          * <p>
101          * @param minLength     Minimum length of the string to read
102          * @param maxLength     Maximum length of the string to read
103          * @param message       Message to user
104          * @param allowEmpty Whether empty strings are allowed
105          * @return Entered string by user or null if empty string is allowed
106          */
107         public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
108
109         /**
110          * Setter for current menu choice
111          * <p>
112          * @param currentMenu Current menu choice
113          */
114         public void setCurrentMenu (final String currentMenu);
115
116         /**
117          * Some "Getter" for menu item
118          * <p>
119          * @param accessKey Key to press to access this menu
120          * @param text Text to show to user
121          * @return
122          */
123         public SelectableMenuItem getMenuItem (final char accessKey, final String text);
124
125         /**
126          * Shows current menu selection to the user
127          */
128         public void showCurrentMenu ();
129
130         /**
131          * Shows given menu entry in client
132          * <p>
133          * @param item Menu item to show
134          */
135         public void showEntry (final SelectableMenuItem item);
136
137         /**
138          * Let the user choose what to change on the address: [n]ame, [a]ddress,
139          * [o]ther
140          * <p>
141          * @param contact Contact instance to let the user change data
142          * @throws UnhandledUserChoiceException If choice is not supported
143          */
144         public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
145 }