+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.model.gender;
+
+import javax.swing.ComboBoxModel;
+import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.model.BaseModel;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class GenderComboBoxModel extends BaseModel implements ComboBoxModel<String> {
+
+ /**
+ * Selected item instance, the value can only be 'M', 'F' or 'C'
+ */
+ private char selectedItem = 0;
+
+ /**
+ * Selectable items
+ */
+ private final char[] validItems = new char[] {'M', 'F', 'C'};
+
+ /**
+ * Creates an instance of this model with a Client instance
+ * @param client Client instance
+ */
+ public GenderComboBoxModel (final Client client) {
+ // Call super constructor
+ super();
+
+ // Set client
+ this.setClient(client);
+ }
+
+ @Override
+ public String getElementAt (final int index) {
+ // Return it
+ return String.valueOf(this.validItems[index]);
+ }
+
+ /**
+ * Gets the currently selected item or null if nothing is selected.
+ *
+ * @return Selected item or null
+ */
+ @Override
+ public Object getSelectedItem () {
+ // Is the char set other than 0?
+ if (this.selectedItem == 0) {
+ // Nothing selected
+ return null;
+ }
+
+ // Return string representing the selected item
+ return this.selectedItem;
+ }
+
+ @Override
+ public void setSelectedItem (final Object anItem) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ /**
+ * Getter for size. Here only 3 values are valid: M, F and C
+ *
+ * @return Maximum size
+ */
+ @Override
+ public int getSize () {
+ // Get size of array
+ return this.validItems.length;
+ }
+}