From 739f0e48fad7cd1ac56afb7beb1cad4516805a7d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 4 Sep 2015 14:51:33 +0200 Subject: [PATCH] =?utf8?q?Preprared=20jcore=20for=20EJB=20applications:=20?= =?utf8?q?-=20moved=20Gender=20into=20own=20sub=20package=20-=20added=20ut?= =?utf8?q?ility=20class=20GenderUtils=20-=20removed=20session-related=20st?= =?utf8?q?uff=20as=20this=20was=20a=20bad=20idea=20anyway=20Signed-off-by:?= =?utf8?q?Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../mxchange/jcore/BaseFrameworkSystem.java | 29 +------- .../mxchange/jcore/FrameworkInterface.java | 12 ---- .../mxchange/jcore/contact/BaseContact.java | 1 + src/org/mxchange/jcore/contact/Contact.java | 1 + .../jcore/contact/{ => gender}/Gender.java | 14 ++-- .../jcore/contact/gender/GenderUtils.java | 69 +++++++++++++++++++ 6 files changed, 77 insertions(+), 49 deletions(-) rename src/org/mxchange/jcore/contact/{ => gender}/Gender.java (93%) create mode 100644 src/org/mxchange/jcore/contact/gender/GenderUtils.java diff --git a/src/org/mxchange/jcore/BaseFrameworkSystem.java b/src/org/mxchange/jcore/BaseFrameworkSystem.java index 3beeadd..1a96607 100644 --- a/src/org/mxchange/jcore/BaseFrameworkSystem.java +++ b/src/org/mxchange/jcore/BaseFrameworkSystem.java @@ -101,11 +101,6 @@ public class BaseFrameworkSystem implements FrameworkInterface { */ private Manageable manager; - /** - * Session id assigned with this basket, or any other unique identifier - */ - private String sessionId; - /** * Name of used database table, handled over to backend */ @@ -331,26 +326,6 @@ public class BaseFrameworkSystem implements FrameworkInterface { this.client = client; } - /** - * Getter for session id - * - * @return Session id - */ - @Override - public final String getSessionId () { - return this.sessionId; - } - - /** - * Setter for session id - * - * @param sessionId Session id - */ - @Override - public final void setSessionId (final String sessionId) { - this.sessionId = sessionId; - } - /** * Name of used database table, handled over to backend * @@ -955,7 +930,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { this.getLogger().trace("CALLED!"); //NOI18N // Is the bundle set? - if (this.isBundledInitialized()) { + if (isBundledInitialized()) { // Is already set throw new IllegalStateException("called twice"); //NOI18N } @@ -1053,7 +1028,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { * * @return Whether the bundle has been initialized */ - protected boolean isBundledInitialized () { + protected static boolean isBundledInitialized () { // Check it return (bundle instanceof ResourceBundle); } diff --git a/src/org/mxchange/jcore/FrameworkInterface.java b/src/org/mxchange/jcore/FrameworkInterface.java index 222b09d..bf9b1e8 100644 --- a/src/org/mxchange/jcore/FrameworkInterface.java +++ b/src/org/mxchange/jcore/FrameworkInterface.java @@ -66,18 +66,6 @@ public interface FrameworkInterface { */ public Application getApplication (); - /** - * Session id - * @return the sessionId - */ - public String getSessionId (); - - /** - * Session id - * @param sessionId the sessionId to set - */ - public void setSessionId (final String sessionId); - /** * Getter for human-readable string from given key * diff --git a/src/org/mxchange/jcore/contact/BaseContact.java b/src/org/mxchange/jcore/contact/BaseContact.java index 297b486..61455d5 100644 --- a/src/org/mxchange/jcore/contact/BaseContact.java +++ b/src/org/mxchange/jcore/contact/BaseContact.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Objects; import org.mxchange.jcore.BaseFrameworkSystem; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.gender.Gender; /** * A general contact class which should only be extended. diff --git a/src/org/mxchange/jcore/contact/Contact.java b/src/org/mxchange/jcore/contact/Contact.java index 2f2f92a..4ac21d8 100644 --- a/src/org/mxchange/jcore/contact/Contact.java +++ b/src/org/mxchange/jcore/contact/Contact.java @@ -21,6 +21,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import java.util.Map; import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.gender.Gender; import org.mxchange.jcore.database.storage.Storable; /** diff --git a/src/org/mxchange/jcore/contact/Gender.java b/src/org/mxchange/jcore/contact/gender/Gender.java similarity index 93% rename from src/org/mxchange/jcore/contact/Gender.java rename to src/org/mxchange/jcore/contact/gender/Gender.java index 322c31f..576851d 100644 --- a/src/org/mxchange/jcore/contact/Gender.java +++ b/src/org/mxchange/jcore/contact/gender/Gender.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jcore.contact; +package org.mxchange.jcore.contact.gender; import java.text.MessageFormat; @@ -70,7 +70,7 @@ public enum Gender { Gender g = null; // Loop through all - for (final Gender gender : Gender.values()) { + for (final Gender gender : GenderUtils.selectableGenders()) { // Does the char match? if (c == gender.getAccessChar()) { // Found it @@ -91,7 +91,7 @@ public enum Gender { } /** - * Valid chars + * Valid chars (mostly for console client) * * @return Valid chars */ @@ -107,16 +107,10 @@ public enum Gender { // Get values int i = 0; - for (Gender gender : values()) { + for (final Gender gender : GenderUtils.selectableGenders()) { // Debug message //* NOISY-DEBUG: */ System.out.println("gender=" + gender); - // Is it UNKNOWN? - if (gender.equals(Gender.UNKNOWN)) { - // Skip this - continue; - } - // Debug message //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("gender={0} - adding at pos {1} ...", gender, i)); diff --git a/src/org/mxchange/jcore/contact/gender/GenderUtils.java b/src/org/mxchange/jcore/contact/gender/GenderUtils.java new file mode 100644 index 0000000..1fb0992 --- /dev/null +++ b/src/org/mxchange/jcore/contact/gender/GenderUtils.java @@ -0,0 +1,69 @@ +/* + * 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 . + */ +package org.mxchange.jcore.contact.gender; + +import java.text.MessageFormat; +import java.util.LinkedList; +import java.util.List; +import org.mxchange.jcore.BaseFrameworkSystem; + +/** + * Gender utils class + * + * @author Roland Haeder + */ +public final class GenderUtils extends BaseFrameworkSystem { + /** + * Private contructor as this is an utility class + */ + private GenderUtils () { + } + + /** + * All selectable genders (not UNKNOWN) + * + * @return Selectable genders (not UNKNOWN) + */ + public static List selectableGenders () { + // Trace message + new GenderUtils().getLogger().trace("CALLED!"); //NOI18N + + // Init list + List list = new LinkedList<>(); + + // Walk through all genders + for (final Gender gender : Gender.values()) { + // Debug log + new GenderUtils().getLogger().debug(MessageFormat.format("gender={0}", gender)); //NOI18N + + // Is it not UNKNOWN + if (!gender.equals(Gender.UNKNOWN)) { + // Add it + boolean added = list.add(gender); + + // Has it been added? + assert(added) : MessageFormat.format("gender {0} not added.", gender); //NOI18N + } + } + + // Trace message + new GenderUtils().getLogger().trace(MessageFormat.format("list={0} - EXIT!", list)); //NOI18N + + // Return it + return list; + } +} -- 2.39.5