From 45574ccad092984bde6cdb2c9dcc6dc7451019b0 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 6 Aug 2015 14:15:36 +0200 Subject: [PATCH] =?utf8?q?These=20update=20methods=20were=20somewhere=20la?= =?utf8?q?me,=20so=20better=20take=20data-setters.=20Object-instance-sette?= =?utf8?q?rs=20however=20should=20*not*=20be=20publicly=20accessible=20as?= =?utf8?q?=20this=20may=20cause=20interferences=20if=20a=20programmer=20se?= =?utf8?q?ts=20a=20needed=20instances=20by=20mistake=20somewhere.=20Signed?= =?utf8?q?-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../client/console/ConsoleClient.java | 22 ++++++++++---- .../addressbook/contact/user/UserContact.java | 7 +++-- .../contact/ContactDatabaseFrontend.java | 30 +++++++++---------- 3 files changed, 36 insertions(+), 23 deletions(-) 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 -- 2.39.5