From 6079f5e2a05bdc3085e76e5f1304292904ef7e83 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 24 Jul 2015 12:51:30 +0200 Subject: [PATCH] =?utf8?q?Added=20some=20documentation=20+=20added=20asser?= =?utf8?q?tions=20for=20important=20fields=20as=20this=20must=20be=20found?= =?utf8?q?=20before=20"release".=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../manager/contact/ContactManager.java | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java index c958c1de..9f17d0cd 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java @@ -51,8 +51,10 @@ public class ContactManager extends BaseManager implements ManageableContact { */ private final List contacts; - /** + * Constructor which accepts maxContacts for maximum (initial) contacts and + * a client instance. + * * @param maxContacts Maximum allowed contacts * @param client Client instance to use */ @@ -89,6 +91,8 @@ public class ContactManager extends BaseManager implements ManageableContact { */ @Override public void addContact (final Contact contact) { + assert(this.contacts instanceof List) : "this.contacts is not initialized"; + this.contacts.add(contact); } @@ -384,9 +388,25 @@ public class ContactManager extends BaseManager implements ManageableContact { @Override public final int getColumnCount () { + assert(this.columnNames instanceof List) : "this.columnNames is not initialized"; + return this.columnNames.size(); } + /** + * Getter for column name at given index. + * + * @param columnIndex Column index + * @return Human-readable column name + */ + @Override + public String getColumnName (final int columnIndex) { + assert(this.columnNames instanceof List) : "this.columnNames is not initialized"; + + // Get column name at index + return this.columnNames.get(columnIndex); + } + /** * Getter for whole contact list * @@ -394,6 +414,7 @@ public class ContactManager extends BaseManager implements ManageableContact { */ @Override public List getList () { + assert(this.contacts instanceof List) : "this.contacts is not initialized"; return Collections.unmodifiableList(this.contacts); } @@ -405,6 +426,8 @@ public class ContactManager extends BaseManager implements ManageableContact { */ @Override public boolean isOwnContactAdded () { + assert(this.contacts instanceof List) : "this.contacts is not initialized"; + // Default is not added boolean isAdded = false; @@ -466,6 +489,7 @@ public class ContactManager extends BaseManager implements ManageableContact { */ @Override public final int size () { + assert(this.contacts instanceof List) : "this.contacts is not initialized"; return this.contacts.size(); } @@ -473,6 +497,8 @@ public class ContactManager extends BaseManager implements ManageableContact { * Fills the column names array with strings from bundle */ private void fillColumnNamesFromBundle () { + assert(this.columnNames instanceof List) : "this.columnNames is not initialized"; + // Debug message this.getLogger().trace("CALLED!"); @@ -498,18 +524,6 @@ public class ContactManager extends BaseManager implements ManageableContact { this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); } - /** - * Getter for column name at given index. - * - * @param columnIndex Column index - * @return Human-readable column name - */ - @Override - public String getColumnName (final int columnIndex) { - // Get column name at index - return this.columnNames.get(columnIndex); - } - /** * Flushes all entries by calling database backend */ @@ -533,6 +547,8 @@ public class ContactManager extends BaseManager implements ManageableContact { * @return Contact instance or null */ private Contact getOwnContact () { + assert(this.contacts instanceof List) : "this.contacts is not initialized"; + // Now get it back from address book, first get an iterator Iterator iterator = this.contacts.iterator(); @@ -564,6 +580,8 @@ public class ContactManager extends BaseManager implements ManageableContact { * @return TRUE if found, FALSE if not found */ private boolean isContactAlreadyAdded (final Contact checkContact) throws NullPointerException { + assert(this.contacts instanceof List) : "this.contacts is not initialized"; + // Default is not found boolean isFound = false; -- 2.39.5