From: Roland Haeder Date: Thu, 6 Aug 2015 12:15:36 +0000 (+0200) Subject: These update methods were somewhere lame, so better take data-setters. Object-instanc... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=45574ccad092984bde6cdb2c9dcc6dc7451019b0;p=jfinancials-swing.git These update methods were somewhere lame, so better take data-setters. Object-instance-setters however should *not* be publicly accessible as this may cause interferences if a programmer sets a needed instances by mistake somewhere. Signed-off-by:Roland Häder --- diff --git a/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java b/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java index c64ac7f..3dbb702 100644 --- a/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java +++ b/Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java @@ -168,8 +168,8 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC // Get manager and cast it ManageableContact manager = (ManageableContact) this.getManager(); - // Own address data - String street = manager.enterOwnStreet(); + // Own street and number + String streetNumber = manager.enterOwnStreet(); // Get zip code int zipCode = manager.enterOwnZipCode(); @@ -181,7 +181,10 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String countryCode = manager.enterOwnCountryCode(); // Update address data - contact.updateAddressData(street, zipCode, city, countryCode); + contact.setStreet(streetNumber); + contact.setZipCode(zipCode); + contact.setCity(city); + contact.setCountryCode(countryCode); // Trace message this.getLogger().trace("EXIT!"); //NOI18N @@ -220,7 +223,10 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String companyName = manager.enterOwnCompanyName(); // Update contact instance - contact.updateNameData(gender, surname, familyName, companyName); + contact.setGender(gender); + contact.setSurname(surname); + contact.setFamilyName(familyName); + contact.setCompanyName(companyName); // Trace message this.getLogger().trace("EXIT!"); //NOI18N @@ -250,7 +256,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String phoneNumber = manager.enterOwnPhoneNumber(); // Phone number - String cellNumber = manager.enterOwnCellNumber(); + String cellphonePhoneNumber = manager.enterOwnCellNumber(); // Fax number String faxNumber = manager.enterOwnFaxNumber(); @@ -262,7 +268,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String comment = manager.enterOwnComment(); // Update contact instance - contact.updateOtherData(phoneNumber, cellNumber, faxNumber, email, null, comment); + contact.setPhoneNumber(phoneNumber); + contact.setCellphoneNumber(cellphonePhoneNumber); + contact.setFaxNumber(faxNumber); + contact.setEmailAddress(email); + contact.setComment(comment); // Trace message this.getLogger().trace("EXIT!"); //NOI18N diff --git a/Addressbook/src/org/mxchange/addressbook/contact/user/UserContact.java b/Addressbook/src/org/mxchange/addressbook/contact/user/UserContact.java index cd98817..d03a6d6 100644 --- a/Addressbook/src/org/mxchange/addressbook/contact/user/UserContact.java +++ b/Addressbook/src/org/mxchange/addressbook/contact/user/UserContact.java @@ -17,9 +17,9 @@ package org.mxchange.addressbook.contact.user; import java.text.MessageFormat; +import org.mxchange.addressbook.contact.book.BookContact; import org.mxchange.jcore.contact.Contact; import org.mxchange.jcore.contact.Gender; -import org.mxchange.addressbook.contact.book.BookContact; import org.mxchange.jcore.database.storage.csv.StoreableCsv; /** @@ -47,7 +47,10 @@ public class UserContact extends BookContact implements Contact, StoreableCsv { this.getLogger().trace(MessageFormat.format("gender={0},surname={1},familyName={2},companyName={3} - CALLED!", gender, surname, familyName, companyName)); //NOI18N // Update all data - this.updateNameData(gender, surname, familyName, companyName); + this.setGender(gender); + this.setSurname(surname); + this.setFamilyName(familyName); + this.setCompanyName(companyName); // Trace message this.getLogger().trace("EXIT!"); //NOI18N diff --git a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java index 6c83b89..8280ad0 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java @@ -415,7 +415,7 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateNameData(gender, null, null, null); + contact.setGender(gender); break; case 2: // Surname @@ -423,7 +423,7 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N // Update data - contact.updateNameData(gender, strippedToken, null, null); + contact.setSurname(strippedToken); break; case 3: // Family name @@ -431,7 +431,7 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N // Update data - contact.updateNameData(gender, null, strippedToken, null); + contact.setFamilyName(strippedToken); break; case 4: // Company name @@ -439,77 +439,77 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N // Update data - contact.updateNameData(gender, null, null, strippedToken); + contact.setCompanyName(strippedToken); break; case 5: // Street number assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateAddressData(strippedToken, 0, null, null); + contact.setHouseNumber(num); break; case 6: // ZIP code assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateAddressData(null, num, null, null); + contact.setZipCode(num); break; case 7: // City name assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateAddressData(null, 0, strippedToken, null); + contact.setCity(strippedToken); break; case 8: // Country code assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateAddressData(null, 0, null, strippedToken); + contact.setCountryCode(strippedToken); break; case 9: // Phone number assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateOtherData(strippedToken, null, null, null, null, null); + contact.setPhoneNumber(strippedToken); break; case 10: // Fax number assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateOtherData(null, strippedToken, null, null, null, null); + contact.setFaxNumber(strippedToken); break; case 11: // Cellphone number assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateOtherData(null, null, strippedToken, null, null, null); + contact.setCellphoneNumber(strippedToken); break; case 12: // Email address assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateOtherData(null, null, null, strippedToken, null, null); + contact.setEmailAddress(strippedToken); break; case 13: // Birthday assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateOtherData(null, null, null, null, strippedToken, null); + contact.setBirthday(strippedToken); break; - case 14: // Birthday + case 14: // Comment assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N // Update data - contact.updateOtherData(null, null, null, null, null, strippedToken); + contact.setComment(strippedToken); break; default: // New data entry