Ditch JSR305 annotations in favor of JDT annotations.
JIRA: YANGTOOLS-907
Change-Id: Ia183995a947277ea78cb9e37e2aa1494f937c43e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
<build>
<plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Import-Package>!javax.annotation,*</Import-Package>
- </instructions>
- </configuration>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
* @param prefix Prefix
* @return module mapped to prefix, or null if the module cannot be resolved
*/
- protected abstract Module moduleForPrefix(@Nonnull String prefix);
+ protected abstract @Nullable Module moduleForPrefix(@NonNull String prefix);
@Override
- protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
+ protected final QName createQName(final String prefix, final String localName) {
final Module module = moduleForPrefix(prefix);
checkArgument(module != null, "Failed to lookup prefix %s", prefix);
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
* @param prefix Prefix
* @return module mapped to prefix, or null if the module cannot be resolved
*/
- protected abstract Module moduleForPrefix(@Nonnull String prefix);
+ protected abstract @Nullable Module moduleForPrefix(@NonNull String prefix);
@Override
- protected final QName createQName(@Nonnull final String prefix, @Nonnull final String localName) {
+ protected final QName createQName(final String prefix, final String localName) {
final Module module = moduleForPrefix(prefix);
checkArgument(module != null, "Failed to lookup prefix %s", prefix);
return QName.create(module.getQNameModule(), localName);
import com.google.common.base.Splitter;
import java.net.URI;
import java.util.Iterator;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
* @param namespace Namespace to map
* @return Allocated unique prefix, or null if the prefix cannot be mapped.
*/
- @Nullable protected abstract String prefixForNamespace(@Nonnull URI namespace);
+ protected abstract @Nullable String prefixForNamespace(@NonNull URI namespace);
/**
* Create a QName for a prefix and local name.
* @return QName
* @throws IllegalArgumentException if the prefix cannot be resolved
*/
- @Nullable protected abstract QName createQName(@Nonnull String prefix, @Nonnull String localName);
+ protected abstract @Nullable QName createQName(@NonNull String prefix, @NonNull String localName);
private static String getIdAndPrefixAsStr(final String pathPart) {
int predicateStartIndex = pathPart.indexOf('[');
import com.google.common.annotations.Beta;
import java.util.Map.Entry;
-import javax.annotation.Nonnull;
import javax.xml.XMLConstants;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
* @return DataSchemaContextTree associated with SchemaContext for which
* serialization / deserialization occurs.
*/
- protected abstract @Nonnull DataSchemaContextTree getDataContextTree();
+ protected abstract @NonNull DataSchemaContextTree getDataContextTree();
protected Object deserializeKeyValue(final DataSchemaNode schemaNode, final String value) {
return value;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import java.util.Collection;
-import java.util.List;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
/**
return false;
}
- @Nonnull
@Override
public QName getQName() {
return schemaNode.getQName();
}
- @Nonnull
@Override
public SchemaPath getPath() {
return schemaNode.getPath();
return schemaNode.getReference();
}
- @Nonnull
@Override
public Status getStatus() {
return schemaNode.getStatus();
}
- @Nonnull
- @Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return ImmutableList.of();
- }
-
@Override
public Collection<MustDefinition> getMustConstraints() {
return ImmutableList.of();
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-import javax.annotation.Nullable;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* @param child Child path argument
* @return A child node, or null if not found
*/
- @Nullable public abstract DataSchemaContextNode<?> getChild(PathArgument child);
+ public abstract @Nullable DataSchemaContextNode<?> getChild(PathArgument child);
- @Nullable public abstract DataSchemaContextNode<?> getChild(QName child);
+ public abstract @Nullable DataSchemaContextNode<?> getChild(QName child);
- @Nullable public DataSchemaNode getDataSchemaNode() {
+ public @Nullable DataSchemaNode getDataSchemaNode() {
return dataSchemaNode;
}
* DataContextNodeOperation for child as call for
* {@link #fromDataSchemaNode(DataSchemaNode)}.
*/
- @Nullable static DataSchemaContextNode<?> fromAugmentation(final DataNodeContainer parent,
+ static @Nullable DataSchemaContextNode<?> fromAugmentation(final DataNodeContainer parent,
final AugmentationTarget parentAug, final DataSchemaNode child) {
for (AugmentationSchemaNode aug : parentAug.getAvailableAugmentations()) {
if (aug.findDataChildByName(child.getQName()).isPresent()) {
return fromDataSchemaNode(child);
}
- @Nullable public static DataSchemaContextNode<?> fromDataSchemaNode(final DataSchemaNode potential) {
+ public static @Nullable DataSchemaContextNode<?> fromDataSchemaNode(final DataSchemaNode potential) {
if (potential instanceof ContainerSchemaNode) {
return new ContainerContextNode((ContainerSchemaNode) potential);
} else if (potential instanceof ListSchemaNode) {
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.Optional;
-import javax.annotation.Nonnull;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
private static final LoadingCache<SchemaContext, DataSchemaContextTree> TREES = CacheBuilder.newBuilder()
.weakKeys().weakValues().build(new CacheLoader<SchemaContext, DataSchemaContextTree>() {
@Override
- public DataSchemaContextTree load(@Nonnull final SchemaContext key) throws Exception {
+ public DataSchemaContextTree load(final SchemaContext key) throws Exception {
return new DataSchemaContextTree(key);
}
});
root = DataSchemaContextNode.from(ctx);
}
- @Nonnull public static DataSchemaContextTree from(@Nonnull final SchemaContext ctx) {
+ public static @NonNull DataSchemaContextTree from(final @NonNull SchemaContext ctx) {
return TREES.getUnchecked(ctx);
}
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import java.util.Objects;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
* @param schema The leaf node's schema
* @return An interner instance
*/
- @Nonnull public static <T extends LeafNode<?>> Interner<T> forSchema(@Nullable final LeafSchemaNode schema) {
+ @NonNull public static <T extends LeafNode<?>> Interner<T> forSchema(final @Nullable LeafSchemaNode schema) {
if (schema != null && isLowCardinality(schema.getType())) {
return LeafInterner::intern;
}
import com.google.common.annotations.Beta;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
}
@SuppressWarnings("static-method")
- public <T extends LeafSetEntryNode<?>> T intern(@Nonnull final T sample) {
+ public <T extends LeafSetEntryNode<?>> @NonNull T intern(final @NonNull T sample) {
if (!sample.getAttributes().isEmpty()) {
// Non-empty attributes, do not intern
return sample;
* @param schema Schema of the parent leaf set
* @return An interner instance, or null if the leafset's type should not be interned.
*/
- @Nullable public static LeafsetEntryInterner forSchema(@Nullable final LeafListSchemaNode schema) {
+ public static @Nullable LeafsetEntryInterner forSchema(final @Nullable LeafListSchemaNode schema) {
if (schema != null) {
final TypeDefinition<?> type = schema.getType();
if (type instanceof BooleanTypeDefinition || type instanceof EnumTypeDefinition
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.util.Iterator;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
protected final QNameModule parentModuleQname;
- protected ModuleStringIdentityrefCodec(@Nonnull final SchemaContext context,
- @Nonnull final QNameModule parentModule) {
+ protected ModuleStringIdentityrefCodec(final @NonNull SchemaContext context,
+ final @NonNull QNameModule parentModule) {
this.context = requireNonNull(context);
this.parentModuleQname = requireNonNull(parentModule);
}
@Override
- protected String prefixForNamespace(@Nonnull final URI namespace) {
+ protected String prefixForNamespace(final URI namespace) {
final Iterator<Module> modules = context.findModules(namespace).iterator();
return modules.hasNext() ? modules.next().getName() : null;
}
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
public final class RpcAsContainer implements ContainerSchemaNode {
-
private final RpcDefinition delegate;
@Override
return delegate.getGroupings();
}
- @Nonnull
@Override
public Status getStatus() {
return delegate.getStatus();
delegate = parentNode;
}
- @Nonnull
@Override
public QName getQName() {
return delegate.getQName();
}
- @Nonnull
@Override
public SchemaPath getPath() {
return delegate.getPath();
}
- @Nonnull
- @Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return Collections.emptyList();
- }
-
@Override
public Optional<DataSchemaNode> findDataChildByName(final QName name) {
// FIXME: check QNameModule
@Override
public Set<UsesNode> getUses() {
- return Collections.emptySet();
+ return ImmutableSet.of();
}
@Override
public Set<AugmentationSchemaNode> getAvailableAugmentations() {
- return Collections.emptySet();
+ return ImmutableSet.of();
}
@Override
package org.opendaylight.yangtools.yang.data.util.codec;
import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
* @param schema Schema node
* @return Cached codec, or null if no codec is cached.
*/
- @Nullable abstract T lookupComplex(TypedDataSchemaNode schema);
+ abstract @Nullable T lookupComplex(TypedDataSchemaNode schema);
/**
* Lookup a simple codec for a type definition.
* @param type Type definition
* @return Cached codec, or null if no codec is cached.
*/
- @Nullable abstract T lookupSimple(TypeDefinition<?> type);
+ abstract @Nullable T lookupSimple(TypeDefinition<?> type);
/**
* Lookup-or-store a complex codec for a particular schema node.
* @param codec Codec to cache
* @return Codec instance, either already-cached, or the codec presented as argument.
*/
- @Nonnull abstract T getComplex(TypedDataSchemaNode schema, T codec);
+ abstract @NonNull T getComplex(TypedDataSchemaNode schema, T codec);
/**
* Lookup-or-store a simple codec for a particular schema node.
* @param codec Codec to cache
* @return Codec instance, either already-cached, or the codec presented as argument.
*/
- @Nonnull abstract T getSimple(TypeDefinition<?> type, T codec);
+ abstract @NonNull T getSimple(TypeDefinition<?> type, T codec);
}