]> git.mxchange.org Git - jcontacts-core.git/blobdiff - src/org/mxchange/jcontacts/events/contact/deleted/AdminDeletedContactEvent.java
Updated copyright year
[jcontacts-core.git] / src / org / mxchange / jcontacts / events / contact / deleted / AdminDeletedContactEvent.java
index d3a2a8c60e80018f6911b346f8291a4054cc33f2..318416622eac12f23c324cd2d42a30024ff16101 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Haeder
+ * 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 Haeder<roland@mxchange.org>
+ * @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;
+       }
 
 }