*/
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;
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<EntityOwnershipState> getOwnershipState(Entity forEntity) {
+ public Optional<EntityOwnershipState> 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()));
}
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;
* @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);
}
* @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());
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;
@Beta
public class EntityOwnershipChange extends GenericEntityOwnershipChange<InstanceIdentifier<?>, 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);
}
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;
GenericEntityOwnershipService<InstanceIdentifier<?>, 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<EntityOwnershipState> getOwnershipState(@Nonnull Entity forEntity);
+ Optional<EntityOwnershipState> getOwnershipState(Entity forEntity);
@Override
- boolean isCandidateRegistered(@Nonnull Entity forEntity);
+ boolean isCandidateRegistered(Entity forEntity);
}
* 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;
/**
public class CandidateAlreadyRegisteredException extends Exception {
private static final long serialVersionUID = 1L;
- private final GenericEntity<?> entity;
+ private final @NonNull GenericEntity<?> entity;
- public <T extends Path<T>> CandidateAlreadyRegisteredException(@Nonnull GenericEntity<T> entity) {
- super(String.format("Candidate has already been registered for %s",
- Preconditions.checkNotNull(entity, "entity should not be null")));
- this.entity = entity;
+ public <T extends Path<T>> CandidateAlreadyRegisteredException(@NonNull final GenericEntity<T> entity) {
+ super("Candidate has already been registered for " + entity);
+ this.entity = requireNonNull(entity, "entity should not be null");
}
/**
* @return the entity.
*/
@SuppressWarnings("unchecked")
- @Nonnull
- public <T extends Path<T>> GenericEntity<T> getEntity() {
+ public <T extends Path<T>> @NonNull GenericEntity<T> getEntity() {
return (GenericEntity<T>) entity;
}
}
*/
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;
public class GenericEntity<T extends Path<T>> implements Serializable, Identifiable<T> {
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;
}
* 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;
}
*/
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;
/**
* @param <E> the GenericEntity type
*/
public class GenericEntityOwnershipChange<P extends Path<P>, E extends GenericEntity<P>> {
- 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;
}
* Returns the entity whose ownership status changed.
* @return the entity
*/
- @Nonnull public E getEntity() {
+ public @NonNull E getEntity() {
return entity;
}
* Returns the ownership change state.
* @return an EntityOwnershipChangeState enum
*/
- @Nonnull public EntityOwnershipChangeState getState() {
+ public @NonNull EntityOwnershipChangeState getState() {
return state;
}
*/
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;
*
* @return the entity type that the listener was registered for
*/
- @Nonnull String getEntityType();
+ @NonNull String getEntityType();
/**
* Unregister the listener.
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;
/**
* @return a registration object that can be used to unregister the Candidate
* @throws CandidateAlreadyRegisteredException if the candidate was already registered
*/
- GenericEntityOwnershipCandidateRegistration<P, E> registerCandidate(@Nonnull E entity)
+ GenericEntityOwnershipCandidateRegistration<P, E> registerCandidate(@NonNull E entity)
throws CandidateAlreadyRegisteredException;
/**
* @param listener the listener that is interested in the entities
* @return a registration object that can be used to unregister the Listener
*/
- GenericEntityOwnershipListenerRegistration<P, L> registerListener(@Nonnull String entityType, @Nonnull L listener);
+ GenericEntityOwnershipListenerRegistration<P, L> registerListener(@NonNull String entityType, @NonNull L listener);
/**
* Gets the current ownership state information for an entity.
* @param forEntity the entity to query.
* @return an Optional EntityOwnershipState whose instance is present if the entity is found
*/
- Optional<EntityOwnershipState> getOwnershipState(@Nonnull E forEntity);
+ Optional<EntityOwnershipState> getOwnershipState(@NonNull E forEntity);
/**
* Checks if a local candidate is registered for the given entity.
* @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);
}
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;
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;
}
}
* 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;
* @param <E> the GenericEntity type
*/
public abstract class AbstractGenericEntityOwnershipCandidateRegistration<P extends Path<P>, E extends GenericEntity<P>>
- extends AbstractObjectRegistration<E>
- implements GenericEntityOwnershipCandidateRegistration<P, E> {
+ extends AbstractObjectRegistration<E> implements GenericEntityOwnershipCandidateRegistration<P, E> {
- protected AbstractGenericEntityOwnershipCandidateRegistration(@Nonnull final E entity) {
- super(Preconditions.checkNotNull(entity, "entity cannot be null"));
+ protected AbstractGenericEntityOwnershipCandidateRegistration(final @NonNull E entity) {
+ super(entity);
}
}
-
* 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;
extends AbstractObjectRegistration<L>
implements GenericEntityOwnershipListenerRegistration<P, L> {
- 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
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;
"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);
}
* @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());
}
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;
*/
@Beta
public class DOMEntityOwnershipChange extends GenericEntityOwnershipChange<YangInstanceIdentifier, DOMEntity> {
-
-
- 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);
}
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;
@Beta
public interface DOMEntityOwnershipService extends
GenericEntityOwnershipService<YangInstanceIdentifier, DOMEntity, DOMEntityOwnershipListener> {
-
-
@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<EntityOwnershipState> getOwnershipState(@Nonnull DOMEntity forEntity);
-
+ Optional<EntityOwnershipState> getOwnershipState(DOMEntity forEntity);
@Override
- boolean isCandidateRegistered(@Nonnull DOMEntity forEntity);
+ boolean isCandidateRegistered(DOMEntity forEntity);
}