/*
- * Copyright (C) 2016 Roland Häder
+ * Copyright (C) 2016 - 2020 Free Software Foundation
*
* 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
*/
package org.mxchange.jcontacts.events.contact.deleted;
-import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
+import java.text.MessageFormat;
+import org.mxchange.jcontacts.model.contact.Contact;
/**
- * An interface for events being fired when an administrator deleted a contact.
+ * An event being fired when the administrator has deleted a contact
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface AdminDeletedContactEvent extends Serializable {
+public class AdminDeletedContactEvent implements ObservableAdminDeletedContactEvent {
/**
- * Getter for deleted contact instance
+ * Serial number
+ */
+ private static final long serialVersionUID = 14_785_787_174_676_290L;
+
+ /**
+ * Deleted contact instance
+ */
+ private final Contact deletedContact;
+
+ /**
+ * Constructor with deleted contact instance
* <p>
- * @return Deleted contact instance
+ * @param deletedContact Deleted contact instance
*/
- Contact getDeletedContact ();
+ public AdminDeletedContactEvent (final Contact deletedContact) {
+ // Is the contact instance valid?
+ if (null == deletedContact) {
+ // Throw NPE
+ throw new NullPointerException("deletedContact is null"); //NOI18N
+ } else if (deletedContact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("deletedContact.contactId is null"); //NOI18N
+ } else if (deletedContact.getContactId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("deletedContact.contactId={0} is invalid.", deletedContact.getContactId())); //NOI18N
+ }
+
+ // Set it here
+ this.deletedContact = deletedContact;
+ }
+
+ @Override
+ public Contact getDeletedContact () {
+ return this.deletedContact;
+ }
}