2e0f4b4f2d9b748e5e784736e52d28d264e7df8c
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / entityownership / DistributedEntityOwnershipListenerRegistration.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.entityownership;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
12 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
13 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
14
15 /**
16  * Implementation of EntityOwnershipListenerRegistration.
17  *
18  * @author Thomas Pantelis
19  */
20 class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegistration<DOMEntityOwnershipListener>
21         implements DOMEntityOwnershipListenerRegistration {
22     private final DistributedEntityOwnershipService service;
23     private final String entityType;
24
25     DistributedEntityOwnershipListenerRegistration(DOMEntityOwnershipListener listener, String entityType,
26             DistributedEntityOwnershipService service) {
27         super(listener);
28         this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
29         this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
30     }
31
32     @Override
33     protected void removeRegistration() {
34         service.unregisterListener(getEntityType(), getInstance());
35     }
36
37     @Override
38     public String getEntityType() {
39         return entityType;
40     }
41
42     @Override
43     public String toString() {
44         return "DistributedEntityOwnershipListenerRegistration [entityType=" + getEntityType()
45                 + ", listener=" + getInstance() + "]";
46     }
47 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.