case NANOSECONDS:
return "ns";
case MICROSECONDS:
- return "\u03bcs"; // μs
+ return "μs";
case MILLISECONDS:
return "ms";
case SECONDS:
}
@Override
- UnmodifiableMapPhase<K, V> modifiedMap(final List<K> keys, final V[] objects) {
- return new ImmutableOffsetMap.Ordered<>(OffsetMapCache.orderedOffsets(keys), objects);
+ UnmodifiableMapPhase<K, V> modifiedMap(final List<K> keys, final V[] values) {
+ return new ImmutableOffsetMap.Ordered<>(OffsetMapCache.orderedOffsets(keys), values);
}
@Override
- UnmodifiableMapPhase<K, V> unmodifiedMap(final Map<K, Integer> offsets, final V[] objects) {
- return new ImmutableOffsetMap.Ordered<>(offsets, objects);
+ UnmodifiableMapPhase<K, V> unmodifiedMap(final Map<K, Integer> offsetMap, final V[] values) {
+ return new ImmutableOffsetMap.Ordered<>(offsetMap, values);
}
@Override
}
@Override
- UnmodifiableMapPhase<K, V> modifiedMap(final List<K> keys, final V[] objects) {
+ UnmodifiableMapPhase<K, V> modifiedMap(final List<K> keys, final V[] values) {
final Map<K, Integer> offsets = OffsetMapCache.unorderedOffsets(keys);
- return new ImmutableOffsetMap.Unordered<>(offsets, OffsetMapCache.adjustedArray(offsets, keys, objects));
+ return new ImmutableOffsetMap.Unordered<>(offsets, OffsetMapCache.adjustedArray(offsets, keys, values));
}
@Override
- UnmodifiableMapPhase<K, V> unmodifiedMap(final Map<K, Integer> offsets, final V[] objects) {
- return new ImmutableOffsetMap.Unordered<>(offsets, objects);
+ UnmodifiableMapPhase<K, V> unmodifiedMap(final Map<K, Integer> offsetMap, final V[] values) {
+ return new ImmutableOffsetMap.Unordered<>(offsetMap, values);
}
@Override
abstract Object removedObject();
- abstract UnmodifiableMapPhase<K, V> modifiedMap(List<K> keys, V[] objects);
+ abstract UnmodifiableMapPhase<K, V> modifiedMap(List<K> keys, V[] values);
- abstract UnmodifiableMapPhase<K, V> unmodifiedMap(Map<K, Integer> offsets, V[] objects);
+ abstract UnmodifiableMapPhase<K, V> unmodifiedMap(Map<K, Integer> offsetMap, V[] values);
abstract SharedSingletonMap<K, V> singletonMap();
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public final boolean containsValue(final Object value) {
return this.value.equals(value);
}
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public final V put(final K key, final V value) {
throw new UnsupportedOperationException();
}
reset(expCount);
}
- void reset(final int expCount) {
- this.expCount = expCount;
- latch = new CountDownLatch(expCount);
+ void reset(final int newExpCount) {
+ this.expCount = newExpCount;
+ latch = new CountDownLatch(newExpCount);
actual.clear();
}
@Test(expected = RejectedExecutionException.class)
public void testCachedThreadRejectingTask() throws InterruptedException {
- ExecutorService executor = SpecialExecutors.newBoundedCachedThreadPool(1, 1, "TestPool");
+ ExecutorService localExecutor = SpecialExecutors.newBoundedCachedThreadPool(1, 1, "TestPool");
for (int i = 0; i < 5; i++) {
- executor.execute(new Task(null, null, null, null, TimeUnit.MICROSECONDS.convert(5, TimeUnit.SECONDS)));
+ localExecutor.execute(new Task(null, null, null, null, TimeUnit.MICROSECONDS.convert(5, TimeUnit.SECONDS)));
}
}
testThreadPoolExecution(SpecialExecutors.newBlockingBoundedCachedThreadPool(2, 1, "TestPool"), 1000, null, 10);
}
- void testThreadPoolExecution(final ExecutorService executor, final int numTasksToRun, final String expThreadPrefix,
- final long taskDelay) throws InterruptedException {
+ void testThreadPoolExecution(final ExecutorService executorToTest, final int numTasksToRun,
+ final String expThreadPrefix, final long taskDelay) throws InterruptedException {
- this.executor = executor;
+ this.executor = executorToTest;
- LOG.debug("Testing {} with {} tasks.", executor.getClass().getSimpleName(), numTasksToRun);
+ LOG.debug("Testing {} with {} tasks.", executorToTest.getClass().getSimpleName(), numTasksToRun);
final CountDownLatch tasksRunLatch = new CountDownLatch(numTasksToRun);
final ConcurrentMap<Thread, AtomicLong> taskCountPerThread = new ConcurrentHashMap<>();
// Uninterruptibles.sleepUninterruptibly(20, TimeUnit.MICROSECONDS);
// }
- executor.execute(new Task(tasksRunLatch, taskCountPerThread, threadError, expThreadPrefix,
+ executorToTest.execute(new Task(tasksRunLatch, taskCountPerThread, threadError, expThreadPrefix,
taskDelay));
}
}
LOG.debug(" {} - {} tasks", e.getKey().getName(), e.getValue());
}
- LOG.debug("{}", executor);
+ LOG.debug("{}", executorToTest);
LOG.debug("Elapsed time: {}", stopWatch);
}
*
* @author Robert Varga
*/
-public class YangDataConstants {
+public final class YangDataConstants {
private static final String MODULE_NAME = "ietf-restconf";
private static final URI MODULE_NAMESPACE = URI.create("urn:ietf:params:xml:ns:yang:ietf-restconf");
private static final Revision RFC8040_REVISION = Revision.of("2017-01-26");
}
/**
- * Returns a namespace in form defined by section 5.6.4. of {@link https://tools.ietf.org/html/rfc6020}, for example
+ * Returns a namespace in form defined by section 5.6.4. of
+ * <a href=https://tools.ietf.org/html/rfc6020">RFC6020</a>, for example
* {@code http://example.acme.com/system?revision=2008-04-01}.
*
- * @return Namespace in form defined by section 5.6.4. of {@link https://tools.ietf.org/html/rfc6020}.
+ * @return Namespace in form defined by section 5.6.4. of RFC6020.
* @throws URISyntaxException on incorrect namespace definition
*
*/
*
* @param result the result value
*/
+ @SuppressWarnings("checkstyle:hiddenField")
public RpcResultBuilder<T> withResult(final T result) {
this.result = result;
return this;
/**
* Adds RpcErrors.
*
- * @param errors the list of RpcErrors
+ * @param rpcErrors the list of RpcErrors
*/
- public RpcResultBuilder<T> withRpcErrors(final Collection<RpcError> errors) {
- if (errors != null) {
- for (RpcError error : errors) {
+ public RpcResultBuilder<T> withRpcErrors(final Collection<RpcError> rpcErrors) {
+ if (rpcErrors != null) {
+ for (RpcError error : rpcErrors) {
addError(error);
}
}
*
* @param <K> {@link PathArgument} which identifies instance of {@link DataContainerNode}
*/
-public interface DataContainerNode<K extends PathArgument> extends //
+public interface DataContainerNode<K extends PathArgument> extends
NormalizedNodeContainer<K, PathArgument, DataContainerChild<? extends PathArgument, ?>> {
/**
* Returns iteration of all child nodes.
* Returns modified child or null if child was not modified
* / does not exists.
*
- * @param identifier Identifier of child node
+ * @param childIdentifier Identifier of child node
* @return Modified child or null if child was not modified.
*/
- @Nullable DataTreeCandidateNode getModifiedChild(PathArgument identifier);
+ @Nullable DataTreeCandidateNode getModifiedChild(PathArgument childIdentifier);
/**
* Return the type of modification this node is undergoing.
@Nullable
@Override
- public DataTreeCandidateNode getModifiedChild(final PathArgument identifier) {
+ public DataTreeCandidateNode getModifiedChild(final PathArgument childIdentifier) {
return null;
}
}
@Override
- public DataTreeCandidateNode getModifiedChild(final PathArgument identifier) {
+ public DataTreeCandidateNode getModifiedChild(final PathArgument childIdentifier) {
if (data instanceof NormalizedNodeContainer) {
@SuppressWarnings({ "rawtypes", "unchecked" })
- final Optional<? extends NormalizedNode<?, ?>> child = ((NormalizedNodeContainer)data).getChild(identifier);
+ final Optional<? extends NormalizedNode<?, ?>> child =
+ ((NormalizedNodeContainer)data).getChild(childIdentifier);
return child.map(input -> new NormalizedNodeDataTreeCandidateNode(input)).orElse(null);
}
return null;
assertEquals("Path size", 1, newID.getPathArguments().size());
assertEquals("PathArg 1 node type", NODENAME1, newID.getPathArguments().get(0).getNodeType());
- assertNotNull(newID.toString()); // for code coverage
+ // for code coverage
+ assertNotNull(newID.toString());
}
@Test
assertFalse("equals", node1.equals(new NodeIdentifierWithPredicates(NODENAME1, KEY1, "bar")));
assertFalse("equals", node1.equals(new Object()));
- assertNotNull(node1.toString()); // for code coverage
+ // for code coverage
+ assertNotNull(node1.toString());
assertNotNull(node1.toRelativeString(node2));
NodeIdentifierWithPredicates node3 = new NodeIdentifierWithPredicates(NODENAME1,
assertFalse("equals", node1.equals(new NodeWithValue<>(NODENAME2, "foo")));
assertFalse("equals", node1.equals(new Object()));
- assertNotNull(node1.toString()); // for code coverage
+ // for code coverage
+ assertNotNull(node1.toString());
assertNotNull(node1.toRelativeString(node2));
NodeWithValue<?> node3 = new NodeWithValue<>(NODENAME1, new byte[]{1,2});
assertFalse("equals", node1.equals(new NodeIdentifier(NODENAME3)));
assertFalse("equals", node1.equals(new Object()));
- assertNotNull(node1.toString()); // for code coverage
+ // for code coverage
+ assertNotNull(node1.toString());
}
@Test(expected = UnsupportedOperationException.class)
assertEquals("compareTo", 1, node1.compareTo(node4));
assertEquals("compareTo", -1, node4.compareTo(node1));
- assertNotNull(node1.toString()); // for code coverage
+ // for code coverage
+ assertNotNull(node1.toString());
assertNotNull(node1.toRelativeString(node5));
}
return isReferencedBy;
}
- public void setReferencedBy(final boolean isReferencedBy) {
- this.isReferencedBy = isReferencedBy;
+ public void setReferencedBy(final boolean referencedBy) {
+ this.isReferencedBy = referencedBy;
}
public boolean isReferencing() {
return isReferencing;
}
- public void setReferencing(final boolean isReferencing) {
- this.isReferencing = isReferencing;
+ public void setReferencing(final boolean referencing) {
+ this.isReferencing = referencing;
}
public void addReferencingChild(final LeafRefContext child, final QName childQName) {
}
@Override
- protected LeafRefPath createInstance(final LeafRefPath parent,
- final QNameWithPredicate qname) {
- return new AbsoluteLeafRefPath(parent, qname);
+ protected LeafRefPath createInstance(final LeafRefPath newParent,
+ final QNameWithPredicate newQname) {
+ return new AbsoluteLeafRefPath(newParent, newQname);
}
}
}
@Override
- protected LeafRefPath createInstance(final LeafRefPath parent,
- final QNameWithPredicate qname) {
- return new RelativeLeafRefPath(parent, qname);
+ protected LeafRefPath createInstance(final LeafRefPath newParent,
+ final QNameWithPredicate newQname) {
+ return new RelativeLeafRefPath(newParent, newQname);
}
}
private final int hash;
/**
- * Cached legacy path, filled-in when {@link #getPath()} or
+ * Cached legacy path, filled-in when {@link #getPathFromRoot()} or
* {@link #getPathTowardsRoot()} is invoked.
*/
private volatile ImmutableList<QNameWithPredicate> legacyPath;
/**
* Create a new instance.
*
- * @param parent
+ * @param newParent
* Parent LeafRefPath
- * @param qname
+ * @param newQname
* next path element
* @return A new LeafRefPath instance
*/
- protected abstract LeafRefPath createInstance(LeafRefPath parent,
- QNameWithPredicate qname);
+ protected abstract LeafRefPath createInstance(LeafRefPath newParent,
+ QNameWithPredicate newQname);
/**
* Create a child path based on concatenation of this path and a relative
return this;
}
- LeafRefPath parent = this;
- for (QNameWithPredicate qname : relative) {
- parent = parent.createInstance(parent, qname);
+ LeafRefPath newParent = this;
+ for (QNameWithPredicate relativeQname : relative) {
+ newParent = newParent.createInstance(newParent, relativeQname);
}
- return parent;
+ return newParent;
}
/**
public LeafRefPath createChild(final LeafRefPath relative) {
checkArgument(!relative.isAbsolute(), "Child creation requires relative path");
- LeafRefPath parent = this;
- for (QNameWithPredicate qname : relative.getPathFromRoot()) {
- parent = parent.createInstance(parent, qname);
+ LeafRefPath newParent = this;
+ for (QNameWithPredicate relativeQname : relative.getPathFromRoot()) {
+ newParent = newParent.createInstance(newParent, relativeQname);
}
- return parent;
+ return newParent;
}
/**
sb.append(isAbsolute() ? "Absolute path:" : "Relative path:");
- for (QNameWithPredicate qname : getPathFromRoot()) {
- sb.append('/').append(qname);
+ for (QNameWithPredicate qnameWithPredicate : getPathFromRoot()) {
+ sb.append('/').append(qnameWithPredicate);
}
return sb.toString();
}
final StringBuilder sb = new StringBuilder();
- String module = null;
+ String exceptionModule = null;
boolean first = true;
for (final LeafRefPathSyntaxErrorException e : exceptions) {
- if (module == null) {
- module = e.getModule();
+ if (exceptionModule == null) {
+ exceptionModule = e.getModule();
}
if (first) {
first = false;
sb.append(e.getFormattedMessage());
}
- throw new LeafRefPathSyntaxErrorException(module, 0, 0, sb.toString());
+ throw new LeafRefPathSyntaxErrorException(exceptionModule, 0, 0, sb.toString());
}
}
}
@Override
- public DataContainerNodeAttrBuilder<I, R> withAttributes(final Map<QName, String> attributes) {
- this.attributes = attributes;
+ public DataContainerNodeAttrBuilder<I, R> withAttributes(final Map<QName, String> withAttributes) {
+ this.attributes = withAttributes;
return this;
}
@Override
public DataContainerNodeAttrBuilder<I, R> withValue(
- final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
- return (DataContainerNodeAttrBuilder<I, R>) super.withValue(value);
+ final Collection<DataContainerChild<? extends PathArgument, ?>> withValue) {
+ return (DataContainerNodeAttrBuilder<I, R>) super.withValue(withValue);
}
@Override
}
@Override
- public DataContainerNodeAttrBuilder<I, R> withNodeIdentifier(final I nodeIdentifier) {
- return (DataContainerNodeAttrBuilder<I, R>) super.withNodeIdentifier(nodeIdentifier);
+ public DataContainerNodeAttrBuilder<I, R> withNodeIdentifier(final I withNodeIdentifier) {
+ return (DataContainerNodeAttrBuilder<I, R>) super.withNodeIdentifier(withNodeIdentifier);
}
}
@Override
public DataContainerNodeBuilder<I, R> withValue(
- final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
+ final Collection<DataContainerChild<? extends PathArgument, ?>> withValue) {
// TODO Replace or putAll ?
- for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : value) {
+ for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : withValue) {
withChild(dataContainerChild);
}
return this;
}
@Override
- public DataContainerNodeBuilder<I, R> withNodeIdentifier(final I nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ public DataContainerNodeBuilder<I, R> withNodeIdentifier(final I withNodeIdentifier) {
+ this.nodeIdentifier = withNodeIdentifier;
return this;
}
}
@Override
- public NormalizedNodeAttrBuilder<I, V, R> withValue(final V value) {
- this.value = requireNonNull(value);
+ public NormalizedNodeAttrBuilder<I, V, R> withValue(final V withValue) {
+ this.value = requireNonNull(withValue);
return this;
}
@Override
- public NormalizedNodeAttrBuilder<I, V, R> withNodeIdentifier(final I nodeIdentifier) {
- this.nodeIdentifier = requireNonNull(nodeIdentifier);
+ public NormalizedNodeAttrBuilder<I, V, R> withNodeIdentifier(final I withNodeIdentifier) {
+ this.nodeIdentifier = requireNonNull(withNodeIdentifier);
return this;
}
@Override
- public NormalizedNodeAttrBuilder<I, V, R> withAttributes(final Map<QName, String> attributes) {
- this.attributes = requireNonNull(attributes);
+ public NormalizedNodeAttrBuilder<I, V, R> withAttributes(final Map<QName, String> withAttributes) {
+ this.attributes = requireNonNull(withAttributes);
return this;
}
}
}
@Override
- public NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> withValue(final DOMSource value) {
- return super.withValue(value);
+ public NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> withValue(final DOMSource withValue) {
+ return super.withValue(withValue);
}
@Override
public NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> withNodeIdentifier(
- final NodeIdentifier nodeIdentifier) {
+ final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
@Override
public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withNodeIdentifier(
- final AugmentationIdentifier nodeIdentifier) {
+ final AugmentationIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
@Override
public DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> withNodeIdentifier(
- final NodeIdentifier nodeIdentifier) {
+ final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
@Override
public DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> withNodeIdentifier(
- final NodeIdentifier nodeIdentifier) {
+ final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
@Override
- protected byte[] wrapValue(final byte[] value) {
- return value.clone();
+ protected byte[] wrapValue(final byte[] valueToWrap) {
+ return valueToWrap.clone();
}
}
}
}
@Override
- public NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> withValue(final T value) {
+ public NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> withValue(final T withValue) {
// TODO: check value type
- return super.withValue(value);
+ return super.withValue(withValue);
}
@Override
public NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> withNodeIdentifier(
- final NodeIdentifier nodeIdentifier) {
+ final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
}
@Override
- public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withValue(final T value) {
- super.withNodeIdentifier(new NodeWithValue<>(schema.getQName(), value));
+ public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withValue(final T withValue) {
+ super.withNodeIdentifier(new NodeWithValue<>(schema.getQName(), withValue));
// TODO check value type using TypeProvider ?
- return super.withValue(value);
+ return super.withValue(withValue);
}
@Override
public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(
- final NodeWithValue nodeIdentifier) {
+ final NodeWithValue withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
+ this.nodeIdentifier = withNodeIdentifier;
return this;
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withValue(final Collection<LeafSetEntryNode<T>> value) {
- for (final LeafSetEntryNode<T> leafSetEntry : value) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withValue(final Collection<LeafSetEntryNode<T>> withValue) {
+ for (final LeafSetEntryNode<T> leafSetEntry : withValue) {
withChild(leafSetEntry);
}
return this;
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value, final Map<QName, String> attributes) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue,
+ final Map<QName, String> attributes) {
final ImmutableLeafSetEntryNodeBuilder<T> b = ImmutableLeafSetEntryNodeBuilder.create();
- b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), value));
- b.withValue(value);
+ b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), childValue));
+ b.withValue(childValue);
b.withAttributes(attributes);
return withChild(b.build());
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value) {
- return withChildValue(value, Collections.emptyMap());
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue) {
+ return withChildValue(childValue, Collections.emptyMap());
}
protected static final class ImmutableLeafSetNode<T> extends
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue) {
// TODO check value type
- return super.withChildValue(value);
+ return super.withChildValue(childValue);
}
@Override
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
@Override
public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withValue(
- final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
- fillQnames(value, childrenQNamesToPaths);
- return super.withValue(value);
+ final Collection<DataContainerChild<? extends PathArgument, ?>> withValue) {
+ fillQnames(withValue, childrenQNamesToPaths);
+ return super.withValue(withValue);
}
private static boolean isAugment(final PathArgument identifier) {
}
@Override
- public ImmutableMapEntryNodeBuilder withNodeIdentifier(final NodeIdentifierWithPredicates nodeIdentifier) {
+ public ImmutableMapEntryNodeBuilder withNodeIdentifier(final NodeIdentifierWithPredicates withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
@Override
- public CollectionNodeBuilder<MapEntryNode, MapNode> withValue(final Collection<MapEntryNode> value) {
+ public CollectionNodeBuilder<MapEntryNode, MapNode> withValue(final Collection<MapEntryNode> withValue) {
// TODO replace or putAll ?
- for (final MapEntryNode mapEntryNode : value) {
+ for (final MapEntryNode mapEntryNode : withValue) {
withChild(mapEntryNode);
}
}
@Override
- public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
+ this.nodeIdentifier = withNodeIdentifier;
return this;
}
}
@Override
- public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+ public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
+ this.nodeIdentifier = withNodeIdentifier;
return this;
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withValue(final Collection<LeafSetEntryNode<T>> value) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withValue(final Collection<LeafSetEntryNode<T>> withValue) {
checkDirty();
- for (final LeafSetEntryNode<T> leafSetEntry : value) {
+ for (final LeafSetEntryNode<T> leafSetEntry : withValue) {
withChild(leafSetEntry);
}
return this;
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value, final Map<QName, String> attributes) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue,
+ final Map<QName, String> attributes) {
final ImmutableLeafSetEntryNodeBuilder<T> b = ImmutableLeafSetEntryNodeBuilder.create();
- b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), value));
- b.withValue(value);
+ b.withNodeIdentifier(new NodeWithValue<>(nodeIdentifier.getNodeType(), childValue));
+ b.withValue(childValue);
b.withAttributes(attributes);
return withChild(b.build());
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value) {
- return withChildValue(value, Collections.emptyMap());
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue) {
+ return withChildValue(childValue, Collections.emptyMap());
}
protected static final class ImmutableOrderedLeafSetNode<T> extends
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T value) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(final T childValue) {
// TODO check value type
- return super.withChildValue(value);
+ return super.withChildValue(childValue);
}
@Override
}
@Override
- public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+ public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
}
@Override
- public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withValue(final Collection<MapEntryNode> value) {
+ public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withValue(final Collection<MapEntryNode> withValue) {
// TODO replace or putAll ?
- for (final MapEntryNode mapEntryNode : value) {
+ for (final MapEntryNode mapEntryNode : withValue) {
withChild(mapEntryNode);
}
}
@Override
- public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(
+ final NodeIdentifier withNodeIdentifier) {
+ this.nodeIdentifier = withNodeIdentifier;
return this;
}
}
@Override
- public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+ public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(
+ final NodeIdentifier withNodeIdentifier) {
throw new UnsupportedOperationException("Node identifier created from schema");
}
}
@Override
public CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> withValue(
- final Collection<UnkeyedListEntryNode> value) {
+ final Collection<UnkeyedListEntryNode> withValue) {
// TODO replace or putAll ?
- for (final UnkeyedListEntryNode node : value) {
+ for (final UnkeyedListEntryNode node : withValue) {
withChild(node);
}
@Override
public CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> withNodeIdentifier(
- final NodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ final NodeIdentifier withNodeIdentifier) {
+ this.nodeIdentifier = withNodeIdentifier;
return this;
}
return value;
}
- protected V wrapValue(final V value) {
- return value;
+ protected V wrapValue(final V valueToWrap) {
+ return valueToWrap;
}
}
AtomicReferenceFieldUpdater.newUpdater(AbstractCursorAware.class, AbstractCursor.class, "cursor");
private volatile AbstractCursor<?> cursor = null;
- protected <T extends AbstractCursor<?>> T openCursor(final T cursor) {
- final boolean success = CURSOR_UPDATER.compareAndSet(this, null, cursor);
+ protected <T extends AbstractCursor<?>> T openCursor(final T cursorToOpen) {
+ final boolean success = CURSOR_UPDATER.compareAndSet(this, null, cursorToOpen);
Preconditions.checkState(success, "Modification %s has cursor attached at path %s", this,
this.cursor.getRootPath());
- return cursor;
+ return cursorToOpen;
}
- final void closeCursor(final AbstractCursor<?> cursor) {
- final boolean success = CURSOR_UPDATER.compareAndSet(this, cursor, null);
+ final void closeCursor(final AbstractCursor<?> cursorToClose) {
+ final boolean success = CURSOR_UPDATER.compareAndSet(this, cursorToClose, null);
if (!success) {
- LOG.warn("Attempted to close cursor {} while {} is open", cursor, this.cursor);
+ LOG.warn("Attempted to close cursor {} while {} is open", cursorToClose, this.cursor);
}
}
}
/**
* Records a write for associated node.
*
- * @param value new value
+ * @param newValue new value
*/
- void write(final NormalizedNode<?, ?> value) {
- updateValue(LogicalOperation.WRITE, value);
+ void write(final NormalizedNode<?, ?> newValue) {
+ updateValue(LogicalOperation.WRITE, newValue);
children.clear();
}
* Update this node's value and operation type without disturbing any of its child modifications.
*
* @param type New operation type
- * @param value New node value
+ * @param newValue New node value
*/
- void updateValue(final LogicalOperation type, final NormalizedNode<?, ?> value) {
- this.value = requireNonNull(value);
+ void updateValue(final LogicalOperation type, final NormalizedNode<?, ?> newValue) {
+ this.value = requireNonNull(newValue);
updateOperationType(type);
}
@Test(expected = IllegalArgumentException.class)
@Ignore
public void incorrectLeafRefPathTest() {
- final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory(
- "/leafref-context-test/incorrect-modules");
- LeafRefContext.create(context);
+ LeafRefContext.create(
+ YangParserTestUtils.parseYangResourceDirectory("/leafref-context-test/incorrect-modules"));
}
}
@Test
public void minMaxListNoMinMaxDeleteTest() throws DataValidationFailedException {
- final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME,
- "foo");
+ final MapEntryNode fooEntryNoMinMaxNode =
+ ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME, "foo");
final MapNode mapNode1 = ImmutableNodes.mapNodeBuilder()
.withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX))
- .withChild(fooEntryNode).build();
+ .withChild(fooEntryNoMinMaxNode).build();
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
checkValid(!pathComponents.isEmpty(), "Malformed path key expression: '%s'.", pathKeyExpression);
boolean inNodeIdentifierPart = false;
- NormalizedNodeContext currentNodeCtx = this.currentNodeCtx;
- NormalizedNode<?, ?> currentNode = null;
+ NormalizedNodeContext nodeCtx = this.currentNodeCtx;
+ NormalizedNode<?, ?> node = null;
for (String pathComponent : pathComponents) {
final Matcher matcher = NODE_IDENTIFIER_PATTERN.matcher(pathComponent);
if (UP_ONE_LEVEL.equals(pathComponent)) {
checkValid(!inNodeIdentifierPart, "Up-one-level expression cannot follow concrete path component.");
- currentNodeCtx = currentNodeCtx.getParent();
- currentNode = currentNodeCtx.getNode();
+ nodeCtx = nodeCtx.getParent();
+ node = nodeCtx.getNode();
offset += UP_ONE_LEVEL.length() + 1;
} else if (matcher.matches()) {
inNodeIdentifierPart = true;
- if (currentNode != null && currentNode instanceof DataContainerNode) {
- final DataContainerNode dcn = (DataContainerNode) currentNode;
+ if (node != null && node instanceof DataContainerNode) {
+ final DataContainerNode dcn = (DataContainerNode) node;
final Optional<NormalizedNode<?, ?>> possibleChild = dcn.getChild(new NodeIdentifier(nextQName()));
- currentNode = possibleChild.isPresent() ? possibleChild.get() : null;
+ node = possibleChild.isPresent() ? possibleChild.get() : null;
}
} else {
throw new IllegalArgumentException(String.format(
}
}
- if (currentNode != null && currentNode instanceof LeafNode) {
- return currentNode.getValue();
+ if (node != null && node instanceof LeafNode) {
+ return node.getValue();
}
throw new IllegalArgumentException("Could not resolve current function path value.");
}
@Override
- public void setMavenProject(final MavenProject project) {
- GeneratorMock.project = project;
+ public void setMavenProject(final MavenProject mavenProject) {
+ GeneratorMock.project = mavenProject;
}
@Override
}
@Override
- public AbsoluteSchemaPath createChild(final QName qname) {
- return new AbsoluteSchemaPath(this, requireNonNull(qname));
+ public AbsoluteSchemaPath createChild(final QName element) {
+ return new AbsoluteSchemaPath(this, requireNonNull(element));
}
}
}
@Override
- public RelativeSchemaPath createChild(final QName qname) {
- return new RelativeSchemaPath(this, requireNonNull(qname));
+ public RelativeSchemaPath createChild(final QName element) {
+ return new RelativeSchemaPath(this, requireNonNull(element));
}
}
ImmutableList<QName> ret = legacyPath;
if (ret == null) {
final List<QName> tmp = new ArrayList<>();
- for (QName qname : getPathTowardsRoot()) {
- tmp.add(qname);
+ for (QName item : getPathTowardsRoot()) {
+ tmp.add(item);
}
ret = ImmutableList.copyOf(Lists.reverse(tmp));
LEGACYPATH_UPDATER.lazySet(this, ret);
}
SchemaPath parentPath = this;
- for (QName qname : relative) {
- parentPath = parentPath.createChild(qname);
+ for (QName item : relative) {
+ parentPath = parentPath.createChild(item);
}
return parentPath;
}
SchemaNodeIdentifier parentNode = this;
- for (QName qname : relative) {
- parentNode = parentNode.createChild(qname);
+ for (QName item : relative) {
+ parentNode = parentNode.createChild(item);
}
return parentNode;
ListenableFuture<D> apply(@Nonnull S input) throws Exception;
}
- private final Map<PotentialSchemaSource<?>, RefcountedRegistration> sources = new HashMap<>();
+ private final Map<PotentialSchemaSource<?>, RefcountedRegistration> availableSources = new HashMap<>();
private final SchemaSourceRegistry consumer;
private final SchemaRepository provider;
private final AsyncFunction<S, D> function;
}
private void registerSource(final PotentialSchemaSource<?> src) {
- RefcountedRegistration reg = sources.get(src);
+ RefcountedRegistration reg = availableSources.get(src);
if (reg != null) {
reg.incRef();
return;
src.getCost() + PotentialSchemaSource.Costs.COMPUTATION.getValue());
final SchemaSourceRegistration<D> r = consumer.registerSchemaSource(this, newSrc);
- sources.put(src, new RefcountedRegistration(r));
+ availableSources.put(src, new RefcountedRegistration(r));
}
private void unregisterSource(final PotentialSchemaSource<?> src) {
- final RefcountedRegistration reg = sources.get(src);
+ final RefcountedRegistration reg = availableSources.get(src);
if (reg != null && reg.decRef()) {
- sources.remove(src);
+ availableSources.remove(src);
}
}
}
touch();
}
- abstract T buildType(LengthConstraint lengthConstraint);
+ abstract T buildType(LengthConstraint constraint);
@Override
final T buildType() {
super(baseType, path);
}
+ @SuppressWarnings("checkstyle:hiddenField")
public final void setRangeConstraint(final @NonNull ConstraintMetaDefinition constraint,
final @NonNull List<ValueRange> ranges) {
checkState(this.ranges == null, "Range constraint already defined as %s %s", this.ranges, this.constraint);
@Nonnull final BinaryTypeDefinition baseType, @Nonnull final SchemaPath path) {
return new LengthRestrictedTypeBuilder<BinaryTypeDefinition>(baseType, path) {
@Override
- BinaryTypeDefinition buildType(final @Nullable LengthConstraint lengthConstraint) {
- return new RestrictedBinaryType(getBaseType(), getPath(), getUnknownSchemaNodes(), lengthConstraint);
+ BinaryTypeDefinition buildType(final @Nullable LengthConstraint constraint) {
+ return new RestrictedBinaryType(getBaseType(), getPath(), getUnknownSchemaNodes(), constraint);
}
@Override
}
@Override
- StringTypeDefinition buildType(final @Nullable LengthConstraint lengthConstraints) {
- return new RestrictedStringType(getBaseType(), getPath(), getUnknownSchemaNodes(),
- lengthConstraints, patternConstraints);
+ StringTypeDefinition buildType(final @Nullable LengthConstraint constraint) {
+ return new RestrictedStringType(getBaseType(), getPath(), getUnknownSchemaNodes(), constraint,
+ patternConstraints);
}
}
}
@Test
- public void schemaSourceTransformerGetSourceTest() throws Exception {
+ public void schemaSourceTransformerGetSourceTest() {
final Provider p = new Provider();
final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS,
PotentialSchemaSource.Costs.IMMEDIATE);
this.schema = new SchemaSourceTransformer<>(p,
SchemaSourceTransformerTest.SRC_CLASS, this.consumer, SchemaSourceTransformerTest.DST_CLASS,
this.function);
- final SchemaSourceProvider<YinXmlSchemaSource> provider = this.schema;
- final Future<? extends YinXmlSchemaSource> source = provider.getSource(sourceIdentifier);
+ final SchemaSourceProvider<YinXmlSchemaSource> prov = this.schema;
+ final Future<? extends YinXmlSchemaSource> source = prov.getSource(sourceIdentifier);
Assert.assertNotNull(source);
source.cancel(true);
Assert.assertTrue(source.isDone());
}
@Test
- public void schemaSourceRegAndUnregSchemaSourceTest() throws Exception {
+ public void schemaSourceRegAndUnregSchemaSourceTest() {
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("source");
final Foo<YangSchemaSourceRepresentation> foo = new Foo<>(sourceIdentifier,
SchemaSourceTransformerTest.SRC_CLASS,
doReturn(groupings).when(mockedModule).getGroupings();
- final DataNodeIterator dataNodeIterator = new DataNodeIterator(mockedModule);
- assertFalse(dataNodeIterator.allContainers().contains(mockedAugmentingContainer));
- assertTrue(dataNodeIterator.allContainers().contains(mockedContainer));
- assertTrue(dataNodeIterator.allLists().contains(mockedList));
- assertTrue(dataNodeIterator.allChoices().contains(mockedChoice));
- assertTrue(dataNodeIterator.allChoices().get(0).getCases().values().contains(mockedCase1));
- assertTrue(dataNodeIterator.allChoices().get(0).getCases().values().contains(mockedCase2));
- assertTrue(dataNodeIterator.allContainers().contains(mockedContainerInNotification));
- assertTrue(dataNodeIterator.allLists().contains(mockedListInRpcInputContainer));
- assertTrue(dataNodeIterator.allGroupings().contains(mockedGrouping));
+ final DataNodeIterator it = new DataNodeIterator(mockedModule);
+ assertFalse(it.allContainers().contains(mockedAugmentingContainer));
+ assertTrue(it.allContainers().contains(mockedContainer));
+ assertTrue(it.allLists().contains(mockedList));
+ assertTrue(it.allChoices().contains(mockedChoice));
+ assertTrue(it.allChoices().get(0).getCases().values().contains(mockedCase1));
+ assertTrue(it.allChoices().get(0).getCases().values().contains(mockedCase2));
+ assertTrue(it.allContainers().contains(mockedContainerInNotification));
+ assertTrue(it.allLists().contains(mockedListInRpcInputContainer));
+ assertTrue(it.allGroupings().contains(mockedGrouping));
}
}
final class SharedSchemaContextFactory implements SchemaContextFactory {
private static final Logger LOG = LoggerFactory.getLogger(SharedSchemaContextFactory.class);
- private final Cache<Collection<SourceIdentifier>, SchemaContext> cache = CacheBuilder.newBuilder().weakValues()
- .build();
+ private final Cache<Collection<SourceIdentifier>, SchemaContext> revisionCache = CacheBuilder.newBuilder()
+ .weakValues().build();
private final Cache<Collection<SourceIdentifier>, SchemaContext> semVerCache = CacheBuilder.newBuilder()
.weakValues().build();
private final SharedSchemaRepository repository;
public ListenableFuture<SchemaContext> createSchemaContext(final Collection<SourceIdentifier> requiredSources,
final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
return createSchemaContext(requiredSources,
- statementParserMode == StatementParserMode.SEMVER_MODE ? this.semVerCache : this.cache,
+ statementParserMode == StatementParserMode.SEMVER_MODE ? this.semVerCache : this.revisionCache,
new AssembleSources(Optional.ofNullable(supportedFeatures), statementParserMode));
}
}
@Beta
+ @SuppressWarnings("checkstyle:avoidHidingCauseException")
public SchemaContext trySchemaContext(final StatementParserMode statementParserMode)
throws SchemaResolutionException {
final ListenableFuture<SchemaContext> future = repository
return enabledSemanticVersions;
}
- StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase currentPhase) {
- return supports.get(currentPhase);
+ StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase phase) {
+ return supports.get(phase);
}
void addSource(@Nonnull final StatementStreamSource source) {
}
@SuppressWarnings("checkstyle:illegalCatch")
- private void loadPhaseStatementsFor(final Set<SourceSpecificContext> sources) throws ReactorException {
- for (final SourceSpecificContext source : sources) {
+ private void loadPhaseStatementsFor(final Set<SourceSpecificContext> srcs) throws ReactorException {
+ for (final SourceSpecificContext source : srcs) {
try {
source.loadStatements();
} catch (final RuntimeException ex) {
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public void apply(final InferenceAction action) {
Preconditions.checkState(this.action == null, "Action already defined to %s", this.action);
this.action = Preconditions.checkNotNull(action);
private T value;
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public final T resolve(final InferenceContext ctx) {
Preconditions.checkState(done);
Preconditions.checkArgument(ctx == ModifierImpl.this.ctx);
return done;
}
+ @SuppressWarnings("checkstyle:hiddenField")
final boolean resolvePrereq(final T value) {
this.value = value;
this.done = true;
}
final <O> Prerequisite<O> transform(final Function<? super T, O> transformation) {
- return ctx -> transformation.apply(resolve(ctx));
+ return context -> transformation.apply(resolve(context));
}
@Override
implements OnPhaseFinished {
@SuppressWarnings("unchecked")
@Override
- public boolean phaseFinished(final StatementContextBase<?, ?, ?> context, final ModelProcessingPhase phase) {
+ public boolean phaseFinished(final StatementContextBase<?, ?, ?> context,
+ final ModelProcessingPhase finishedPhase) {
return resolvePrereq((C) context);
}
}
@SuppressWarnings("unchecked")
@Override
- public boolean phaseFinished(final StatementContextBase<?, ?, ?> context, final ModelProcessingPhase phase) {
+ public boolean phaseFinished(final StatementContextBase<?, ?, ?> context,
+ final ModelProcessingPhase finishedPhase) {
return resolvePrereq((C) context);
}
private final SourceSpecificContext sourceContext;
private final A argument;
- private YangVersion version;
+ private YangVersion rootVersion;
private Collection<SourceIdentifier> requiredSources = ImmutableSet.of();
- private SourceIdentifier identifier;
+ private SourceIdentifier rootIdentifier;
/**
* References to RootStatementContext of submodules which are included in this source.
@Override
public YangVersion getRootVersion() {
- return version == null ? DEFAULT_VERSION : version;
+ return rootVersion == null ? DEFAULT_VERSION : rootVersion;
}
@Override
public void setRootVersion(final YangVersion version) {
checkArgument(sourceContext.getSupportedVersions().contains(version),
"Unsupported yang version %s in %s", version, getStatementSourceReference());
- checkState(this.version == null, "Version of root %s has been already set to %s", argument,
- this.version);
- this.version = requireNonNull(version);
+ checkState(this.rootVersion == null, "Version of root %s has been already set to %s", argument,
+ this.rootVersion);
+ this.rootVersion = requireNonNull(version);
}
@Override
@Override
public void setRootIdentifier(final SourceIdentifier identifier) {
- this.identifier = requireNonNull(identifier);
+ this.rootIdentifier = requireNonNull(identifier);
}
SourceIdentifier getRootIdentifier() {
- return identifier;
+ return rootIdentifier;
}
@Override
/**
* Invoked whenever a processing phase has finished.
*/
- boolean phaseFinished(StatementContextBase<?, ?, ?> context, ModelProcessingPhase phase);
+ boolean phaseFinished(StatementContextBase<?, ?, ?> context, ModelProcessingPhase finishedPhase);
}
/**
}
public void removeStatementsFromEffectiveSubstatements(
- final Collection<? extends StmtContext<?, ?, ?>> substatements) {
+ final Collection<? extends StmtContext<?, ?, ?>> statements) {
if (!effective.isEmpty()) {
- effective.removeAll(substatements);
+ effective.removeAll(statements);
shrinkEffective();
}
}
/**
* Adds an effective statement to collection of substatements.
*
- * @param substatements substatements
+ * @param statements substatements
* @throws IllegalStateException
* if added in declared phase
* @throws NullPointerException
* if statement parameter is null
*/
- public void addEffectiveSubstatements(final Collection<? extends Mutable<?, ?, ?>> substatements) {
- if (substatements.isEmpty()) {
+ public void addEffectiveSubstatements(final Collection<? extends Mutable<?, ?, ?>> statements) {
+ if (statements.isEmpty()) {
return;
}
- substatements.forEach(Preconditions::checkNotNull);
- beforeAddEffectiveStatement(substatements.size());
- effective.addAll(substatements);
+ statements.forEach(Preconditions::checkNotNull);
+ beforeAddEffectiveStatement(statements.size());
+ effective.addAll(statements);
}
private void beforeAddEffectiveStatement(final int toAdd) {
final ModelProcessingPhase phase, final NamespaceKeyCriterion<K> criterion,
final OnNamespaceItemAdded listener) {
((StatementContextBase<?, ? ,?>) value).addPhaseCompletedListener(phase,
- (context, completedPhase) -> {
+ (context, phaseCompleted) -> {
selectMatch(type, criterion, listener);
return true;
});
}
@Override
- StatementMap put(final int index, final StatementContextBase<?, ?, ?> object) {
- return index == 0 ? new Singleton(object) : new Regular(index, object);
+ StatementMap put(final int index, final StatementContextBase<?, ?, ?> obj) {
+ return index == 0 ? new Singleton(obj) : new Regular(index, obj);
}
@Override
}
@Override
- StatementMap put(final int index, final StatementContextBase<?, ?, ?> object) {
+ StatementMap put(final int index, final StatementContextBase<?, ?, ?> obj) {
if (index < elements.length) {
checkArgument(elements[index] == null);
} else {
elements = Arrays.copyOf(elements, index + 1);
}
- elements[index] = requireNonNull(object);
+ elements[index] = requireNonNull(obj);
return this;
}
}
@Override
- StatementMap put(final int index, final StatementContextBase<?, ?, ?> object) {
+ StatementMap put(final int index, final StatementContextBase<?, ?, ?> obj) {
checkArgument(index != 0);
- return new Regular(this.object, index, object);
+ return new Regular(this.object, index, obj);
}
@Override
* Add a statement at specified index.
*
* @param index Element index, must be non-negative
- * @param object Object to store
+ * @param obj Object to store
* @return New statement map
* @throws IllegalArgumentException if the index is already occupied
*/
- abstract @Nonnull StatementMap put(int index, @Nonnull StatementContextBase<?, ?, ?> object);
+ abstract @Nonnull StatementMap put(int index, @Nonnull StatementContextBase<?, ?, ?> obj);
/**
* Return a read-only view of the elements in this map. Unlike other maps, this view does not detect concurrent
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.repo;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.ArrayDeque;
import java.util.Deque;
import org.opendaylight.yangtools.yang.parser.spi.source.DeclarationInTextSource;
private final Document doc;
private final String file;
- private Locator locator;
+ private Locator documentLocator;
StatementSourceReferenceHandler(final Document doc, final String file) {
- this.doc = Preconditions.checkNotNull(doc);
+ this.doc = requireNonNull(doc);
this.file = file;
}
@Override
public void setDocumentLocator(final Locator locator) {
// Save the locator, so that it can be used later for line tracking when traversing nodes.
- this.locator = locator;
+ this.documentLocator = locator;
}
@Override
el.setAttributeNS(attributes.getURI(i), attributes.getQName(i), attributes.getValue(i));
}
- final StatementSourceReference ref = DeclarationInTextSource.atPosition(file, locator.getLineNumber(),
- locator.getColumnNumber());
+ final StatementSourceReference ref = DeclarationInTextSource.atPosition(file, documentLocator.getLineNumber(),
+ documentLocator.getColumnNumber());
el.setUserData(USER_DATA_KEY, ref, null);
stack.push(el);
}
import java.util.ArrayList;
import java.util.List;
import org.antlr.v4.runtime.BaseErrorListener;
-import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
exceptions.add(new YangSyntaxErrorException(source, line, charPositionInLine, msg, e));
}
- @SuppressWarnings("checkstyle:illegalCatch")
- private static String getModuleName(final Recognizer<?, ?> recognizer) {
- if (!(recognizer instanceof Parser)) {
- return null;
- }
-
- final Parser parser = (Parser) recognizer;
- try {
- String model = parser.getInputStream().getTokenSource().getInputStream().toString();
- model = model.substring(0, model.indexOf('\n'));
- model = model.substring(model.indexOf("module") + 6);
- model = model.substring(0, model.indexOf('{'));
- model = model.trim();
- return model;
- } catch (Exception e) {
- LOG.debug("Failed to extract module name from parser {}", parser, e);
- return null;
- }
- }
-
public void validate() throws YangSyntaxErrorException {
if (exceptions.isEmpty()) {
return;
}
final StringBuilder sb = new StringBuilder();
- SourceIdentifier source = null;
boolean first = true;
for (YangSyntaxErrorException e : exceptions) {
- if (source == null) {
- source = e.getSource().orElse(null);
- }
if (first) {
first = false;
} else {
/**
* Dependency information for YANG module.
*/
- public static class ModuleDependencyInfo extends YangModelDependencyInfo {
+ public static final class ModuleDependencyInfo extends YangModelDependencyInfo {
private ModuleDependencyInfo(final String name, final String latestRevision,
final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
super(name, latestRevision, imports, includes);
this.sourceName = sourceName;
}
+ @SuppressWarnings("checkstyle:hiddenField")
public void setAttributes(final StatementWriter writer, final QNameToStatementDefinition stmtDef) {
this.writer = writer;
this.stmtDef = stmtDef;
initCounters();
}
+ @SuppressWarnings("checkstyle:hiddenField")
public void setAttributes(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
final PrefixToModule prefixes) {
this.writer = writer;
initCounters();
}
+ @SuppressWarnings("checkstyle:hiddenField")
public void setAttributes(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
final PrefixToModule prefixes, final YangVersion yangVersion) {
this.yangVersion = yangVersion;
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public final Optional<DataSchemaNode> findDataChildByName(final QName name) {
// Child nodes are keyed by their container name, so we can do a direct lookup
return Optional.ofNullable(childNodes.get(requireNonNull(name)));
// initCopyType
final CopyHistory copyTypesFromOriginal = ctx.getCopyHistory();
if (copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) {
- this.addedByUses = this.addedByAugmentation = true;
+ this.addedByAugmentation = true;
+ this.addedByUses = true;
} else {
this.addedByAugmentation = copyTypesFromOriginal.contains(CopyType.ADDED_BY_AUGMENTATION);
this.addedByUses = copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES);
// initCopyType
final CopyHistory copyTypesFromOriginal = ctx.getCopyHistory();
if (copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) {
- this.addedByUses = this.augmenting = true;
+ this.augmenting = true;
+ this.addedByUses = true;
} else {
this.augmenting = copyTypesFromOriginal.contains(CopyType.ADDED_BY_AUGMENTATION);
this.addedByUses = copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES);
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
stmt.addToNs(ModuleNameToModuleQName.class, stmt.getStatementArgument(), qNameModule);
- stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule); // tu
+ stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
stmt.addToNs(ModuleCtxToSourceIdentifier.class, stmt, moduleIdentifier);
stmt.addToNs(ModuleQNameToModuleName.class, qNameModule, stmt.getStatementArgument());
stmt.addToNs(ImportPrefixToModuleCtx.class, modulePrefix, stmt);
// initCopyType
final CopyHistory copyTypesFromOriginal = ctx.getCopyHistory();
if (copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) {
- this.addedByUses = this.augmenting = true;
+ this.augmenting = true;
+ this.addedByUses = true;
} else {
this.augmenting = copyTypesFromOriginal.contains(CopyType.ADDED_BY_AUGMENTATION);
this.addedByUses = copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES);
@Test
public void testOrderingNestedChildNodes3() throws Exception {
- final Module baz = TestUtils.loadModuleResources(getClass(), "/ordering/foo.yang")
+ final Module justFoo = TestUtils.loadModuleResources(getClass(), "/ordering/foo.yang")
.getModules().iterator().next();
- final ContainerSchemaNode x = (ContainerSchemaNode) baz
- .getDataChildByName(QName.create(baz.getQNameModule(), "x"));
+ final ContainerSchemaNode x = (ContainerSchemaNode) justFoo
+ .getDataChildByName(QName.create(justFoo.getQNameModule(), "x"));
final Collection<DataSchemaNode> childNodes = x.getChildNodes();
final String[] expectedOrder = { "x15", "x10", "x5", "x1", "a5", "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" };
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
-public class StmtTestUtils {
+public final class StmtTestUtils {
public static final FileFilter YANG_FILE_FILTER =
file -> file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile();
EnumTypeDefinition enumType = (EnumTypeDefinition) testedType.getBaseType();
List<EnumPair> values = enumType.getValues();
- assertEquals(415, values.size()); // 0-414
+ // 0-414
+ assertEquals(415, values.size());
EnumPair enum168 = values.get(168);
assertEquals("America/Danmarkshavn", enum168.getName());