2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.entityownership;
10 import com.google.common.base.MoreObjects.ToStringHelper;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
13 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
14 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
17 * Implementation of EntityOwnershipListenerRegistration.
19 * @author Thomas Pantelis
21 class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegistration<DOMEntityOwnershipListener>
22 implements DOMEntityOwnershipListenerRegistration {
23 private final DistributedEntityOwnershipService service;
24 private final String entityType;
26 DistributedEntityOwnershipListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType,
27 final DistributedEntityOwnershipService service) {
29 this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
30 this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
34 protected void removeRegistration() {
35 service.unregisterListener(getEntityType(), getInstance());
39 public String getEntityType() {
44 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
45 return toStringHelper.add("entityType", entityType);