From: Roland Häder <roland@mxchange.org> Date: Tue, 16 Aug 2016 08:02:45 +0000 (+0200) Subject: Renaming season has started: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bd0bc29ee0ecd58e2ebd4bd139d390efaf59023e;p=jphone-core.git Renaming season has started: - renamed cellphone to mobile (all occurences) - let's don't discrimite other mobile phones, right? --- diff --git a/src/org/mxchange/jphone/events/cellphone/deleted/AdminCellphoneNumberDeletedEvent.java b/src/org/mxchange/jphone/events/cellphone/deleted/AdminCellphoneNumberDeletedEvent.java deleted file mode 100644 index 06e405b..0000000 --- a/src/org/mxchange/jphone/events/cellphone/deleted/AdminCellphoneNumberDeletedEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.events.cellphone.deleted; - -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An event when a cell phone number has been updated - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public class AdminCellphoneNumberDeletedEvent implements AdminDeletedCellphoneNumberEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_521_758_718_691_064L; - - /** - * Added mobile provider instance - */ - private final DialableCellphoneNumber deletedCellphoneNumber; - - /** - * Constructor with deleted cell phone number - * <p> - * @param deletedCellphoneNumber Updated cell phone number - */ - public AdminCellphoneNumberDeletedEvent (final DialableCellphoneNumber deletedCellphoneNumber) { - // Set it here - this.deletedCellphoneNumber = deletedCellphoneNumber; - } - - @Override - public DialableCellphoneNumber getDeletedCellphoneNumber () { - return this.deletedCellphoneNumber; - } - -} diff --git a/src/org/mxchange/jphone/events/cellphone/deleted/AdminDeletedCellphoneNumberEvent.java b/src/org/mxchange/jphone/events/cellphone/deleted/AdminDeletedCellphoneNumberEvent.java deleted file mode 100644 index 9f35293..0000000 --- a/src/org/mxchange/jphone/events/cellphone/deleted/AdminDeletedCellphoneNumberEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.events.cellphone.deleted; - -import java.io.Serializable; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An interface for an event when a cell phone number has been updated - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public interface AdminDeletedCellphoneNumberEvent extends Serializable { - - /** - * Getter for deleted cell phone numbers - * <p> - * @return Deleted cell phone numbers - */ - DialableCellphoneNumber getDeletedCellphoneNumber (); - -} diff --git a/src/org/mxchange/jphone/events/cellphone/remove/AdminCellphoneNumberRemovedFromListEvent.java b/src/org/mxchange/jphone/events/cellphone/remove/AdminCellphoneNumberRemovedFromListEvent.java deleted file mode 100644 index 595df99..0000000 --- a/src/org/mxchange/jphone/events/cellphone/remove/AdminCellphoneNumberRemovedFromListEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.events.cellphone.remove; - -import java.util.List; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An event when a cell phone number has been updated - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public class AdminCellphoneNumberRemovedFromListEvent implements AdminRemoveCellphoneNumberFromListEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_521_758_718_691_064L; - - /** - * Updated mobile provider instance - */ - private final List<DialableCellphoneNumber> cellphoneList; - - /** - * Constructor with updated cell phone number - * <p> - * @param cellphoneList Updated cell phone number - */ - public AdminCellphoneNumberRemovedFromListEvent (final List<DialableCellphoneNumber> cellphoneList) { - // Set it here - this.cellphoneList = cellphoneList; - } - - @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List<DialableCellphoneNumber> getCellphoneList () { - return this.cellphoneList; - } - -} diff --git a/src/org/mxchange/jphone/events/cellphone/remove/AdminRemoveCellphoneNumberFromListEvent.java b/src/org/mxchange/jphone/events/cellphone/remove/AdminRemoveCellphoneNumberFromListEvent.java deleted file mode 100644 index 3dbbfe3..0000000 --- a/src/org/mxchange/jphone/events/cellphone/remove/AdminRemoveCellphoneNumberFromListEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.events.cellphone.remove; - -import java.io.Serializable; -import java.util.List; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An interface for an event when a list needs to be cleared from cell phone - * numbers. - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public interface AdminRemoveCellphoneNumberFromListEvent extends Serializable { - - /** - * Getter for cell phone numer list - * <p> - * @return Cell phone number list - */ - List<DialableCellphoneNumber> getCellphoneList (); - -} diff --git a/src/org/mxchange/jphone/events/cellphone/updated/AdminCellphoneNumberUpdatedEvent.java b/src/org/mxchange/jphone/events/cellphone/updated/AdminCellphoneNumberUpdatedEvent.java deleted file mode 100644 index 8a26c1b..0000000 --- a/src/org/mxchange/jphone/events/cellphone/updated/AdminCellphoneNumberUpdatedEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.events.cellphone.updated; - -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An event when a cell phone number has been updated - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public class AdminCellphoneNumberUpdatedEvent implements AdminUpdatedCellphoneNumberEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_521_758_718_691_064L; - - /** - * Updated mobile provider instance - */ - private final DialableCellphoneNumber updatedCellphoneNumber; - - /** - * Constructor with updated cell phone number - * <p> - * @param updatedCellphoneNumber Updated cell phone number - */ - public AdminCellphoneNumberUpdatedEvent (final DialableCellphoneNumber updatedCellphoneNumber) { - // Set it here - this.updatedCellphoneNumber = updatedCellphoneNumber; - } - - @Override - public DialableCellphoneNumber getUpdatedCellphoneNumber () { - return this.updatedCellphoneNumber; - } - -} diff --git a/src/org/mxchange/jphone/events/cellphone/updated/AdminUpdatedCellphoneNumberEvent.java b/src/org/mxchange/jphone/events/cellphone/updated/AdminUpdatedCellphoneNumberEvent.java deleted file mode 100644 index 43a4ddc..0000000 --- a/src/org/mxchange/jphone/events/cellphone/updated/AdminUpdatedCellphoneNumberEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.events.cellphone.updated; - -import java.io.Serializable; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An interface for an event when a cell phone number has been updated - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public interface AdminUpdatedCellphoneNumberEvent extends Serializable { - - /** - * Getter for updated cell phone numbers - * <p> - * @return Updated cell phone numbers - */ - DialableCellphoneNumber getUpdatedCellphoneNumber (); - -} diff --git a/src/org/mxchange/jphone/events/mobile/deleted/AdminDeletedMobileNumberEvent.java b/src/org/mxchange/jphone/events/mobile/deleted/AdminDeletedMobileNumberEvent.java new file mode 100644 index 0000000..b7188e2 --- /dev/null +++ b/src/org/mxchange/jphone/events/mobile/deleted/AdminDeletedMobileNumberEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.events.mobile.deleted; + +import java.io.Serializable; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An interface for an event when a cell phone number has been updated + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public interface AdminDeletedMobileNumberEvent extends Serializable { + + /** + * Getter for deleted cell phone numbers + * <p> + * @return Deleted cell phone numbers + */ + DialableMobileNumber getDeletedCellphoneNumber (); + +} diff --git a/src/org/mxchange/jphone/events/mobile/deleted/AdminMobileNumberDeletedEvent.java b/src/org/mxchange/jphone/events/mobile/deleted/AdminMobileNumberDeletedEvent.java new file mode 100644 index 0000000..00ba635 --- /dev/null +++ b/src/org/mxchange/jphone/events/mobile/deleted/AdminMobileNumberDeletedEvent.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.events.mobile.deleted; + +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An event when a cell phone number has been updated + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public class AdminMobileNumberDeletedEvent implements AdminDeletedMobileNumberEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_521_758_718_691_064L; + + /** + * Added mobile provider instance + */ + private final DialableMobileNumber deletedCellphoneNumber; + + /** + * Constructor with deleted cell phone number + * <p> + * @param deletedCellphoneNumber Updated cell phone number + */ + public AdminMobileNumberDeletedEvent (final DialableMobileNumber deletedCellphoneNumber) { + // Set it here + this.deletedCellphoneNumber = deletedCellphoneNumber; + } + + @Override + public DialableMobileNumber getDeletedCellphoneNumber () { + return this.deletedCellphoneNumber; + } + +} diff --git a/src/org/mxchange/jphone/events/mobile/remove/AdminMobileNumberRemovedFromListEvent.java b/src/org/mxchange/jphone/events/mobile/remove/AdminMobileNumberRemovedFromListEvent.java new file mode 100644 index 0000000..68f6460 --- /dev/null +++ b/src/org/mxchange/jphone/events/mobile/remove/AdminMobileNumberRemovedFromListEvent.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.events.mobile.remove; + +import java.util.List; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An event when a cell phone number has been updated + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public class AdminMobileNumberRemovedFromListEvent implements AdminRemoveMobileNumberFromListEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_521_758_718_691_064L; + + /** + * Updated mobile provider instance + */ + private final List<DialableMobileNumber> cellphoneList; + + /** + * Constructor with updated cell phone number + * <p> + * @param cellphoneList Updated cell phone number + */ + public AdminMobileNumberRemovedFromListEvent (final List<DialableMobileNumber> cellphoneList) { + // Set it here + this.cellphoneList = cellphoneList; + } + + @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List<DialableMobileNumber> getCellphoneList () { + return this.cellphoneList; + } + +} diff --git a/src/org/mxchange/jphone/events/mobile/remove/AdminRemoveMobileNumberFromListEvent.java b/src/org/mxchange/jphone/events/mobile/remove/AdminRemoveMobileNumberFromListEvent.java new file mode 100644 index 0000000..b558eae --- /dev/null +++ b/src/org/mxchange/jphone/events/mobile/remove/AdminRemoveMobileNumberFromListEvent.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.events.mobile.remove; + +import java.io.Serializable; +import java.util.List; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An interface for an event when a list needs to be cleared from cell phone + * numbers. + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public interface AdminRemoveMobileNumberFromListEvent extends Serializable { + + /** + * Getter for cell phone numer list + * <p> + * @return Cell phone number list + */ + List<DialableMobileNumber> getCellphoneList (); + +} diff --git a/src/org/mxchange/jphone/events/mobile/updated/AdminMobileNumberUpdatedEvent.java b/src/org/mxchange/jphone/events/mobile/updated/AdminMobileNumberUpdatedEvent.java new file mode 100644 index 0000000..5647d8a --- /dev/null +++ b/src/org/mxchange/jphone/events/mobile/updated/AdminMobileNumberUpdatedEvent.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.events.mobile.updated; + +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An event when a cell phone number has been updated + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public class AdminMobileNumberUpdatedEvent implements AdminUpdatedMobileNumberEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_521_758_718_691_064L; + + /** + * Updated mobile provider instance + */ + private final DialableMobileNumber updatedCellphoneNumber; + + /** + * Constructor with updated cell phone number + * <p> + * @param updatedCellphoneNumber Updated cell phone number + */ + public AdminMobileNumberUpdatedEvent (final DialableMobileNumber updatedCellphoneNumber) { + // Set it here + this.updatedCellphoneNumber = updatedCellphoneNumber; + } + + @Override + public DialableMobileNumber getUpdatedCellphoneNumber () { + return this.updatedCellphoneNumber; + } + +} diff --git a/src/org/mxchange/jphone/events/mobile/updated/AdminUpdatedMobileNumberEvent.java b/src/org/mxchange/jphone/events/mobile/updated/AdminUpdatedMobileNumberEvent.java new file mode 100644 index 0000000..1cc4d14 --- /dev/null +++ b/src/org/mxchange/jphone/events/mobile/updated/AdminUpdatedMobileNumberEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.events.mobile.updated; + +import java.io.Serializable; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An interface for an event when a cell phone number has been updated + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public interface AdminUpdatedMobileNumberEvent extends Serializable { + + /** + * Getter for updated cell phone numbers + * <p> + * @return Updated cell phone numbers + */ + DialableMobileNumber getUpdatedCellphoneNumber (); + +} diff --git a/src/org/mxchange/jphone/exceptions/CellphoneNotLinkedException.java b/src/org/mxchange/jphone/exceptions/CellphoneNotLinkedException.java deleted file mode 100644 index 037b0bb..0000000 --- a/src/org/mxchange/jphone/exceptions/CellphoneNotLinkedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * An exception thrown when a cell phone number is not linked but should be. - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public class CellphoneNotLinkedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_964_581_681_985_597L; - - /** - * Counstructor with cell phone instance - * <p> - * @param cellphoneNumber Cell phone instance - */ - public CellphoneNotLinkedException (final DialableCellphoneNumber cellphoneNumber) { - // Call super constructor with message - super(MessageFormat.format("cellphoneNumber={0} with phoneId={1} is not linked.", cellphoneNumber, cellphoneNumber.getPhoneId())); //NOI18N - } - -} diff --git a/src/org/mxchange/jphone/exceptions/MobileNumberNotLinkedException.java b/src/org/mxchange/jphone/exceptions/MobileNumberNotLinkedException.java new file mode 100644 index 0000000..4b959db --- /dev/null +++ b/src/org/mxchange/jphone/exceptions/MobileNumberNotLinkedException.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * An exception thrown when a cell phone number is not linked but should be. + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public class MobileNumberNotLinkedException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_964_581_681_985_597L; + + /** + * Counstructor with cell phone instance + * <p> + * @param cellphoneNumber Cell phone instance + */ + public MobileNumberNotLinkedException (final DialableMobileNumber cellphoneNumber) { + // Call super constructor with message + super(MessageFormat.format("cellphoneNumber={0} with phoneId={1} is not linked.", cellphoneNumber, cellphoneNumber.getPhoneId())); //NOI18N + } + +} diff --git a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java deleted file mode 100644 index d2e835f..0000000 --- a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.phonenumbers.cellphone; - -import java.util.Calendar; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider; -import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; - -/** - * A POJO for dialable cellphone numbers - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -@Entity (name = "cellphone_numbers") -@Table (name = "cellphone_numbers") -@NamedQueries ( - { - @NamedQuery (name = "AllCellphoneNumbers", query = "SELECT c FROM cellphone_numbers AS c ORDER BY c.phoneId ASC"), - @NamedQuery (name = "SearchCellphoneId", query = "SELECT c FROM cellphone_numbers AS c WHERE c.phoneId = :cellphoneId") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class CellphoneNumber implements DialableCellphoneNumber { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 13_859_879_482_106L; - - /** - * Connection to table "cellphone_provider" (for dial prefix and more data) - */ - @JoinColumn (name = "cellphone_provider_id", nullable = false) - @OneToOne (targetEntity = CellphoneProvider.class, cascade = CascadeType.REFRESH, optional = false) - private MobileProvider cellphoneProvider; - - /** - * Timestamp when this entry has been created - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "cellphone_entry_created", nullable = false, updatable = false) - private Calendar phoneEntryCreated; - - /** - * Timestamp when this entry has been created - */ - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "phone_entry_updated", updatable = false) - private Calendar phoneEntryUpdated; - - /** - * Id number - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "cellphone_id", nullable = false, updatable = false) - private Long phoneId; - - /** - * Number without prefix to dial - */ - @Basic (optional = false) - @Column (name = "cellphone_number", nullable = false) - private Long phoneNumber; - - /** - * Default constructor - */ - public CellphoneNumber () { - } - - /** - * Constructor with cellphone provider and number - * <p> - * @param cellphoneProvider Cellphone provider instance - * @param cellphoneNumber Cellphone number - */ - public CellphoneNumber (final MobileProvider cellphoneProvider, final Long cellphoneNumber) { - // Call default constructor - this(); - - // Set all values - this.cellphoneProvider = cellphoneProvider; - this.phoneNumber = cellphoneNumber; - } - - @Override - public void copyAll (final DialableCellphoneNumber sourceNumber) { - // Copy all - this.setCellphoneProvider(sourceNumber.getCellphoneProvider()); - this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated()); - this.setPhoneId(sourceNumber.getPhoneId()); - this.setPhoneNumber(sourceNumber.getPhoneNumber()); - } - - @Override - public boolean equals (final Object object) { - if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final DialableCellphoneNumber other = (DialableCellphoneNumber) object; - - if (!Objects.equals(this.getCellphoneProvider(), other.getCellphoneProvider())) { - return false; - } else if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) { - return false; - } - - return true; - } - - @Override - public MobileProvider getCellphoneProvider () { - return this.cellphoneProvider; - } - - @Override - public void setCellphoneProvider (final MobileProvider cellphoneProvider) { - this.cellphoneProvider = cellphoneProvider; - } - - @Override - @Deprecated - public Integer getPhoneAreaCode () { - throw new UnsupportedOperationException("Cellphone numbers don't have area codes. Please fix your code."); //NOI18N - } - - @Override - @Deprecated - public void setPhoneAreaCode (final Integer phoneAreaCode) { - throw new UnsupportedOperationException("Cellphone numbers don't have area codes. Please fix your code."); //NOI18N - } - - @Override - @Deprecated - public Country getPhoneCountry () { - throw new UnsupportedOperationException("The country code is provided by MobileProvider."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - @Deprecated - public void setPhoneCountry (final Country country) { - throw new UnsupportedOperationException("The country code is provided by MobileProvider."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getPhoneEntryCreated () { - return this.phoneEntryCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setPhoneEntryCreated (final Calendar phoneEntryCreated) { - this.phoneEntryCreated = phoneEntryCreated; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getPhoneEntryUpdated () { - return this.phoneEntryUpdated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setPhoneEntryUpdated (final Calendar phoneEntryUpdated) { - this.phoneEntryUpdated = phoneEntryUpdated; - } - - @Override - public Long getPhoneId () { - return this.phoneId; - } - - @Override - public void setPhoneId (final Long phoneId) { - this.phoneId = phoneId; - } - - @Override - public Long getPhoneNumber () { - return this.phoneNumber; - } - - @Override - public void setPhoneNumber (final Long phoneNumber) { - this.phoneNumber = phoneNumber; - } - - @Override - public int hashCode () { - int hash = 5; - - hash = 97 * hash + Objects.hashCode(this.getCellphoneProvider()); - hash = 97 * hash + Objects.hashCode(this.getPhoneNumber()); - - return hash; - } - -} diff --git a/src/org/mxchange/jphone/phonenumbers/cellphone/DialableCellphoneNumber.java b/src/org/mxchange/jphone/phonenumbers/cellphone/DialableCellphoneNumber.java deleted file mode 100644 index ce9021e..0000000 --- a/src/org/mxchange/jphone/phonenumbers/cellphone/DialableCellphoneNumber.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.phonenumbers.cellphone; - -import org.mxchange.jphone.phonenumbers.DialableNumber; -import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; - -/** - * A POJO for dialable cellphone numbers with carriers. - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public interface DialableCellphoneNumber extends DialableNumber { - - /** - * Getter for SMS provider instance - * <p> - * @return SMS provider instance - */ - MobileProvider getCellphoneProvider (); - - /** - * Setter for SMS provider instance - * <p> - * @param cellphoneProvider SMS provider instance - */ - void setCellphoneProvider (final MobileProvider cellphoneProvider); - - /** - * Copy all fields from source object to this - * <p> - * @param sourceNumber Source number object - */ - void copyAll (final DialableCellphoneNumber sourceNumber); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); -} diff --git a/src/org/mxchange/jphone/phonenumbers/mobile/DialableMobileNumber.java b/src/org/mxchange/jphone/phonenumbers/mobile/DialableMobileNumber.java new file mode 100644 index 0000000..4cad25b --- /dev/null +++ b/src/org/mxchange/jphone/phonenumbers/mobile/DialableMobileNumber.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.phonenumbers.mobile; + +import org.mxchange.jphone.phonenumbers.DialableNumber; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; + +/** + * A POJO for dialable mobile numbers with carriers. + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public interface DialableMobileNumber extends DialableNumber { + + /** + * Getter for mobile provider + * <p> + * @return Mobile provider + */ + MobileProvider getMobileProvider (); + + /** + * Setter for mobile provider + * <p> + * @param mobileProvider Mobile provider + */ + void setMobileProvider (final MobileProvider mobileProvider); + + /** + * Copy all fields from source object to this + * <p> + * @param sourceNumber Source number object + */ + void copyAll (final DialableMobileNumber sourceNumber); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); +} diff --git a/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java b/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java new file mode 100644 index 0000000..49baf19 --- /dev/null +++ b/src/org/mxchange/jphone/phonenumbers/mobile/MobileNumber.java @@ -0,0 +1,236 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.phonenumbers.mobile; + +import java.util.Calendar; +import java.util.Objects; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import org.mxchange.jcountry.data.Country; +import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider; +import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; + +/** + * A POJO for dialable cellphone numbers + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +@Entity (name = "mobile_numbers") +@Table (name = "mobile_numbers") +@NamedQueries ( + { + @NamedQuery (name = "AllCellphoneNumbers", query = "SELECT c FROM mobile_numbers AS c ORDER BY c.phoneId ASC"), + @NamedQuery (name = "SearchCellphoneId", query = "SELECT c FROM mobile_numbers AS c WHERE c.phoneId = :cellphoneId") + } +) +@SuppressWarnings ("PersistenceUnitPresent") +public class MobileNumber implements DialableMobileNumber { + + /** + * Serial number + */ + @Transient + private static final long serialVersionUID = 13_859_879_482_106L; + + /** + * Connection to table "mobile_provider" (for dial prefix and more data) + */ + @JoinColumn (name = "mobile_provider_id", nullable = false) + @OneToOne (targetEntity = CellphoneProvider.class, cascade = CascadeType.REFRESH, optional = false) + private MobileProvider mobileProvider; + + /** + * Timestamp when this entry has been created + */ + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "mobile_entry_created", nullable = false, updatable = false) + private Calendar phoneEntryCreated; + + /** + * Timestamp when this entry has been created + */ + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "mobile_entry_updated", updatable = false) + private Calendar phoneEntryUpdated; + + /** + * Id number + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "mobile_id", nullable = false, updatable = false) + private Long phoneId; + + /** + * Number without prefix to dial + */ + @Basic (optional = false) + @Column (name = "mobile_number", nullable = false) + private Long phoneNumber; + + /** + * Default constructor + */ + public MobileNumber () { + } + + /** + * Constructor with cellphone provider and number + * <p> + * @param mobileProvider Mobile provider + * @param mobileNumber Mobile number + */ + public MobileNumber (final MobileProvider mobileProvider, final Long mobileNumber) { + // Call default constructor + this(); + + // Set all values + this.mobileProvider = mobileProvider; + this.phoneNumber = mobileNumber; + } + + @Override + public void copyAll (final DialableMobileNumber sourceNumber) { + // Copy all + this.setMobileProvider(sourceNumber.getMobileProvider()); + this.setPhoneEntryCreated(sourceNumber.getPhoneEntryCreated()); + this.setPhoneId(sourceNumber.getPhoneId()); + this.setPhoneNumber(sourceNumber.getPhoneNumber()); + } + + @Override + public boolean equals (final Object object) { + if (null == object) { + return false; + } else if (this.getClass() != object.getClass()) { + return false; + } + + final DialableMobileNumber other = (DialableMobileNumber) object; + + if (!Objects.equals(this.getMobileProvider(), other.getMobileProvider())) { + return false; + } else if (!Objects.equals(this.getPhoneNumber(), other.getPhoneNumber())) { + return false; + } + + return true; + } + + @Override + public MobileProvider getMobileProvider () { + return this.mobileProvider; + } + + @Override + public void setMobileProvider (final MobileProvider mobileProvider) { + this.mobileProvider = mobileProvider; + } + + @Override + @Deprecated + public Integer getPhoneAreaCode () { + throw new UnsupportedOperationException("Cellphone numbers don't have area codes. Please fix your code."); //NOI18N + } + + @Override + @Deprecated + public void setPhoneAreaCode (final Integer phoneAreaCode) { + throw new UnsupportedOperationException("Cellphone numbers don't have area codes. Please fix your code."); //NOI18N + } + + @Override + @Deprecated + public Country getPhoneCountry () { + throw new UnsupportedOperationException("The country code is provided by MobileProvider."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + @Deprecated + public void setPhoneCountry (final Country country) { + throw new UnsupportedOperationException("The country code is provided by MobileProvider."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Calendar getPhoneEntryCreated () { + return this.phoneEntryCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setPhoneEntryCreated (final Calendar phoneEntryCreated) { + this.phoneEntryCreated = phoneEntryCreated; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Calendar getPhoneEntryUpdated () { + return this.phoneEntryUpdated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setPhoneEntryUpdated (final Calendar phoneEntryUpdated) { + this.phoneEntryUpdated = phoneEntryUpdated; + } + + @Override + public Long getPhoneId () { + return this.phoneId; + } + + @Override + public void setPhoneId (final Long phoneId) { + this.phoneId = phoneId; + } + + @Override + public Long getPhoneNumber () { + return this.phoneNumber; + } + + @Override + public void setPhoneNumber (final Long phoneNumber) { + this.phoneNumber = phoneNumber; + } + + @Override + public int hashCode () { + int hash = 5; + + hash = 97 * hash + Objects.hashCode(this.getMobileProvider()); + hash = 97 * hash + Objects.hashCode(this.getPhoneNumber()); + + return hash; + } + +} diff --git a/src/org/mxchange/jphone/utils/PhoneUtils.java b/src/org/mxchange/jphone/utils/PhoneUtils.java index 94e28ed..ed9bba6 100644 --- a/src/org/mxchange/jphone/utils/PhoneUtils.java +++ b/src/org/mxchange/jphone/utils/PhoneUtils.java @@ -1,125 +1,125 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jphone.utils; - -import java.io.Serializable; -import java.util.Objects; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; - -/** - * - * @author Roland Haeder<roland@mxchange.org> - */ -public class PhoneUtils implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 183_598_328_176_450L; - - /** - * Checks if both are the same - * <p> - * @param cellphoneNumber Cellphone number 1 - * @param otherNumber Cellphone number 2 - * <p> - * @return Whether both are the same number - */ - public static boolean isSameCellphoneNumber (final DialableCellphoneNumber cellphoneNumber, final DialableCellphoneNumber otherNumber) { - // Test object equality first - if (Objects.equals(cellphoneNumber, otherNumber)) { - // Both the same object (null/null or same object) - return true; - } else if (((null == cellphoneNumber) && (otherNumber instanceof DialableCellphoneNumber)) || ((null == otherNumber) && (cellphoneNumber instanceof DialableCellphoneNumber))) { - // One is null the other not - return false; - } - - // Now compare deeper - @SuppressWarnings ("null") - boolean sameProvider = Objects.equals(cellphoneNumber.getCellphoneProvider(), otherNumber.getCellphoneProvider()); - boolean sameNumber = Objects.equals(cellphoneNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); - - // All are the same? - return (sameProvider && sameNumber); - } - - /** - * Checks if both are the same - * <p> - * @param faxNumber First fax number - * @param otherNumber Second fax number - * <p> - * @return Whether both are the same - */ - public static boolean isSameFaxNumber (final DialableFaxNumber faxNumber, DialableFaxNumber otherNumber) { - // Test object equality first - if (Objects.equals(faxNumber, otherNumber)) { - // Both the same object (null/null or same object) - return true; - } else if (((null == faxNumber) && (otherNumber instanceof DialableFaxNumber)) || ((null == otherNumber) && (faxNumber instanceof DialableFaxNumber))) { - // One is null the other not - return false; - } - - // Now compare deeper - @SuppressWarnings ("null") - boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry()); - boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode()); - boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); - - // All are the same? - return (sameCountry && sameAreaCode && sameNumber); - } - - /** - * Checks if both are the same - * <p> - * @param landLineNumber First land-line number - * @param otherNumber Second land-line number - * <p> - * @return Whether both are the same - */ - public static boolean isSameLandLineNumber (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber otherNumber) { - // Test object equality first - if (Objects.equals(landLineNumber, otherNumber)) { - // Both the same object (null/null or same object) - return true; - } else if (((null == landLineNumber) && (otherNumber instanceof DialableLandLineNumber)) || ((null == otherNumber) && (landLineNumber instanceof DialableLandLineNumber))) { - // One is null the other not - return false; - } - - // Now compare deeper - @SuppressWarnings ("null") - boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry()); - boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode()); - boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); - - // All are the same? - return (sameCountry && sameAreaCode && sameNumber); - } - - /** - * Private constructor for utility classes - */ - private PhoneUtils () { - } - -} +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jphone.utils; + +import java.io.Serializable; +import java.util.Objects; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; + +/** + * + * @author Roland Haeder<roland@mxchange.org> + */ +public class PhoneUtils implements Serializable { + + /** + * Serial number + */ + private static final long serialVersionUID = 183_598_328_176_450L; + + /** + * Checks if both are the same + * <p> + * @param cellphoneNumber Cellphone number 1 + * @param otherNumber Cellphone number 2 + * <p> + * @return Whether both are the same number + */ + public static boolean isSameCellphoneNumber (final DialableMobileNumber cellphoneNumber, final DialableMobileNumber otherNumber) { + // Test object equality first + if (Objects.equals(cellphoneNumber, otherNumber)) { + // Both the same object (null/null or same object) + return true; + } else if (((null == cellphoneNumber) && (otherNumber instanceof DialableMobileNumber)) || ((null == otherNumber) && (cellphoneNumber instanceof DialableMobileNumber))) { + // One is null the other not + return false; + } + + // Now compare deeper + @SuppressWarnings ("null") + boolean sameProvider = Objects.equals(cellphoneNumber.getMobileProvider(), otherNumber.getMobileProvider()); + boolean sameNumber = Objects.equals(cellphoneNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); + + // All are the same? + return (sameProvider && sameNumber); + } + + /** + * Checks if both are the same + * <p> + * @param faxNumber First fax number + * @param otherNumber Second fax number + * <p> + * @return Whether both are the same + */ + public static boolean isSameFaxNumber (final DialableFaxNumber faxNumber, DialableFaxNumber otherNumber) { + // Test object equality first + if (Objects.equals(faxNumber, otherNumber)) { + // Both the same object (null/null or same object) + return true; + } else if (((null == faxNumber) && (otherNumber instanceof DialableFaxNumber)) || ((null == otherNumber) && (faxNumber instanceof DialableFaxNumber))) { + // One is null the other not + return false; + } + + // Now compare deeper + @SuppressWarnings ("null") + boolean sameCountry = Objects.equals(faxNumber.getPhoneCountry(), otherNumber.getPhoneCountry()); + boolean sameAreaCode = Objects.equals(faxNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode()); + boolean sameNumber = Objects.equals(faxNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); + + // All are the same? + return (sameCountry && sameAreaCode && sameNumber); + } + + /** + * Checks if both are the same + * <p> + * @param landLineNumber First land-line number + * @param otherNumber Second land-line number + * <p> + * @return Whether both are the same + */ + public static boolean isSameLandLineNumber (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber otherNumber) { + // Test object equality first + if (Objects.equals(landLineNumber, otherNumber)) { + // Both the same object (null/null or same object) + return true; + } else if (((null == landLineNumber) && (otherNumber instanceof DialableLandLineNumber)) || ((null == otherNumber) && (landLineNumber instanceof DialableLandLineNumber))) { + // One is null the other not + return false; + } + + // Now compare deeper + @SuppressWarnings ("null") + boolean sameCountry = Objects.equals(landLineNumber.getPhoneCountry(), otherNumber.getPhoneCountry()); + boolean sameAreaCode = Objects.equals(landLineNumber.getPhoneAreaCode(), otherNumber.getPhoneAreaCode()); + boolean sameNumber = Objects.equals(landLineNumber.getPhoneNumber(), otherNumber.getPhoneNumber()); + + // All are the same? + return (sameCountry && sameAreaCode && sameNumber); + } + + /** + * Private constructor for utility classes + */ + private PhoneUtils () { + } + +}