]> git.mxchange.org Git - jaddressbook-lib.git/commitdiff
Added some documentation + added assertions for important fields as this must be...
authorRoland Haeder <roland@mxchange.org>
Fri, 24 Jul 2015 10:51:30 +0000 (12:51 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 24 Jul 2015 10:51:30 +0000 (12:51 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java

index c958c1de9b82084a782f2fd2de821b06cb514be2..9f17d0cd816a9022f5e52b9d2cd06931cfa8b6d0 100644 (file)
@@ -51,8 +51,10 @@ public class ContactManager extends BaseManager implements ManageableContact {
      */
     private final List<Contact> 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<Contact> 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<Contact> 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;