Remove opendaylight directory
[netconf.git] / netconf / abstract-topology / src / main / java / org / opendaylight / netconf / topology / RoleChangeListener.java
diff --git a/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeListener.java b/netconf/abstract-topology/src/main/java/org/opendaylight/netconf/topology/RoleChangeListener.java
new file mode 100644 (file)
index 0000000..5cf4250
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.topology;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * A listener that recieves {@link #onRoleChanged(RoleChangeDTO)} callbacks when a role change occurs
+ */
+@Beta
+public interface RoleChangeListener {
+
+    /**
+     * Called when a role change occurs
+     * @param roleChangeDTO a DTO that wraps the current ownership status
+     */
+    void onRoleChanged(RoleChangeDTO roleChangeDTO);
+
+    /**
+     * A DTO that wraps an ownership change status
+     */
+    class RoleChangeDTO {
+
+        private final boolean wasOwner;
+        private final boolean isOwner;
+        private final boolean hasOwner;
+
+        public RoleChangeDTO(boolean wasOwner, boolean isOwner, boolean hasOwner) {
+            this.wasOwner = wasOwner;
+            this.isOwner = isOwner;
+            this.hasOwner = hasOwner;
+        }
+
+        public boolean wasOwner() {
+            return wasOwner;
+        }
+
+        public boolean isOwner() {
+            return isOwner;
+        }
+
+        public boolean hasOwner() {
+            return hasOwner;
+        }
+    }
+}