2 * Copyright (C) 2016 - 2024 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jaddressbookshare.events.sharing;
19 import java.text.MessageFormat;
20 import org.mxchange.jaddressbookshare.events.sharing.type.SharingType;
21 import org.mxchange.jaddressbookshare.model.shared.ShareableAddressbook;
24 * An event fired when a user ends sharing address books
26 * @author Roland Häder<roland@mxchange.org>
28 public class EndedAddressbookSharingEvent implements ObservableAddressbookSharingEvent {
33 private static final long serialVersionUID = 152_896_748_186_018_497L;
36 * Shared address book entry
38 private final ShareableAddressbook shareableAddressbook;
41 * Constructor with address book share entry
43 * @param share Address book share entry
45 public EndedAddressbookSharingEvent (final ShareableAddressbook share) {
49 throw new NullPointerException("Parameter 'share' is null"); //NOI18N
50 } else if (share.getShareId() == null) {
52 throw new NullPointerException("share.shareId is null"); //NOI18N
53 } else if (share.getShareId() < 1) {
55 throw new IllegalArgumentException(MessageFormat.format("share.shareId={0} is invalid", share.getShareId())); //NOI18N
56 } else if (share.getShareAddressbook() == null) {
58 throw new NullPointerException("share.shareAddressbook is null"); //NOI18N
59 } else if (share.getShareAddressbook().getAddressbookId() == null) {
61 throw new NullPointerException("share.shareAddressbook.addressbookId is null"); //NOI18N
62 } else if (share.getShareAddressbook().getAddressbookId() < 1) {
64 throw new IllegalArgumentException(MessageFormat.format("share.shareAddressbook.addressbookId={0} is invalid", share.getShareAddressbook().getAddressbookId())); //NOI18N
65 } else if (share.getShareUserOwner() == null) {
67 throw new NullPointerException("share.shareUserOwner is null"); //NOI18N
68 } else if (share.getShareUserOwner().getUserId() == null) {
70 throw new NullPointerException("share.shareUserOwner.userId is null"); //NOI18N
71 } else if (share.getShareUserOwner().getUserId() < 1) {
73 throw new IllegalArgumentException(MessageFormat.format("share.shareUserOwner.userId={0} is invalid", share.getShareUserOwner().getUserId())); //NOI18N
74 } else if (share.getShareUserSharee() == null) {
76 throw new NullPointerException("share.shareUserSharee is null"); //NOI18N
77 } else if (share.getShareUserSharee().getUserId() == null) {
79 throw new NullPointerException("share.shareUserSharee.userId is null"); //NOI18N
80 } else if (share.getShareUserSharee().getUserId() < 1) {
82 throw new IllegalArgumentException(MessageFormat.format("share.shareUserSharee.userId={0} is invalid", share.getShareUserSharee().getUserId())); //NOI18N
86 this.shareableAddressbook = share;
90 public ShareableAddressbook getShareableAddressbook () {
91 return this.shareableAddressbook;
95 public SharingType getSharingType () {
97 return SharingType.ENDED;