From: Roland Haeder Date: Fri, 24 Jul 2015 10:51:30 +0000 (+0200) Subject: Added some documentation + added assertions for important fields as this must be... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6079f5e2a05bdc3085e76e5f1304292904ef7e83;p=jfinancials-lib.git Added some documentation + added assertions for important fields as this must be found before "release". Signed-off-by:Roland Häder --- diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java index c958c1d..9f17d0c 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;