This moves over to use JDT annotations instead of JSR305.
Change-Id: I98d70e53a951d41c3533272da016fb8afa223a49
JIRA: YANGTOOLS-907
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 java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import javax.annotation.Nonnull;
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
}
@Override
- public <T extends SchemaSourceRepresentation> ListenableFuture<T> getSchemaSource(
- @Nonnull final SourceIdentifier id, @Nonnull final Class<T> representation) {
+ public <T extends SchemaSourceRepresentation> ListenableFuture<T> getSchemaSource(final SourceIdentifier id,
+ final Class<T> representation) {
final ArrayList<AbstractSchemaSourceRegistration<?>> sortedSchemaSourceRegistrations;
synchronized (this) {
@Override
@SuppressWarnings("checkstyle:parameterName")
- public void onFailure(@Nonnull final Throwable t) {
+ public void onFailure(final Throwable t) {
LOG.trace("Skipping notification for encountered source {}, fetching source failed", id, t);
}
}, MoreExecutors.directExecutor());
import com.google.common.util.concurrent.MoreExecutors;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
public interface Transformation<S extends SchemaSourceRepresentation, D extends SchemaSourceRepresentation>
extends AsyncFunction<S, D> {
@Override
- ListenableFuture<D> apply(@Nonnull S input) throws Exception;
+ ListenableFuture<D> apply(S input) throws Exception;
}
private final Map<PotentialSchemaSource<?>, RefcountedRegistration> availableSources = new HashMap<>();
* 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.yangtools.yang.model.util;
import com.google.common.base.Preconditions;
*/
package org.opendaylight.yangtools.yang.model.util;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
-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.model.api.ActionNodeContainer;
import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
import org.slf4j.LoggerFactory;
/**
- * The Schema Context Util contains support methods for searching through Schema
- * Context modules for specified schema nodes via Schema Path or Revision Aware
- * XPath. The Schema Context Util is designed as mixin, so it is not
+ * The Schema Context Util contains support methods for searching through Schema Context modules for specified schema
+ * nodes via Schema Path or Revision Aware XPath. The Schema Context Util is designed as mixin, so it is not
* instantiable.
- *
*/
public final class SchemaContextUtil {
private static final Logger LOG = LoggerFactory.getLogger(SchemaContextUtil.class);
* @throws IllegalArgumentException if context or schemaPath is not correct.
*/
public static SchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
final Iterable<QName> prefixedPath = schemaPath.getPathFromRoot();
if (prefixedPath == null) {
// that feels like an overkill.
public static SchemaNode findDataSchemaNode(final SchemaContext context, final Module module,
final RevisionAwareXPath nonCondXPath) {
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
- Preconditions.checkArgument(nonCondXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(module != null, "Module reference cannot be NULL");
+ checkArgument(nonCondXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
final String strXPath = nonCondXPath.toString();
if (strXPath != null) {
- Preconditions.checkArgument(strXPath.indexOf('[') == -1,
- "Revision Aware XPath may not contain a condition");
+ checkArgument(strXPath.indexOf('[') == -1, "Revision Aware XPath may not contain a condition");
if (nonCondXPath.isAbsolute()) {
final List<QName> path = xpathToQNamePath(context, module, strXPath);
// that feels like an overkill.
public static SchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, final Module module,
final SchemaNode actualSchemaNode, final RevisionAwareXPath relativeXPath) {
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
- Preconditions.checkArgument(actualSchemaNode != null, "Actual Schema Node reference cannot be NULL");
- Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
- Preconditions.checkState(!relativeXPath.isAbsolute(),
- "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
- + "for non relative Revision Aware XPath use findDataSchemaNode method");
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(module != null, "Module reference cannot be NULL");
+ checkArgument(actualSchemaNode != null, "Actual Schema Node reference cannot be NULL");
+ checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
+ checkState(!relativeXPath.isAbsolute(), "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+ + "for non relative Revision Aware XPath use findDataSchemaNode method");
final SchemaPath actualNodePath = actualSchemaNode.getPath();
if (actualNodePath != null) {
* return <code>null</code>
*/
public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL!");
- Preconditions.checkArgument(schemaNode != null, "Schema Node cannot be NULL!");
- Preconditions.checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not "
- + "set properly (Schema Path is NULL)");
+ checkArgument(context != null, "Schema Context reference cannot be NULL!");
+ checkArgument(schemaNode != null, "Schema Node cannot be NULL!");
+ checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not set properly (Schema Path is "
+ + "NULL)");
final QName qname = schemaNode.getPath().getLastComponent();
- Preconditions.checkState(qname != null, "Schema Path contains invalid state of path parts. "
+ checkState(qname != null, "Schema Path contains invalid state of path parts. "
+ "The Schema Path MUST contain at least ONE QName which defines namespace and Local name of path.");
return context.findModule(qname.getModule()).orElse(null);
}
* @return Notification schema or null, if notification is not present in schema context.
*/
@Beta
- @Nullable
- public static NotificationDefinition getNotificationSchema(@Nonnull final SchemaContext schema,
- @Nonnull final SchemaPath path) {
- Preconditions.checkNotNull(schema, "Schema context must not be null.");
- Preconditions.checkNotNull(path, "Schema path must not be null.");
+ public static @Nullable NotificationDefinition getNotificationSchema(final @NonNull SchemaContext schema,
+ final @NonNull SchemaPath path) {
+ requireNonNull(schema, "Schema context must not be null.");
+ requireNonNull(path, "Schema path must not be null.");
for (final NotificationDefinition potential : schema.getNotifications()) {
if (path.equals(potential.getPath())) {
return potential;
* @return Notification schema or null, if notification is not present in schema context.
*/
@Beta
- @Nullable
- public static ContainerSchemaNode getRpcDataSchema(@Nonnull final SchemaContext schema,
- @Nonnull final SchemaPath path) {
- Preconditions.checkNotNull(schema, "Schema context must not be null.");
- Preconditions.checkNotNull(path, "Schema path must not be null.");
+ public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull SchemaContext schema,
+ final @NonNull SchemaPath path) {
+ requireNonNull(schema, "Schema context must not be null.");
+ requireNonNull(path, "Schema path must not be null.");
final Iterator<QName> it = path.getPathFromRoot().iterator();
- Preconditions.checkArgument(it.hasNext(), "Rpc must have QName.");
+ checkArgument(it.hasNext(), "Rpc must have QName.");
final QName rpcName = it.next();
- Preconditions.checkArgument(it.hasNext(), "input or output must be part of path.");
+ checkArgument(it.hasNext(), "input or output must be part of path.");
final QName inOrOut = it.next();
for (final RpcDefinition potential : schema.getOperations()) {
if (rpcName.equals(potential.getQName())) {
}
private static SchemaNode findNodeInModule(final Module module, final Iterable<QName> path) {
-
- Preconditions.checkArgument(module != null, "Parent reference cannot be NULL");
- Preconditions.checkArgument(path != null, "Path reference cannot be NULL");
+ checkArgument(module != null, "Parent reference cannot be NULL");
+ checkArgument(path != null, "Path reference cannot be NULL");
if (!path.iterator().hasNext()) {
LOG.debug("No node matching {} found in node {}", path, module);
}
private static SchemaNode findNodeIn(final SchemaNode parent, final Iterable<QName> path) {
-
- Preconditions.checkArgument(parent != null, "Parent reference cannot be NULL");
- Preconditions.checkArgument(path != null, "Path reference cannot be NULL");
+ checkArgument(parent != null, "Parent reference cannot be NULL");
+ checkArgument(path != null, "Path reference cannot be NULL");
if (!path.iterator().hasNext()) {
LOG.debug("No node matching {} found in node {}", path, parent);
*/
private static List<QName> xpathToQNamePath(final SchemaContext context, final Module parentModule,
final String xpath) {
- // FIXME: 2.0.0: this should throw NPE, not IAE
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
- Preconditions.checkArgument(xpath != null, "XPath string reference cannot be NULL");
+ // FIXME: 3.0.0: this should throw NPE, not IAE
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
+ checkArgument(xpath != null, "XPath string reference cannot be NULL");
final List<QName> path = new LinkedList<>();
for (final String pathComponent : SLASH_SPLITTER.split(xpath)) {
* If Schema Context, Parent Module or Prefixed Path Part refers to
* <code>null</code> the method will throw IllegalArgumentException
*
- * @param context
- * Schema Context
- * @param parentModule
- * Parent Module
- * @param prefixedPathPart
- * Prefixed Path Part string
+ * @param context Schema Context
+ * @param parentModule Parent Module
+ * @param prefixedPathPart Prefixed Path Part string
* @return QName from prefixed Path Part String.
* @throws IllegalArgumentException if any arguments are null
*/
private static QName stringPathPartToQName(final SchemaContext context, final Module parentModule,
final String prefixedPathPart) {
- // FIXME: 2.0.0: this should throw NPE, not IAE
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
- Preconditions.checkArgument(prefixedPathPart != null, "Prefixed Path Part cannot be NULL!");
+ // FIXME: 3.0.0: this should throw NPE, not IAE
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
+ checkArgument(prefixedPathPart != null, "Prefixed Path Part cannot be NULL!");
if (prefixedPathPart.indexOf(':') != -1) {
final Iterator<String> prefixedName = COLON_SPLITTER.split(prefixedPathPart).iterator();
final String modulePrefix = prefixedName.next();
final Module module = resolveModuleForPrefix(context, parentModule, modulePrefix);
- Preconditions.checkArgument(module != null,
- "Failed to resolve xpath: no module found for prefix %s in module %s", modulePrefix,
- parentModule.getName());
+ checkArgument(module != null, "Failed to resolve xpath: no module found for prefix %s in module %s",
+ modulePrefix, parentModule.getName());
return QName.create(module.getQNameModule(), prefixedName.next());
}
}
/**
- * Method will attempt to resolve and provide Module reference for specified
- * module prefix. Each Yang module could contains multiple imports which
- * MUST be associated with corresponding module prefix. The method simply
- * looks into module imports and returns the module that is bounded with
- * specified prefix. If the prefix is not present in module or the prefixed
- * module is not present in specified Schema Context, the method will return
- * <code>null</code>. <br>
- * If String prefix is the same as prefix of the specified Module the
- * reference to this module is returned. <br>
- * If Schema Context, Module or Prefix are referring to <code>null</code>
- * the method will return IllegalArgumentException
+ * Method will attempt to resolve and provide Module reference for specified module prefix. Each Yang module could
+ * contains multiple imports which MUST be associated with corresponding module prefix. The method simply looks into
+ * module imports and returns the module that is bounded with specified prefix. If the prefix is not present
+ * in module or the prefixed module is not present in specified Schema Context, the method will return {@code null}.
+ * <br>
+ * If String prefix is the same as prefix of the specified Module the reference to this module is returned.<br>
+ * If Schema Context, Module or Prefix are referring to {@code null} the method will throw IllegalArgumentException.
*
- * @param context
- * Schema Context
- * @param module
- * Yang Module
- * @param prefix
- * Module Prefix
- * @return Module for given prefix in specified Schema Context if is
- * present, otherwise returns <code>null</code>
+ * @param context Schema Context
+ * @param module Yang Module
+ * @param prefix Module Prefix
+ * @return Module for given prefix in specified Schema Context if is present, otherwise returns <code>null</code>
* @throws IllegalArgumentException if any arguments are null
*/
private static Module resolveModuleForPrefix(final SchemaContext context, final Module module,
final String prefix) {
- // FIXME: 2.0.0: this should throw NPE, not IAE
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
- Preconditions.checkArgument(prefix != null, "Prefix string cannot be NULL");
+ // FIXME: 3.0.0: this should throw NPE, not IAE
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(module != null, "Module reference cannot be NULL");
+ checkArgument(prefix != null, "Prefix string cannot be NULL");
if (prefix.equals(module.getPrefix())) {
return module;
*/
private static Iterable<QName> resolveRelativeXPath(final SchemaContext context, final Module module,
final RevisionAwareXPath relativeXPath, final SchemaNode actualSchemaNode) {
- // FIXME: 2.0.0: this should throw NPE, not IAE
- Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
- Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
- Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
- Preconditions.checkState(!relativeXPath.isAbsolute(),
- "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
- + "for non relative Revision Aware XPath use findDataSchemaNode method");
- Preconditions.checkState(actualSchemaNode.getPath() != null,
+ // FIXME: 3.0.0: this should throw NPE, not IAE
+ checkArgument(context != null, "Schema Context reference cannot be NULL");
+ checkArgument(module != null, "Module reference cannot be NULL");
+ checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
+ checkState(!relativeXPath.isAbsolute(), "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+ + "for non relative Revision Aware XPath use findDataSchemaNode method");
+ checkState(actualSchemaNode.getPath() != null,
"Schema Path reference for Leafref cannot be NULL");
final Iterable<String> xpaths = SLASH_SPLITTER.split(relativeXPath.toString());
}
final Optional<Module> parentModule = schemaContext.findModule(qname.getModule());
- Preconditions.checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);
+ checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);
final DataSchemaNode dataSchemaNode = (DataSchemaNode) SchemaContextUtil.findDataSchemaNode(schemaContext,
parentModule.get(), strippedPathStatement);
private static Module findParentModuleOfReferencingType(final SchemaContext schemaContext,
final SchemaNode schemaNode) {
- Preconditions.checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
- Preconditions.checkArgument(schemaNode instanceof TypedDataSchemaNode, "Unsupported node %s", schemaNode);
+ checkArgument(schemaContext != null, "Schema Context reference cannot be NULL!");
+ checkArgument(schemaNode instanceof TypedDataSchemaNode, "Unsupported node %s", schemaNode);
TypeDefinition<?> nodeType = ((TypedDataSchemaNode) schemaNode).getType();
if (nodeType.getBaseType() != null) {
import static java.util.Objects.requireNonNull;
import java.util.Optional;
-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.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
public final class SchemaNodeUtils {
-
private SchemaNodeUtils() {
throw new UnsupportedOperationException("Utility class");
}
* @param qname input or output QName with namespace same as RPC
* @return input or output schema. Returns null if RPC does not have input/output specified.
*/
- @Nullable public static ContainerSchemaNode getRpcDataSchema(@Nonnull final RpcDefinition rpc,
- @Nonnull final QName qname) {
+ public static @Nullable ContainerSchemaNode getRpcDataSchema(final @NonNull RpcDefinition rpc,
+ final @NonNull QName qname) {
requireNonNull(rpc, "Rpc Schema must not be null");
- requireNonNull(qname, "QName must not be null");
- switch (qname.getLocalName()) {
+ switch (requireNonNull(qname, "QName must not be null").getLocalName()) {
case "input":
return rpc.getInput();
case "output":
import java.util.Collection;
import java.util.Optional;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
}
- @Nonnull
@Override
public final Optional<LengthConstraint> getLengthConstraint() {
return baseType().getLengthConstraint();
import com.google.common.collect.Range;
import java.util.List;
import java.util.Optional;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
}
@Override
- @Nonnull
public final Optional<RangeConstraint<N>> getRangeConstraint() {
return Optional.of(rangeConstraint);
}
import java.util.Collection;
import java.util.Optional;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
super(baseType, path, defaultValue, description, reference, status, units, unknownSchemaNodes);
}
- @Nonnull
@Override
public final Optional<RangeConstraint<N>> getRangeConstraint() {
return baseType().getRangeConstraint();
import java.util.Collection;
import java.util.Optional;
-import javax.annotation.Nonnull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
}
@Override
- @Nonnull
public final Optional<RangeConstraint<N>> getRangeConstraint() {
return Optional.ofNullable(rangeConstraint);
}
*/
package org.opendaylight.yangtools.yang.model.util.type;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Verify.verifyNotNull;
+
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
AbstractRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
super(baseType, path);
if (baseType != null) {
- Preconditions.checkArgument(baseType instanceof AbstractBaseType || baseType instanceof AbstractDerivedType,
+ checkArgument(baseType instanceof AbstractBaseType || baseType instanceof AbstractDerivedType,
"Restricted type has to be based on either a base or derived type, not %s", baseType);
} else {
touched = true;
@Override
public final T build() {
- if (!touched) {
- return getBaseType();
- }
-
- return buildType();
+ return touched ? buildType() : verifyNotNull(getBaseType());
}
}
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseBinaryType extends AbstractLengthRestrictedBaseType<BinaryTypeDefinition>
implements BinaryTypeDefinition {
- static final BaseBinaryType INSTANCE = new BaseBinaryType();
+ static final @NonNull BaseBinaryType INSTANCE = new BaseBinaryType();
private BaseBinaryType() {
super(BaseTypes.BINARY_QNAME);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseBooleanType extends AbstractBaseType<BooleanTypeDefinition> implements BooleanTypeDefinition {
- static final BaseBooleanType INSTANCE = new BaseBooleanType();
+ static final @NonNull BaseBooleanType INSTANCE = new BaseBooleanType();
private BaseBooleanType() {
super(BaseTypes.BOOLEAN_QNAME);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseEmptyType extends AbstractBaseType<EmptyTypeDefinition> implements EmptyTypeDefinition {
- static final BaseEmptyType INSTANCE = new BaseEmptyType();
+ static final @NonNull BaseEmptyType INSTANCE = new BaseEmptyType();
private BaseEmptyType() {
super(BaseTypes.EMPTY_QNAME);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseInstanceIdentifierType extends AbstractBaseType<InstanceIdentifierTypeDefinition>
implements InstanceIdentifierTypeDefinition {
- static final BaseInstanceIdentifierType INSTANCE = new BaseInstanceIdentifierType();
+ static final @NonNull BaseInstanceIdentifierType INSTANCE = new BaseInstanceIdentifierType();
private BaseInstanceIdentifierType() {
super(BaseTypes.INSTANCE_IDENTIFIER_QNAME);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseInt16Type extends AbstractRangeRestrictedBaseType<Int16TypeDefinition, Short>
implements Int16TypeDefinition {
- static final BaseInt16Type INSTANCE = new BaseInt16Type();
+ static final @NonNull BaseInt16Type INSTANCE = new BaseInt16Type();
private BaseInt16Type() {
super(BaseTypes.INT16_QNAME, Short.MIN_VALUE, Short.MAX_VALUE);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Int32TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseInt32Type extends AbstractRangeRestrictedBaseType<Int32TypeDefinition, Integer>
implements Int32TypeDefinition {
- static final BaseInt32Type INSTANCE = new BaseInt32Type();
+ static final @NonNull BaseInt32Type INSTANCE = new BaseInt32Type();
private BaseInt32Type() {
super(BaseTypes.INT32_QNAME, Integer.MIN_VALUE, Integer.MAX_VALUE);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Int64TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseInt64Type extends AbstractRangeRestrictedBaseType<Int64TypeDefinition, Long>
implements Int64TypeDefinition {
- static final BaseInt64Type INSTANCE = new BaseInt64Type();
+ static final @NonNull BaseInt64Type INSTANCE = new BaseInt64Type();
private BaseInt64Type() {
super(BaseTypes.INT64_QNAME, Long.MIN_VALUE, Long.MAX_VALUE);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Int8TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseInt8Type extends AbstractRangeRestrictedBaseType<Int8TypeDefinition, Byte>
implements Int8TypeDefinition {
- static final BaseInt8Type INSTANCE = new BaseInt8Type();
+ static final @NonNull BaseInt8Type INSTANCE = new BaseInt8Type();
private BaseInt8Type() {
super(BaseTypes.INT8_QNAME, Byte.MIN_VALUE, Byte.MAX_VALUE);
import com.google.common.collect.ImmutableList;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseStringType extends AbstractLengthRestrictedBaseType<StringTypeDefinition>
implements StringTypeDefinition {
- static final BaseStringType INSTANCE = new BaseStringType();
+ static final @NonNull BaseStringType INSTANCE = new BaseStringType();
private BaseStringType() {
super(BaseTypes.STRING_QNAME);
package org.opendaylight.yangtools.yang.model.util.type;
import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
throw new UnsupportedOperationException();
}
- public static BinaryTypeDefinition binaryType() {
+ public static @NonNull BinaryTypeDefinition binaryType() {
return BaseBinaryType.INSTANCE;
}
- public static BitsTypeBuilder bitsTypeBuilder(final SchemaPath path) {
+ public static @NonNull BitsTypeBuilder bitsTypeBuilder(final SchemaPath path) {
return new BitsTypeBuilder(path);
}
- public static BooleanTypeDefinition booleanType() {
+ public static @NonNull BooleanTypeDefinition booleanType() {
return BaseBooleanType.INSTANCE;
}
- public static DecimalTypeBuilder decimalTypeBuilder(final SchemaPath path) {
+ public static @NonNull DecimalTypeBuilder decimalTypeBuilder(final SchemaPath path) {
return new DecimalTypeBuilder(path);
}
- public static EmptyTypeDefinition emptyType() {
+ public static @NonNull EmptyTypeDefinition emptyType() {
return BaseEmptyType.INSTANCE;
}
- public static EnumerationTypeBuilder enumerationTypeBuilder(final SchemaPath path) {
+ public static @NonNull EnumerationTypeBuilder enumerationTypeBuilder(final SchemaPath path) {
return new EnumerationTypeBuilder(path);
}
- public static IdentityrefTypeBuilder identityrefTypeBuilder(final SchemaPath path) {
+ public static @NonNull IdentityrefTypeBuilder identityrefTypeBuilder(final SchemaPath path) {
return new IdentityrefTypeBuilder(path);
}
- public static InstanceIdentifierTypeDefinition instanceIdentifierType() {
+ public static @NonNull InstanceIdentifierTypeDefinition instanceIdentifierType() {
return BaseInstanceIdentifierType.INSTANCE;
}
- public static Int8TypeDefinition int8Type() {
+ public static @NonNull Int8TypeDefinition int8Type() {
return BaseInt8Type.INSTANCE;
}
return BaseInt8Type.INSTANCE.getPath().equals(type.getPath());
}
- public static Int16TypeDefinition int16Type() {
+ public static @NonNull Int16TypeDefinition int16Type() {
return BaseInt16Type.INSTANCE;
}
return BaseInt16Type.INSTANCE.getPath().equals(type.getPath());
}
- public static Int32TypeDefinition int32Type() {
+ public static @NonNull Int32TypeDefinition int32Type() {
return BaseInt32Type.INSTANCE;
}
return BaseInt32Type.INSTANCE.getPath().equals(type.getPath());
}
- public static Int64TypeDefinition int64Type() {
+ public static @NonNull Int64TypeDefinition int64Type() {
return BaseInt64Type.INSTANCE;
}
return BaseInt64Type.INSTANCE.getPath().equals(type.getPath());
}
- public static LeafrefTypeBuilder leafrefTypeBuilder(final SchemaPath path) {
+ public static @NonNull LeafrefTypeBuilder leafrefTypeBuilder(final SchemaPath path) {
return new LeafrefTypeBuilder(path);
}
- public static StringTypeDefinition stringType() {
+ public static @NonNull StringTypeDefinition stringType() {
return BaseStringType.INSTANCE;
}
return new UnionTypeBuilder(path);
}
- public static Uint8TypeDefinition uint8Type() {
+ public static @NonNull Uint8TypeDefinition uint8Type() {
return BaseUint8Type.INSTANCE;
}
* @return If the type corresponds to the base uint8 type.
* @throws NullPointerException if type is null
*/
- public static boolean isUint8(@Nonnull final TypeDefinition<?> type) {
+ public static boolean isUint8(final @NonNull TypeDefinition<?> type) {
return BaseUint8Type.INSTANCE.getPath().equals(type.getPath());
}
- public static Uint16TypeDefinition uint16Type() {
+ public static @NonNull Uint16TypeDefinition uint16Type() {
return BaseUint16Type.INSTANCE;
}
* @return If the type corresponds to the base uint16 type.
* @throws NullPointerException if type is null
*/
- public static boolean isUint16(@Nonnull final TypeDefinition<?> type) {
+ public static boolean isUint16(final @NonNull TypeDefinition<?> type) {
return BaseUint16Type.INSTANCE.getPath().equals(type.getPath());
}
- public static Uint32TypeDefinition uint32Type() {
+ public static @NonNull Uint32TypeDefinition uint32Type() {
return BaseUint32Type.INSTANCE;
}
* @return If the type corresponds to the base uint32 type.
* @throws NullPointerException if type is null
*/
- public static boolean isUint32(@Nonnull final TypeDefinition<?> type) {
+ public static boolean isUint32(final @NonNull TypeDefinition<?> type) {
return BaseUint32Type.INSTANCE.getPath().equals(type.getPath());
}
- public static Uint64TypeDefinition uint64Type() {
+ public static @NonNull Uint64TypeDefinition uint64Type() {
return BaseUint64Type.INSTANCE;
}
* @return If the type corresponds to the base uint64 type.
* @throws NullPointerException if type is null
*/
- public static boolean isUint64(@Nonnull final TypeDefinition<?> type) {
+ public static boolean isUint64(final @NonNull TypeDefinition<?> type) {
return BaseUint64Type.INSTANCE.getPath().equals(type.getPath());
}
* @return Base type of specified type
* @throws NullPointerException if type is null
*/
- public static TypeDefinition<?> baseTypeOf(@Nonnull final TypeDefinition<?> type) {
+ public static @NonNull TypeDefinition<?> baseTypeOf(final @NonNull TypeDefinition<?> type) {
TypeDefinition<?> ret = type;
while (ret.getBaseType() != null) {
ret = ret.getBaseType();
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseUint16Type extends AbstractRangeRestrictedBaseType<Uint16TypeDefinition, Integer>
implements Uint16TypeDefinition {
- static final BaseUint16Type INSTANCE = new BaseUint16Type();
+ static final @NonNull BaseUint16Type INSTANCE = new BaseUint16Type();
private BaseUint16Type() {
super(BaseTypes.UINT16_QNAME, 0, 65535);
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Uint32TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseUint32Type extends AbstractRangeRestrictedBaseType<Uint32TypeDefinition, Long>
implements Uint32TypeDefinition {
- static final BaseUint32Type INSTANCE = new BaseUint32Type();
+ static final @NonNull BaseUint32Type INSTANCE = new BaseUint32Type();
private BaseUint32Type() {
super(BaseTypes.UINT32_QNAME, 0L, 4294967295L);
package org.opendaylight.yangtools.yang.model.util.type;
import java.math.BigInteger;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Uint64TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseUint64Type extends AbstractRangeRestrictedBaseType<Uint64TypeDefinition, BigInteger>
implements Uint64TypeDefinition {
- static final BaseUint64Type INSTANCE = new BaseUint64Type();
+ static final @NonNull BaseUint64Type INSTANCE = new BaseUint64Type();
private BaseUint64Type() {
super(BaseTypes.UINT64_QNAME, BigInteger.ZERO, new BigInteger("18446744073709551615"));
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.type.Uint8TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
final class BaseUint8Type extends AbstractRangeRestrictedBaseType<Uint8TypeDefinition, Short>
implements Uint8TypeDefinition {
- static final BaseUint8Type INSTANCE = new BaseUint8Type();
+ static final @NonNull BaseUint8Type INSTANCE = new BaseUint8Type();
private BaseUint8Type() {
super(BaseTypes.UINT8_QNAME, (short)0, (short)255);
import com.google.common.collect.ImmutableMap.Builder;
import java.util.Map;
import java.util.TreeMap;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
super(baseType, path);
}
- public BitsTypeBuilder addBit(@Nonnull final Bit item) {
+ public BitsTypeBuilder addBit(final @NonNull Bit item) {
// in case we are dealing with a restricted bits type, validate if the bit is a subset of its base type
if (getBaseType() != null) {
validateRestrictedBit(item);
return this;
}
- private void validateRestrictedBit(@Nonnull final Bit item) {
+ private void validateRestrictedBit(final @NonNull Bit item) {
boolean isASubsetOfBaseBits = false;
for (Bit baseTypeBit : getBaseType().getBits()) {
if (item.getName().equals(baseTypeBit.getName())) {
*/
package org.opendaylight.yangtools.yang.model.util.type;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.util.List;
import java.util.Optional;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode;
* @param leaf Leaf for which we are acquiring the type
* @return Potentially base type of the leaf type.
*/
- @Nonnull public static TypeDefinition<?> compatType(@Nonnull final TypedDataSchemaNode leaf) {
- final TypeDefinition<?> leafType = leaf.getType();
- Preconditions.checkNotNull(leafType);
+ public static @NonNull TypeDefinition<?> compatType(final @NonNull TypedDataSchemaNode leaf) {
+ final TypeDefinition<?> leafType = requireNonNull(leaf.getType());
if (!leaf.getPath().equals(leafType.getPath())) {
// Old parser semantics, or no new default/units defined for this leaf
// We are dealing with a type generated for the leaf itself
final TypeDefinition<?> baseType = leafType.getBaseType();
- Preconditions.checkArgument(baseType != null, "Leaf %s has type for leaf, but no base type", leaf);
+ checkArgument(baseType != null, "Leaf %s has type for leaf, but no base type", leaf);
if (leaf.getPath().equals(baseType.getPath().getParent())) {
// Internal instantiation of a base YANG type (decimal64 and similar)
}
// FIXME: 3.0.0: remove this method
- @Nonnull public static TypeDefinition<?> compatLeafType(@Nonnull final LeafSchemaNode leaf) {
+ public static @NonNull TypeDefinition<?> compatLeafType(final @NonNull LeafSchemaNode leaf) {
return compatType(leaf);
}
- private static BinaryTypeDefinition baseTypeIfNotConstrained(final BinaryTypeDefinition type) {
+ private static BinaryTypeDefinition baseTypeIfNotConstrained(final @NonNull BinaryTypeDefinition type) {
return baseTypeIfNotConstrained(type, type.getBaseType());
}
- private static TypeDefinition<?> baseTypeIfNotConstrained(final DecimalTypeDefinition type) {
+ private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull DecimalTypeDefinition type) {
return baseTypeIfNotConstrained(type, type.getBaseType());
}
- private static TypeDefinition<?> baseTypeIfNotConstrained(final InstanceIdentifierTypeDefinition type) {
+ private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull InstanceIdentifierTypeDefinition type) {
final InstanceIdentifierTypeDefinition base = type.getBaseType();
return type.requireInstance() == base.requireInstance() ? base : type;
}
- private static TypeDefinition<?> baseTypeIfNotConstrained(final StringTypeDefinition type) {
+ private static TypeDefinition<?> baseTypeIfNotConstrained(final @NonNull StringTypeDefinition type) {
final StringTypeDefinition base = type.getBaseType();
final List<PatternConstraint> patterns = type.getPatternConstraints();
final Optional<LengthConstraint> optLengths = type.getLengthConstraint();
return type;
}
- private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final T type) {
+ private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final @NonNull T type) {
return baseTypeIfNotConstrained(type, type.getBaseType());
}
- private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final T type,
+ private static <T extends RangeRestrictedTypeDefinition<T, ?>> T baseTypeIfNotConstrained(final @NonNull T type,
final T base) {
final Optional<?> optConstraint = type.getRangeConstraint();
if (!optConstraint.isPresent()) {
return optConstraint.equals(base.getRangeConstraint()) ? base : type;
}
- private static <T extends LengthRestrictedTypeDefinition<T>> T baseTypeIfNotConstrained(final T type,
+ private static <T extends LengthRestrictedTypeDefinition<T>> T baseTypeIfNotConstrained(final @NonNull T type,
final T base) {
final Optional<LengthConstraint> optConstraint = type.getLengthConstraint();
if (!optConstraint.isPresent()) {
*/
package org.opendaylight.yangtools.yang.model.util.type;
+import static com.google.common.base.Verify.verifyNotNull;
+
import com.google.common.annotations.Beta;
-import com.google.common.base.Verify;
import java.util.Objects;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
*
* @return A new type instance
*/
- @Nonnull abstract T buildType();
+ abstract @NonNull T buildType();
@Override
public final T build() {
return base;
}
- return Verify.verifyNotNull(buildType());
+ return verifyNotNull(buildType());
}
}
package org.opendaylight.yangtools.yang.model.util.type;
import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
* Support for creating {@link TypeDefinition} instances defined by leaf and leaf-list statements.
*/
@Beta
+@NonNullByDefault
public final class ConcreteTypes {
private ConcreteTypes() {
throw new UnsupportedOperationException();
}
- public static ConcreteTypeBuilder<?> concreteTypeBuilder(@Nonnull final TypeDefinition<?> baseType,
- @Nonnull final SchemaPath path) {
+ public static ConcreteTypeBuilder<?> concreteTypeBuilder(final TypeDefinition<?> baseType, final SchemaPath path) {
if (baseType instanceof BinaryTypeDefinition) {
return concreteBinaryBuilder((BinaryTypeDefinition) baseType, path);
} else if (baseType instanceof BitsTypeDefinition) {
}
private static ConcreteTypeBuilder<BinaryTypeDefinition> concreteBinaryBuilder(
- @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+ final BinaryTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<BinaryTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public BinaryTypeDefinition buildType() {
return new DerivedBinaryType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<BitsTypeDefinition> concreteBitsBuilder(final BitsTypeDefinition baseType,
final SchemaPath path) {
return new ConcreteTypeBuilder<BitsTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public BitsTypeDefinition buildType() {
return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
}
private static ConcreteTypeBuilder<BooleanTypeDefinition> concreteBooleanBuilder(
- @Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+ final BooleanTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<BooleanTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public BooleanTypeDefinition buildType() {
return new DerivedBooleanType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<DecimalTypeDefinition> concreteDecimalBuilder(
final DecimalTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<DecimalTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public DecimalTypeDefinition buildType() {
return new DerivedDecimalType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<EmptyTypeDefinition> concreteEmptyBuilder(final EmptyTypeDefinition baseType,
final SchemaPath path) {
return new ConcreteTypeBuilder<EmptyTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public EmptyTypeDefinition buildType() {
return new DerivedEmptyType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<EnumTypeDefinition> concreteEnumerationBuilder(
final EnumTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<EnumTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public EnumTypeDefinition buildType() {
return new DerivedEnumerationType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<IdentityrefTypeDefinition> concreteIdentityrefBuilder(
final IdentityrefTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public IdentityrefTypeDefinition buildType() {
return new DerivedIdentityrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<InstanceIdentifierTypeDefinition> concreteInstanceIdentifierBuilder(
final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<InstanceIdentifierTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public InstanceIdentifierTypeDefinition buildType() {
return new DerivedInstanceIdentifierType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Int8TypeDefinition> concreteInt8Builder(
final Int8TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Int8TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Int8TypeDefinition buildType() {
return new DerivedInt8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Int16TypeDefinition> concreteInt16Builder(
final Int16TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Int16TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Int16TypeDefinition buildType() {
return new DerivedInt16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Int32TypeDefinition> concreteInt32Builder(
final Int32TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Int32TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Int32TypeDefinition buildType() {
return new DerivedInt32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Int64TypeDefinition> concreteInt64Builder(
final Int64TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Int64TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Int64TypeDefinition buildType() {
return new DerivedInt64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<LeafrefTypeDefinition> concreteLeafrefBuilder(
final LeafrefTypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public LeafrefTypeDefinition buildType() {
return new DerivedLeafrefType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<StringTypeDefinition> concreteStringBuilder(final StringTypeDefinition baseType,
final SchemaPath path) {
return new ConcreteTypeBuilder<StringTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public StringTypeDefinition buildType() {
return new DerivedStringType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<UnionTypeDefinition> concreteUnionBuilder(final UnionTypeDefinition baseType,
final SchemaPath path) {
return new ConcreteTypeBuilder<UnionTypeDefinition>(baseType, path) {
- @Nonnull
@Override
public DerivedUnionType buildType() {
return new DerivedUnionType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Uint8TypeDefinition> concreteUint8Builder(
final Uint8TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Uint8TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Uint8TypeDefinition buildType() {
return new DerivedUint8Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Uint16TypeDefinition> concreteUint16Builder(
final Uint16TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Uint16TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Uint16TypeDefinition buildType() {
return new DerivedUint16Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Uint32TypeDefinition> concreteUint32Builder(
final Uint32TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Uint32TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Uint32TypeDefinition buildType() {
return new DerivedUint32Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
private static ConcreteTypeBuilder<Uint64TypeDefinition> concreteUint64Builder(
final Uint64TypeDefinition baseType, final SchemaPath path) {
return new ConcreteTypeBuilder<Uint64TypeDefinition>(baseType, path) {
- @Nonnull
@Override
public Uint64TypeDefinition buildType() {
return new DerivedUint64Type(getBaseType(), getPath(), getDefaultValue(), getDescription(),
import static java.util.Objects.requireNonNull;
import java.util.Optional;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
units = baseType.getUnits().orElse(null);
}
- public void setDefaultValue(@Nonnull final Object defaultValue) {
+ public void setDefaultValue(final @NonNull Object defaultValue) {
this.defaultValue = requireNonNull(defaultValue);
}
- public final void setDescription(@Nonnull final String description) {
+ public final void setDescription(final @NonNull String description) {
this.description = requireNonNull(description);
}
- public final void setReference(@Nonnull final String reference) {
+ public final void setReference(final @NonNull String reference) {
this.reference = requireNonNull(reference);
}
- public final void setStatus(@Nonnull final Status status) {
+ public final void setStatus(final @NonNull Status status) {
this.status = requireNonNull(status);
}
package org.opendaylight.yangtools.yang.model.util.type;
import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
throw new UnsupportedOperationException();
}
- public static DerivedTypeBuilder<?> derivedTypeBuilder(@Nonnull final TypeDefinition<?> baseType,
- @Nonnull final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<?> derivedTypeBuilder(final @NonNull TypeDefinition<?> baseType,
+ final @NonNull SchemaPath path) {
if (baseType instanceof BinaryTypeDefinition) {
return derivedBinaryBuilder((BinaryTypeDefinition) baseType, path);
} else if (baseType instanceof BitsTypeDefinition) {
}
}
- public static DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(
- @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<BinaryTypeDefinition> derivedBinaryBuilder(
+ final @NonNull BinaryTypeDefinition baseType, final @NonNull SchemaPath path) {
return new DerivedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
@Override
public BinaryTypeDefinition build() {
};
}
- public static DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType,
+ public static @NonNull DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType,
final SchemaPath path) {
return new DerivedTypeBuilder<BitsTypeDefinition>(baseType, path) {
@Override
};
}
- public static DerivedTypeBuilder<BooleanTypeDefinition> derivedBooleanBuilder(
- @Nonnull final BooleanTypeDefinition baseType, @Nonnull final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<BooleanTypeDefinition> derivedBooleanBuilder(
+ final @NonNull BooleanTypeDefinition baseType, final @NonNull SchemaPath path) {
return new DerivedTypeBuilder<BooleanTypeDefinition>(baseType, path) {
@Override
public BooleanTypeDefinition build() {
};
}
- private static DerivedTypeBuilder<DecimalTypeDefinition> derivedDecimalBuilder(final DecimalTypeDefinition baseType,
- final SchemaPath path) {
+ private static @NonNull DerivedTypeBuilder<DecimalTypeDefinition> derivedDecimalBuilder(
+ final DecimalTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<DecimalTypeDefinition>(baseType, path) {
@Override
public DecimalTypeDefinition build() {
};
}
- public static DerivedTypeBuilder<EmptyTypeDefinition> derivedEmptyBuilder(final EmptyTypeDefinition baseType,
- final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<EmptyTypeDefinition> derivedEmptyBuilder(
+ final EmptyTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<EmptyTypeDefinition>(baseType, path) {
@Override
public EmptyTypeDefinition build() {
};
}
- private static DerivedTypeBuilder<EnumTypeDefinition> derivedEnumerationBuilder(final EnumTypeDefinition baseType,
- final SchemaPath path) {
+ private static @NonNull DerivedTypeBuilder<EnumTypeDefinition> derivedEnumerationBuilder(
+ final EnumTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<EnumTypeDefinition>(baseType, path) {
@Override
public EnumTypeDefinition build() {
};
}
- public static DerivedTypeBuilder<IdentityrefTypeDefinition> derivedIdentityrefBuilder(
+ public static @NonNull DerivedTypeBuilder<IdentityrefTypeDefinition> derivedIdentityrefBuilder(
final IdentityrefTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
@Override
};
}
- public static DerivedTypeBuilder<InstanceIdentifierTypeDefinition> derivedInstanceIdentifierBuilder(
+ public static @NonNull DerivedTypeBuilder<InstanceIdentifierTypeDefinition> derivedInstanceIdentifierBuilder(
final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<InstanceIdentifierTypeDefinition>(baseType, path) {
@Override
};
}
- private static DerivedTypeBuilder<Int8TypeDefinition> derivedInt8Builder(final Int8TypeDefinition baseType,
+ private static @NonNull DerivedTypeBuilder<Int8TypeDefinition> derivedInt8Builder(final Int8TypeDefinition baseType,
final SchemaPath path) {
return new DerivedTypeBuilder<Int8TypeDefinition>(baseType, path) {
@Override
};
}
- public static DerivedTypeBuilder<Int16TypeDefinition> derivedInt16Builder(final Int16TypeDefinition baseType,
- final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<Int16TypeDefinition> derivedInt16Builder(
+ final Int16TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Int16TypeDefinition>(baseType, path) {
@Override
public Int16TypeDefinition build() {
};
}
- public static DerivedTypeBuilder<Int32TypeDefinition> derivedInt32Builder(final Int32TypeDefinition baseType,
- final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<Int32TypeDefinition> derivedInt32Builder(
+ final Int32TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Int32TypeDefinition>(baseType, path) {
@Override
public Int32TypeDefinition build() {
};
}
- private static DerivedTypeBuilder<Int64TypeDefinition> derivedInt64Builder(final Int64TypeDefinition baseType,
- final SchemaPath path) {
+ private static @NonNull DerivedTypeBuilder<Int64TypeDefinition> derivedInt64Builder(
+ final Int64TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Int64TypeDefinition>(baseType, path) {
@Override
public Int64TypeDefinition build() {
};
}
- public static DerivedTypeBuilder<LeafrefTypeDefinition> derivedLeafrefBuilder(final LeafrefTypeDefinition baseType,
- final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<LeafrefTypeDefinition> derivedLeafrefBuilder(
+ final LeafrefTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
@Override
public LeafrefTypeDefinition build() {
};
}
- private static DerivedTypeBuilder<StringTypeDefinition> derivedStringBuilder(final StringTypeDefinition baseType,
- final SchemaPath path) {
+ private static @NonNull DerivedTypeBuilder<StringTypeDefinition> derivedStringBuilder(
+ final StringTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<StringTypeDefinition>(baseType, path) {
@Override
public StringTypeDefinition build() {
};
}
- public static DerivedTypeBuilder<UnionTypeDefinition> derivedUnionBuilder(final UnionTypeDefinition baseType,
- final SchemaPath path) {
+ public static @NonNull DerivedTypeBuilder<UnionTypeDefinition> derivedUnionBuilder(
+ final UnionTypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<UnionTypeDefinition>(baseType, path) {
@Override
public DerivedUnionType build() {
};
}
- private static DerivedTypeBuilder<Uint8TypeDefinition> derivedUint8Builder(
+ private static @NonNull DerivedTypeBuilder<Uint8TypeDefinition> derivedUint8Builder(
final Uint8TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Uint8TypeDefinition>(baseType, path) {
@Override
};
}
- private static DerivedTypeBuilder<Uint16TypeDefinition> derivedUint16Builder(
+ private static @NonNull DerivedTypeBuilder<Uint16TypeDefinition> derivedUint16Builder(
final Uint16TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Uint16TypeDefinition>(baseType, path) {
@Override
};
}
- public static DerivedTypeBuilder<Uint32TypeDefinition> derivedUint32Builder(
+ public static @NonNull DerivedTypeBuilder<Uint32TypeDefinition> derivedUint32Builder(
final Uint32TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Uint32TypeDefinition>(baseType, path) {
@Override
};
}
- public static DerivedTypeBuilder<Uint64TypeDefinition> derivedUint64Builder(
+ public static @NonNull DerivedTypeBuilder<Uint64TypeDefinition> derivedUint64Builder(
final Uint64TypeDefinition baseType, final SchemaPath path) {
return new DerivedTypeBuilder<Uint64TypeDefinition>(baseType, path) {
@Override
import com.google.common.collect.ImmutableMap.Builder;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
super(baseType, path);
}
- public EnumerationTypeBuilder addEnum(@Nonnull final EnumPair item) {
+ public EnumerationTypeBuilder addEnum(final @NonNull EnumPair item) {
// in case we are dealing with a restricted enumeration type, validate if the enum is a subset of its base type
- if (getBaseType() != null) {
- validateRestrictedEnum(item);
+ final EnumTypeDefinition base = getBaseType();
+ if (base != null) {
+ validateRestrictedEnum(item, base);
}
builder.put(item.getName(), item);
return this;
}
- private void validateRestrictedEnum(@Nonnull final EnumPair item) {
+ private static void validateRestrictedEnum(final @NonNull EnumPair item, final @NonNull EnumTypeDefinition base) {
boolean isASubsetOfBaseEnums = false;
- for (EnumPair baseTypeEnumPair : getBaseType().getValues()) {
+ for (EnumPair baseTypeEnumPair : base.getValues()) {
if (item.getName().equals(baseTypeEnumPair.getName())) {
if (item.getValue() != baseTypeEnumPair.getValue()) {
throw new InvalidEnumDefinitionException(item, "Value of enum '%s' must be the same as the value"
+ " of corresponding enum in the base enumeration type %s.", item.getName(),
- getBaseType().getQName());
+ base.getQName());
}
isASubsetOfBaseEnums = true;
break;
if (!isASubsetOfBaseEnums) {
throw new InvalidEnumDefinitionException(item, "Enum '%s' is not a subset of its base enumeration type %s.",
- item.getName(), getBaseType().getQName());
+ item.getName(), base.getQName());
}
}
}
}
- if (getBaseType() == null) {
- return new BaseEnumerationType(getPath(), getUnknownSchemaNodes(), map.values());
- } else {
- return new RestrictedEnumerationType(getBaseType(), getPath(), getUnknownSchemaNodes(), map.values());
- }
+ return getBaseType() == null ? new BaseEnumerationType(getPath(), getUnknownSchemaNodes(), map.values())
+ : new RestrictedEnumerationType(getBaseType(), getPath(), getUnknownSchemaNodes(), map.values());
}
}
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import java.util.Set;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
super(null, path);
}
- public IdentityrefTypeBuilder addIdentity(@Nonnull final IdentitySchemaNode identity) {
+ public IdentityrefTypeBuilder addIdentity(final @NonNull IdentitySchemaNode identity) {
builder.add(identity);
return this;
}
*/
package org.opendaylight.yangtools.yang.model.util.type;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
InstanceIdentifierTypeBuilder(final InstanceIdentifierTypeDefinition baseType,
final SchemaPath path) {
- super(Preconditions.checkNotNull(baseType), path);
+ super(requireNonNull(baseType), path);
}
@Override
InstanceIdentifierTypeDefinition buildType() {
- if (getRequireInstance() == getBaseType().requireInstance()) {
- return getBaseType();
+ final InstanceIdentifierTypeDefinition base = getBaseType();
+ if (getRequireInstance() == base.requireInstance()) {
+ return base;
}
- return new RestrictedInstanceIdentifierType(getBaseType(), getPath(), getUnknownSchemaNodes(),
- getRequireInstance());
+ return new RestrictedInstanceIdentifierType(base, getPath(), getUnknownSchemaNodes(), getRequireInstance());
}
}
*/
package org.opendaylight.yangtools.yang.model.util.type;
-import com.google.common.base.Preconditions;
-import javax.annotation.Nonnull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
super(null, path);
}
- public LeafrefTypeBuilder setPathStatement(@Nonnull final RevisionAwareXPath pathStatement) {
- Preconditions.checkState(this.pathStatement == null, "Path statement already set to %s", this.pathStatement);
- this.pathStatement = Preconditions.checkNotNull(pathStatement);
+ public LeafrefTypeBuilder setPathStatement(final @NonNull RevisionAwareXPath pathStatement) {
+ checkState(this.pathStatement == null, "Path statement already set to %s", this.pathStatement);
+ this.pathStatement = requireNonNull(pathStatement);
return this;
}
import com.google.common.annotations.Beta;
import java.math.BigDecimal;
import java.math.BigInteger;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
throw new UnsupportedOperationException();
}
- public static LengthRestrictedTypeBuilder<BinaryTypeDefinition> newBinaryBuilder(
- @Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
+ public static @NonNull LengthRestrictedTypeBuilder<BinaryTypeDefinition> newBinaryBuilder(
+ final @NonNull BinaryTypeDefinition baseType, final @NonNull SchemaPath path) {
return new LengthRestrictedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
@Override
BinaryTypeDefinition buildType(final @Nullable LengthConstraint constraint) {
};
}
- public static BitsTypeBuilder newBitsBuilder(final BitsTypeDefinition baseType, final SchemaPath path) {
+ public static @NonNull BitsTypeBuilder newBitsBuilder(final BitsTypeDefinition baseType,
+ final SchemaPath path) {
return new BitsTypeBuilder(baseType, path);
}
- public static TypeBuilder<BooleanTypeDefinition> newBooleanBuilder(@Nonnull final BooleanTypeDefinition baseType,
- @Nonnull final SchemaPath path) {
+ public static @NonNull TypeBuilder<BooleanTypeDefinition> newBooleanBuilder(
+ final @NonNull BooleanTypeDefinition baseType, final @NonNull SchemaPath path) {
return new AbstractRestrictedTypeBuilder<BooleanTypeDefinition>(baseType, path) {
@Override
BooleanTypeDefinition buildType() {
};
}
- public static RangeRestrictedTypeBuilder<DecimalTypeDefinition, BigDecimal> newDecima64Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<DecimalTypeDefinition, BigDecimal> newDecima64Builder(
final DecimalTypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<DecimalTypeDefinition, BigDecimal>(baseType, path) {
@Override
};
}
- public static TypeBuilder<EmptyTypeDefinition> newEmptyBuilder(final EmptyTypeDefinition baseType,
+ public static @NonNull TypeBuilder<EmptyTypeDefinition> newEmptyBuilder(final EmptyTypeDefinition baseType,
final SchemaPath path) {
return new AbstractRestrictedTypeBuilder<EmptyTypeDefinition>(baseType, path) {
@Override
};
}
- public static EnumerationTypeBuilder newEnumerationBuilder(final EnumTypeDefinition baseType,
+ public static @NonNull EnumerationTypeBuilder newEnumerationBuilder(final EnumTypeDefinition baseType,
final SchemaPath path) {
return new EnumerationTypeBuilder(baseType, path);
}
- public static TypeBuilder<IdentityrefTypeDefinition> newIdentityrefBuilder(final IdentityrefTypeDefinition baseType,
- final SchemaPath path) {
+ public static @NonNull TypeBuilder<IdentityrefTypeDefinition> newIdentityrefBuilder(
+ final IdentityrefTypeDefinition baseType, final SchemaPath path) {
return new AbstractRestrictedTypeBuilder<IdentityrefTypeDefinition>(baseType, path) {
@Override
IdentityrefTypeDefinition buildType() {
};
}
- public static InstanceIdentifierTypeBuilder newInstanceIdentifierBuilder(
+ public static @NonNull InstanceIdentifierTypeBuilder newInstanceIdentifierBuilder(
final InstanceIdentifierTypeDefinition baseType, final SchemaPath path) {
return new InstanceIdentifierTypeBuilder(baseType, path);
}
- public static RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition> newLeafrefBuilder(
+ public static @NonNull RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition> newLeafrefBuilder(
final LeafrefTypeDefinition baseType, final SchemaPath path) {
return new RequireInstanceRestrictedTypeBuilder<LeafrefTypeDefinition>(baseType, path) {
@Override
LeafrefTypeDefinition buildType() {
- if (getRequireInstance() == getBaseType().requireInstance()) {
- return getBaseType();
+ final LeafrefTypeDefinition base = getBaseType();
+ if (getRequireInstance() == base.requireInstance()) {
+ return base;
}
return new RestrictedLeafrefType(getBaseType(), getPath(), getUnknownSchemaNodes(),
getRequireInstance());
};
}
- public static RangeRestrictedTypeBuilder<Int8TypeDefinition, Byte> newInt8Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Int8TypeDefinition, Byte> newInt8Builder(
final Int8TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Int8TypeDefinition, Byte>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Int16TypeDefinition, Short> newInt16Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Int16TypeDefinition, Short> newInt16Builder(
final Int16TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Int16TypeDefinition, Short>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Int32TypeDefinition, Integer> newInt32Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Int32TypeDefinition, Integer> newInt32Builder(
final Int32TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Int32TypeDefinition, Integer>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Int64TypeDefinition, Long> newInt64Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Int64TypeDefinition, Long> newInt64Builder(
final Int64TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Int64TypeDefinition, Long>(baseType, path) {
@Override
};
}
- public static StringTypeBuilder newStringBuilder(final StringTypeDefinition baseType, final SchemaPath path) {
+ public static @NonNull StringTypeBuilder newStringBuilder(final StringTypeDefinition baseType,
+ final SchemaPath path) {
return new StringTypeBuilder(baseType, path);
}
- public static TypeBuilder<UnionTypeDefinition> newUnionBuilder(final UnionTypeDefinition baseType,
+ public static @NonNull TypeBuilder<UnionTypeDefinition> newUnionBuilder(final UnionTypeDefinition baseType,
final SchemaPath path) {
return new AbstractRestrictedTypeBuilder<UnionTypeDefinition>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Uint8TypeDefinition, Short> newUint8Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Uint8TypeDefinition, Short> newUint8Builder(
final Uint8TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Uint8TypeDefinition, Short>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Uint16TypeDefinition, Integer> newUint16Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Uint16TypeDefinition, Integer> newUint16Builder(
final Uint16TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Uint16TypeDefinition, Integer>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Uint32TypeDefinition, Long> newUint32Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Uint32TypeDefinition, Long> newUint32Builder(
final Uint32TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Uint32TypeDefinition, Long>(baseType, path) {
@Override
};
}
- public static RangeRestrictedTypeBuilder<Uint64TypeDefinition, BigInteger> newUint64Builder(
+ public static @NonNull RangeRestrictedTypeBuilder<Uint64TypeDefinition, BigInteger> newUint64Builder(
final Uint64TypeDefinition baseType, final SchemaPath path) {
return new RangeRestrictedTypeBuilderWithBase<Uint64TypeDefinition, BigInteger>(baseType, path) {
@Override
*/
package org.opendaylight.yangtools.yang.model.util.type;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableList;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public abstract class TypeBuilder<T extends TypeDefinition<T>> implements Builder<T> {
private final ImmutableList.Builder<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.builder();
- private final SchemaPath path;
- private final T baseType;
+ private final @NonNull SchemaPath path;
+ private final @Nullable T baseType;
- TypeBuilder(final T baseType, final SchemaPath path) {
- this.path = Preconditions.checkNotNull(path);
+ TypeBuilder(final @Nullable T baseType, final SchemaPath path) {
+ this.path = requireNonNull(path);
this.baseType = baseType;
}
- final T getBaseType() {
+ final @Nullable T getBaseType() {
return baseType;
}
- final SchemaPath getPath() {
+ final @NonNull SchemaPath getPath() {
return path;
}
- final List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ final @NonNull List<UnknownSchemaNode> getUnknownSchemaNodes() {
return unknownSchemaNodes.build();
}
- public final void addUnknownSchemaNode(final UnknownSchemaNode node) {
+ public final void addUnknownSchemaNode(final @NonNull UnknownSchemaNode node) {
unknownSchemaNodes.add(node);
}
}
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
super(null, path);
}
- public UnionTypeBuilder addType(@Nonnull final TypeDefinition<?> type) {
+ public UnionTypeBuilder addType(final @NonNull TypeDefinition<?> type) {
builder.add(type);
return this;
}
import com.google.common.util.concurrent.SettableFuture;
import java.util.Arrays;
import java.util.concurrent.Future;
-import javax.annotation.Nonnull;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
private class Provider extends AbstractSchemaRepository {
@Deprecated
@Override
- public SchemaContextFactory createSchemaContextFactory(@Nonnull final SchemaSourceFilter filter) {
+ public SchemaContextFactory createSchemaContextFactory(final SchemaSourceFilter filter) {
return null;
}
@Override
- public SchemaContextFactory createSchemaContextFactory(
- @Nonnull final SchemaContextFactoryConfiguration config) {
+ public SchemaContextFactory createSchemaContextFactory(final SchemaContextFactoryConfiguration config) {
return null;
}
private class Consumer extends AbstractSchemaRepository {
@Deprecated
@Override
- public SchemaContextFactory createSchemaContextFactory(@Nonnull final SchemaSourceFilter filter) {
+ public SchemaContextFactory createSchemaContextFactory(final SchemaSourceFilter filter) {
return null;
}
@Override
- public SchemaContextFactory createSchemaContextFactory(
- @Nonnull final SchemaContextFactoryConfiguration config) {
+ public SchemaContextFactory createSchemaContextFactory(final SchemaContextFactoryConfiguration config) {
return null;
}
}