From ff55579e653d013b14f267df29bdf76cd63964a9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 8 Oct 2018 13:53:28 +0200 Subject: [PATCH] Migrate entity ownership to JDT annotations This removes the use of javax.annotation nullable annotations to remove import-package. Change-Id: If89fd8302e1e709c23c6802e3e10341f96bcfe00 JIRA: MDSAL-373 Signed-off-by: Robert Varga --- ...ndingDOMEntityOwnershipServiceAdapter.java | 32 ++++++++++--------- .../mdsal/eos/binding/api/Entity.java | 6 ++-- .../binding/api/EntityOwnershipChange.java | 6 ++-- .../binding/api/EntityOwnershipService.java | 11 +++---- .../CandidateAlreadyRegisteredException.java | 18 +++++------ .../mdsal/eos/common/api/GenericEntity.java | 23 +++++++------ .../api/GenericEntityOwnershipChange.java | 21 ++++++------ ...icEntityOwnershipListenerRegistration.java | 4 +-- .../api/GenericEntityOwnershipService.java | 10 +++--- .../eos/common/api/GenericEntityTest.java | 5 ++- ...cEntityOwnershipCandidateRegistration.java | 12 +++---- ...icEntityOwnershipListenerRegistration.java | 14 ++++---- .../mdsal/eos/dom/api/DOMEntity.java | 7 ++-- .../eos/dom/api/DOMEntityOwnershipChange.java | 9 ++---- .../dom/api/DOMEntityOwnershipService.java | 16 +++------- 15 files changed, 89 insertions(+), 105 deletions(-) diff --git a/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingDOMEntityOwnershipServiceAdapter.java b/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingDOMEntityOwnershipServiceAdapter.java index 6fd10707e9..97cdb69718 100644 --- a/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingDOMEntityOwnershipServiceAdapter.java +++ b/entityownership/mdsal-eos-binding-adapter/src/main/java/org/opendaylight/mdsal/eos/binding/dom/adapter/BindingDOMEntityOwnershipServiceAdapter.java @@ -7,9 +7,10 @@ */ package org.opendaylight.mdsal.eos.binding.dom.adapter; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.util.Optional; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.mdsal.eos.binding.api.Entity; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipCandidateRegistration; @@ -31,39 +32,40 @@ import org.slf4j.LoggerFactory; public class BindingDOMEntityOwnershipServiceAdapter implements EntityOwnershipService, AutoCloseable { static final Logger LOG = LoggerFactory.getLogger(BindingDOMEntityOwnershipServiceAdapter.class); - private final DOMEntityOwnershipService domService; - private final BindingNormalizedNodeSerializer conversionCodec; + private final @NonNull DOMEntityOwnershipService domService; + private final @NonNull BindingNormalizedNodeSerializer conversionCodec; - public BindingDOMEntityOwnershipServiceAdapter(@Nonnull DOMEntityOwnershipService domService, - @Nonnull BindingNormalizedNodeSerializer conversionCodec) { - this.domService = Preconditions.checkNotNull(domService); - this.conversionCodec = Preconditions.checkNotNull(conversionCodec); + public BindingDOMEntityOwnershipServiceAdapter(final @NonNull DOMEntityOwnershipService domService, + @NonNull final BindingNormalizedNodeSerializer conversionCodec) { + this.domService = requireNonNull(domService); + this.conversionCodec = requireNonNull(conversionCodec); } @Override - public EntityOwnershipCandidateRegistration registerCandidate(Entity entity) + public EntityOwnershipCandidateRegistration registerCandidate(final Entity entity) throws CandidateAlreadyRegisteredException { return new BindingEntityOwnershipCandidateRegistration( domService.registerCandidate(toDOMEntity(entity)), entity); } @Override - public EntityOwnershipListenerRegistration registerListener(String entityType, EntityOwnershipListener listener) { - return new BindingEntityOwnershipListenerRegistration(entityType, listener, domService - .registerListener(entityType, new DOMEntityOwnershipListenerAdapter(listener, conversionCodec))); + public EntityOwnershipListenerRegistration registerListener(final String entityType, + final EntityOwnershipListener listener) { + return new BindingEntityOwnershipListenerRegistration(entityType, listener, + domService.registerListener(entityType, new DOMEntityOwnershipListenerAdapter(listener, conversionCodec))); } @Override - public Optional getOwnershipState(Entity forEntity) { + public Optional getOwnershipState(final Entity forEntity) { return domService.getOwnershipState(toDOMEntity(forEntity)); } @Override - public boolean isCandidateRegistered(Entity forEntity) { + public boolean isCandidateRegistered(final Entity forEntity) { return domService.isCandidateRegistered(toDOMEntity(forEntity)); } - private DOMEntity toDOMEntity(Entity entity) { + private @NonNull DOMEntity toDOMEntity(final Entity entity) { return new DOMEntity(entity.getType(), conversionCodec.toYangInstanceIdentifier(entity.getIdentifier())); } diff --git a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java index 7f5e024bea..3b1cee14d7 100644 --- a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java +++ b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/Entity.java @@ -9,7 +9,7 @@ package org.opendaylight.mdsal.eos.binding.api; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.GenericEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.EntityKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -28,7 +28,7 @@ public class Entity extends GenericEntity> { * @param type the entity type * @param id the entity id. */ - public Entity(@Nonnull final String type, @Nonnull final InstanceIdentifier id) { + public Entity(final @NonNull String type, final @NonNull InstanceIdentifier id) { super(type, id); } @@ -39,7 +39,7 @@ public class Entity extends GenericEntity> { * @param type the type of the entity * @param entityName the name of the entity used to construct a general-entity InstanceIdentifier */ - public Entity(@Nonnull String type, @Nonnull String entityName) { + public Entity(final @NonNull String type, final @NonNull String entityName) { super(type, InstanceIdentifier.builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang .mdsal.core.general.entity.rev150930.Entity.class, new EntityKey(Preconditions.checkNotNull(entityName, "entityName should not be null"))).build()); diff --git a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipChange.java b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipChange.java index 6bf801f445..a1ea425da8 100644 --- a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipChange.java +++ b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipChange.java @@ -8,7 +8,7 @@ package org.opendaylight.mdsal.eos.binding.api; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipChange; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -21,11 +21,11 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @Beta public class EntityOwnershipChange extends GenericEntityOwnershipChange, Entity> { - public EntityOwnershipChange(@Nonnull final Entity entity, @Nonnull final EntityOwnershipChangeState state) { + public EntityOwnershipChange(final @NonNull Entity entity, final @NonNull EntityOwnershipChangeState state) { super(entity, state, false); } - public EntityOwnershipChange(@Nonnull final Entity entity, @Nonnull final EntityOwnershipChangeState state, + public EntityOwnershipChange(final @NonNull Entity entity, final @NonNull EntityOwnershipChangeState state, final boolean inJeopardy) { super(entity, state, inJeopardy); } diff --git a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipService.java b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipService.java index f2532d230d..a32cb6e101 100644 --- a/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipService.java +++ b/entityownership/mdsal-eos-binding-api/src/main/java/org/opendaylight/mdsal/eos/binding/api/EntityOwnershipService.java @@ -9,7 +9,6 @@ package org.opendaylight.mdsal.eos.binding.api; import com.google.common.annotations.Beta; import java.util.Optional; -import javax.annotation.Nonnull; import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipService; @@ -25,16 +24,16 @@ public interface EntityOwnershipService extends GenericEntityOwnershipService, Entity, EntityOwnershipListener> { @Override - EntityOwnershipCandidateRegistration registerCandidate(@Nonnull Entity entity) + EntityOwnershipCandidateRegistration registerCandidate(Entity entity) throws CandidateAlreadyRegisteredException; @Override - EntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, - @Nonnull EntityOwnershipListener listener); + EntityOwnershipListenerRegistration registerListener(String entityType, + EntityOwnershipListener listener); @Override - Optional getOwnershipState(@Nonnull Entity forEntity); + Optional getOwnershipState(Entity forEntity); @Override - boolean isCandidateRegistered(@Nonnull Entity forEntity); + boolean isCandidateRegistered(Entity forEntity); } diff --git a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/CandidateAlreadyRegisteredException.java b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/CandidateAlreadyRegisteredException.java index 8f1871c8d0..07f8eaf5ad 100644 --- a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/CandidateAlreadyRegisteredException.java +++ b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/CandidateAlreadyRegisteredException.java @@ -5,11 +5,11 @@ * 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.mdsal.eos.common.api; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Path; /** @@ -19,12 +19,11 @@ import org.opendaylight.yangtools.concepts.Path; public class CandidateAlreadyRegisteredException extends Exception { private static final long serialVersionUID = 1L; - private final GenericEntity entity; + private final @NonNull GenericEntity entity; - public > CandidateAlreadyRegisteredException(@Nonnull GenericEntity entity) { - super(String.format("Candidate has already been registered for %s", - Preconditions.checkNotNull(entity, "entity should not be null"))); - this.entity = entity; + public > CandidateAlreadyRegisteredException(@NonNull final GenericEntity entity) { + super("Candidate has already been registered for " + entity); + this.entity = requireNonNull(entity, "entity should not be null"); } /** @@ -35,8 +34,7 @@ public class CandidateAlreadyRegisteredException extends Exception { * @return the entity. */ @SuppressWarnings("unchecked") - @Nonnull - public > GenericEntity getEntity() { + public > @NonNull GenericEntity getEntity() { return (GenericEntity) entity; } } diff --git a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntity.java b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntity.java index 90c7fd6293..2e7a0bec9d 100644 --- a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntity.java +++ b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntity.java @@ -7,9 +7,10 @@ */ package org.opendaylight.mdsal.eos.common.api; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.concepts.Path; @@ -43,21 +44,20 @@ import org.opendaylight.yangtools.concepts.Path; public class GenericEntity> implements Serializable, Identifiable { private static final long serialVersionUID = 1L; - private final String type; - private final T id; + private final @NonNull String type; + private final @NonNull T id; - protected GenericEntity(@Nonnull String type, @Nonnull T id) { - this.type = Preconditions.checkNotNull(type, "type should not be null"); - this.id = Preconditions.checkNotNull(id, "id should not be null"); + protected GenericEntity(@NonNull final String type, @NonNull final T id) { + this.type = requireNonNull(type, "type should not be null"); + this.id = requireNonNull(id, "id should not be null"); } /** * Gets the id of the entity. * @return the id. */ - @Nonnull @Override - public final T getIdentifier() { + public final @NonNull T getIdentifier() { return id; } @@ -65,14 +65,13 @@ public class GenericEntity> implements Serializable, Identifia * Gets the type of the entity. * @return the type. */ - @Nonnull - public final String getType() { + public final @NonNull String getType() { return type; } @SuppressWarnings("unchecked") @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } diff --git a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipChange.java b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipChange.java index 5e0a499979..16e3566aec 100644 --- a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipChange.java +++ b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipChange.java @@ -7,8 +7,9 @@ */ package org.opendaylight.mdsal.eos.common.api; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Path; /** @@ -20,18 +21,18 @@ import org.opendaylight.yangtools.concepts.Path; * @param the GenericEntity type */ public class GenericEntityOwnershipChange

, E extends GenericEntity

> { - private final E entity; - private final EntityOwnershipChangeState state; + private final @NonNull E entity; + private final @NonNull EntityOwnershipChangeState state; private final boolean inJeopardy; - public GenericEntityOwnershipChange(@Nonnull final E entity, @Nonnull final EntityOwnershipChangeState state) { + public GenericEntityOwnershipChange(final @NonNull E entity, final @NonNull EntityOwnershipChangeState state) { this(entity, state, false); } - public GenericEntityOwnershipChange(@Nonnull final E entity, @Nonnull final EntityOwnershipChangeState state, + public GenericEntityOwnershipChange(final @NonNull E entity, final @NonNull EntityOwnershipChangeState state, final boolean inJeopardy) { - this.entity = Preconditions.checkNotNull(entity, "entity can't be null"); - this.state = Preconditions.checkNotNull(state, "state can't be null"); + this.entity = requireNonNull(entity, "entity can't be null"); + this.state = requireNonNull(state, "state can't be null"); this.inJeopardy = inJeopardy; } @@ -39,7 +40,7 @@ public class GenericEntityOwnershipChange

, E extends GenericEn * Returns the entity whose ownership status changed. * @return the entity */ - @Nonnull public E getEntity() { + public @NonNull E getEntity() { return entity; } @@ -47,7 +48,7 @@ public class GenericEntityOwnershipChange

, E extends GenericEn * Returns the ownership change state. * @return an EntityOwnershipChangeState enum */ - @Nonnull public EntityOwnershipChangeState getState() { + public @NonNull EntityOwnershipChangeState getState() { return state; } diff --git a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipListenerRegistration.java b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipListenerRegistration.java index 06427facac..9bcdd0cd7f 100644 --- a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipListenerRegistration.java +++ b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipListenerRegistration.java @@ -7,7 +7,7 @@ */ package org.opendaylight.mdsal.eos.common.api; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.concepts.Path; @@ -30,7 +30,7 @@ public interface GenericEntityOwnershipListenerRegistration

, * * @return the entity type that the listener was registered for */ - @Nonnull String getEntityType(); + @NonNull String getEntityType(); /** * Unregister the listener. diff --git a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipService.java b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipService.java index e7be676721..e73d26acb3 100644 --- a/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipService.java +++ b/entityownership/mdsal-eos-common-api/src/main/java/org/opendaylight/mdsal/eos/common/api/GenericEntityOwnershipService.java @@ -8,7 +8,7 @@ package org.opendaylight.mdsal.eos.common.api; import java.util.Optional; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.concepts.Path; /** @@ -43,7 +43,7 @@ public interface GenericEntityOwnershipService

, E extends Gene * @return a registration object that can be used to unregister the Candidate * @throws CandidateAlreadyRegisteredException if the candidate was already registered */ - GenericEntityOwnershipCandidateRegistration registerCandidate(@Nonnull E entity) + GenericEntityOwnershipCandidateRegistration registerCandidate(@NonNull E entity) throws CandidateAlreadyRegisteredException; /** @@ -56,7 +56,7 @@ public interface GenericEntityOwnershipService

, E extends Gene * @param listener the listener that is interested in the entities * @return a registration object that can be used to unregister the Listener */ - GenericEntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, @Nonnull L listener); + GenericEntityOwnershipListenerRegistration registerListener(@NonNull String entityType, @NonNull L listener); /** * Gets the current ownership state information for an entity. @@ -64,7 +64,7 @@ public interface GenericEntityOwnershipService

, E extends Gene * @param forEntity the entity to query. * @return an Optional EntityOwnershipState whose instance is present if the entity is found */ - Optional getOwnershipState(@Nonnull E forEntity); + Optional getOwnershipState(@NonNull E forEntity); /** * Checks if a local candidate is registered for the given entity. @@ -72,5 +72,5 @@ public interface GenericEntityOwnershipService

, E extends Gene * @param forEntity the entity to query. * @return true if a candidate is registered locally, false otherwise */ - boolean isCandidateRegistered(@Nonnull E forEntity); + boolean isCandidateRegistered(@NonNull E forEntity); } diff --git a/entityownership/mdsal-eos-common-api/src/test/java/org/opendaylight/mdsal/eos/common/api/GenericEntityTest.java b/entityownership/mdsal-eos-common-api/src/test/java/org/opendaylight/mdsal/eos/common/api/GenericEntityTest.java index 46ac72f9e2..6f78ddc7f6 100644 --- a/entityownership/mdsal-eos-common-api/src/test/java/org/opendaylight/mdsal/eos/common/api/GenericEntityTest.java +++ b/entityownership/mdsal-eos-common-api/src/test/java/org/opendaylight/mdsal/eos/common/api/GenericEntityTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; -import javax.annotation.Nonnull; import org.junit.Test; import org.opendaylight.yangtools.concepts.Path; @@ -37,14 +36,14 @@ public class GenericEntityTest { private final class TestClass implements Path { @Override - public boolean contains(@Nonnull Path other) { + public boolean contains(final Path other) { return false; } } private final class TestClassDiff implements Path { @Override - public boolean contains(@Nonnull Path other) { + public boolean contains(final Path other) { return false; } } diff --git a/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipCandidateRegistration.java b/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipCandidateRegistration.java index 7bfd4f235f..eb19fdf8fc 100644 --- a/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipCandidateRegistration.java +++ b/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipCandidateRegistration.java @@ -5,11 +5,9 @@ * 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.mdsal.eos.common.spi; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.GenericEntity; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipCandidateRegistration; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; @@ -22,11 +20,9 @@ import org.opendaylight.yangtools.concepts.Path; * @param the GenericEntity type */ public abstract class AbstractGenericEntityOwnershipCandidateRegistration

, E extends GenericEntity

> - extends AbstractObjectRegistration - implements GenericEntityOwnershipCandidateRegistration { + extends AbstractObjectRegistration implements GenericEntityOwnershipCandidateRegistration { - protected AbstractGenericEntityOwnershipCandidateRegistration(@Nonnull final E entity) { - super(Preconditions.checkNotNull(entity, "entity cannot be null")); + protected AbstractGenericEntityOwnershipCandidateRegistration(final @NonNull E entity) { + super(entity); } } - diff --git a/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipListenerRegistration.java b/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipListenerRegistration.java index 60ad35c831..5a588894b7 100644 --- a/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipListenerRegistration.java +++ b/entityownership/mdsal-eos-common-spi/src/main/java/org/opendaylight/mdsal/eos/common/spi/AbstractGenericEntityOwnershipListenerRegistration.java @@ -5,11 +5,11 @@ * 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.mdsal.eos.common.spi; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import static java.util.Objects.requireNonNull; + +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.GenericEntity; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipChange; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipListener; @@ -28,12 +28,12 @@ public abstract class AbstractGenericEntityOwnershipListenerRegistration

implements GenericEntityOwnershipListenerRegistration { - private final String entityType; + private final @NonNull String entityType; - protected AbstractGenericEntityOwnershipListenerRegistration(@Nonnull final L instance, - @Nonnull final String entityType) { + protected AbstractGenericEntityOwnershipListenerRegistration(@NonNull final L instance, + @NonNull final String entityType) { super(instance); - this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null"); + this.entityType = requireNonNull(entityType, "entityType cannot be null"); } @Override diff --git a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java index 63b8352200..feac6315b1 100644 --- a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java +++ b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntity.java @@ -9,7 +9,7 @@ package org.opendaylight.mdsal.eos.dom.api; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.GenericEntity; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -27,13 +27,12 @@ public class DOMEntity extends GenericEntity { "urn:opendaylight:params:xml:ns:yang:mdsal:core:general-entity", "2015-09-30", "entity").intern(); static final QName ENTITY_NAME = QName.create(ENTITY, "name").intern(); - /** Constructs an instance. * * @param type the entity type * @param id the entity id. */ - public DOMEntity(@Nonnull final String type, @Nonnull final YangInstanceIdentifier id) { + public DOMEntity(final @NonNull String type, final @NonNull YangInstanceIdentifier id) { super(type, id); } @@ -44,7 +43,7 @@ public class DOMEntity extends GenericEntity { * @param type the type of the entity * @param entityName the name of the entity used to construct a general-entity YangInstanceIdentifier */ - public DOMEntity(@Nonnull String type, @Nonnull String entityName) { + public DOMEntity(final @NonNull String type, final @NonNull String entityName) { super(type, YangInstanceIdentifier.builder().node(ENTITY).nodeWithKey(ENTITY, ENTITY_NAME, Preconditions.checkNotNull(entityName, "entityName should not be null")).build()); } diff --git a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipChange.java b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipChange.java index aa32716f7b..8a3483d3b3 100644 --- a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipChange.java +++ b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipChange.java @@ -8,7 +8,7 @@ package org.opendaylight.mdsal.eos.dom.api; import com.google.common.annotations.Beta; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipChange; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -20,14 +20,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; */ @Beta public class DOMEntityOwnershipChange extends GenericEntityOwnershipChange { - - - public DOMEntityOwnershipChange(@Nonnull final DOMEntity entity, @Nonnull final EntityOwnershipChangeState state) { + public DOMEntityOwnershipChange(final @NonNull DOMEntity entity, final @NonNull EntityOwnershipChangeState state) { super(entity, state, false); } - - public DOMEntityOwnershipChange(@Nonnull final DOMEntity entity, @Nonnull final EntityOwnershipChangeState state, + public DOMEntityOwnershipChange(final @NonNull DOMEntity entity, final @NonNull EntityOwnershipChangeState state, final boolean inJeopardy) { super(entity, state, inJeopardy); } diff --git a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipService.java b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipService.java index 3acf2659c3..b844475745 100644 --- a/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipService.java +++ b/entityownership/mdsal-eos-dom-api/src/main/java/org/opendaylight/mdsal/eos/dom/api/DOMEntityOwnershipService.java @@ -9,7 +9,6 @@ package org.opendaylight.mdsal.eos.dom.api; import com.google.common.annotations.Beta; import java.util.Optional; -import javax.annotation.Nonnull; import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipService; @@ -23,22 +22,17 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @Beta public interface DOMEntityOwnershipService extends GenericEntityOwnershipService { - - @Override - DOMEntityOwnershipCandidateRegistration registerCandidate(@Nonnull DOMEntity entity) + DOMEntityOwnershipCandidateRegistration registerCandidate(DOMEntity entity) throws CandidateAlreadyRegisteredException; - @Override - DOMEntityOwnershipListenerRegistration registerListener(@Nonnull String entityType, - @Nonnull DOMEntityOwnershipListener listener); - + DOMEntityOwnershipListenerRegistration registerListener(String entityType, + DOMEntityOwnershipListener listener); @Override - Optional getOwnershipState(@Nonnull DOMEntity forEntity); - + Optional getOwnershipState(DOMEntity forEntity); @Override - boolean isCandidateRegistered(@Nonnull DOMEntity forEntity); + boolean isCandidateRegistered(DOMEntity forEntity); } -- 2.36.6