X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Feos-dom-akka%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Feos%2Fakka%2FListenerRegistration.java;fp=opendaylight%2Fmd-sal%2Feos-dom-akka%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Feos%2Fakka%2FListenerRegistration.java;h=435babe8ec067f9a533afb5de6c0029086499ba8;hb=e1e6d8e34fd4c5c5c07c7a8063ffa94a8dbe2062;hp=0000000000000000000000000000000000000000;hpb=a99e29aa039032ca57f7945d75e6950716ed9ae7;p=controller.git diff --git a/opendaylight/md-sal/eos-dom-akka/src/main/java/org/opendaylight/controller/eos/akka/ListenerRegistration.java b/opendaylight/md-sal/eos-dom-akka/src/main/java/org/opendaylight/controller/eos/akka/ListenerRegistration.java new file mode 100644 index 0000000000..435babe8ec --- /dev/null +++ b/opendaylight/md-sal/eos-dom-akka/src/main/java/org/opendaylight/controller/eos/akka/ListenerRegistration.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.controller.eos.akka; + +import static java.util.Objects.requireNonNull; + +import com.google.common.base.MoreObjects; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener; +import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration; +import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; + +final class ListenerRegistration extends AbstractObjectRegistration + implements DOMEntityOwnershipListenerRegistration { + private final AkkaEntityOwnershipService service; + private final @NonNull String entityType; + + ListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType, + final AkkaEntityOwnershipService service) { + super(listener); + this.entityType = requireNonNull(entityType); + this.service = requireNonNull(service); + } + + @Override + public String getEntityType() { + return entityType; + } + + @Override + protected void removeRegistration() { + service.unregisterListener(entityType, getInstance()); + } + + @Override + protected MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper) { + return toStringHelper.add("entityType", entityType); + } +}