* Remove intern() on constant strings.
* Avoid some casts by changing test instance types.
* Remove a number of unnecessary type specifiers and casts.
* Remove an unnecessary return.
* Use StringBuilder::append()'s substring parameters instead of a
separate String::substring().
Change-Id: Iaaa206d233fbc43ed1bed2d651c549643e6e7697
Signed-off-by: Stephen Kitt <skitt@redhat.com>
(cherry picked from commit
a993ec185764e9f07b7f1c6751bad8f63f6eecc7)
static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice").intern();
static final QName ID_QNAME = QName.create(TEST_QNAME, "id").intern();
static final QName NAME_QNAME = QName.create(TEST_QNAME, "name").intern();
- static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value".intern());
+ static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value").intern();
private BenchmarkModel() {
public void testValidSimple() throws Exception {
Set<Node> nodes = new HashSet<>();
- Node node1 = new NodeImpl();
+ NodeImpl node1 = new NodeImpl();
nodes.add(node1);
- Node node2 = new NodeImpl();
+ NodeImpl node2 = new NodeImpl();
nodes.add(node2);
- Node node3 = new NodeImpl();
+ NodeImpl node3 = new NodeImpl();
nodes.add(node3);
Node node4 = new NodeImpl();
nodes.add(node4);
- ((NodeImpl) node1).addEdge(node2);
- ((NodeImpl) node1).addEdge(node3);
- ((NodeImpl) node2).addEdge(node4);
- ((NodeImpl) node3).addEdge(node2);
+ node1.addEdge(node2);
+ node1.addEdge(node3);
+ node2.addEdge(node4);
+ node3.addEdge(node2);
List<Node> sorted = TopologicalSort.sort(nodes);
}
private static LeafSetNode<?> getImmutableLeafSetNode() {
- final ListNodeBuilder<String, LeafSetEntryNode<String>> leafSetBuilder = Builders.<String>leafSetBuilder();
+ final ListNodeBuilder<String, LeafSetEntryNode<String>> leafSetBuilder = Builders.leafSetBuilder();
leafSetBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST);
leafSetBuilder.addChild(LEAF_SET_ENTRY_NODE);
return leafSetBuilder.build();
fail("Verification exception should have been thrown");
} catch (VerificationException e) {
assertVerificationException(e, "Imported module [unknownDep] was not found.");
- return;
}
}
*/
default <E extends DataTreeEffectiveStatement<?>> @NonNull Optional<E> findDataTreeNode(
final @NonNull QName qname) {
- return Optional.ofNullable((E)get(Namespace.class, requireNonNull(qname)));
+ return Optional.ofNullable(get(Namespace.class, requireNonNull(qname)));
}
}
*/
default <E extends SchemaTreeEffectiveStatement<?>> @NonNull Optional<E> findSchemaTreeNode(
final @NonNull QName qname) {
- return Optional.ofNullable((E)get(Namespace.class, requireNonNull(qname)));
+ return Optional.ofNullable(get(Namespace.class, requireNonNull(qname)));
}
}
final SchemaNodeIdentifier identifier) {
final Iterator<QName> iterator = identifier.getPathFromRoot().iterator();
if (!iterator.hasNext()) {
- return Optional.of((Mutable<?, ?, EffectiveStatement<?, ?>>) root);
+ return Optional.of(root);
}
QName nextPath = iterator.next();
* According to RFC6020 a single quote character cannot occur in
* a single-quoted string, even when preceded by a backslash.
*/
- sb.append(str.substring(1, str.length() - 1));
+ sb.append(str, 1, str.length() - 1);
} else {
checkUnquotedString(str, yangVersion, ref);
sb.append(str);
super.onFullDefinitionDeclared(stmt);
final Collection<StmtContext<QName, BaseStatement, ?>> baseStatements =
- StmtContextUtils.<QName, BaseStatement>findAllDeclaredSubstatements(stmt, BaseStatement.class);
+ StmtContextUtils.findAllDeclaredSubstatements(stmt, BaseStatement.class);
for (StmtContext<QName, BaseStatement, ?> baseStmt : baseStatements) {
final QName baseIdentity = baseStmt.getStatementArgument();
final StmtContext<?, ?, ?> stmtCtx = stmt.getFromNamespace(IdentityNamespace.class, baseIdentity);
assertNotNull(context);
final SchemaNode findNode = findNode(context, qN("target"), qN("my-con"));
assertTrue(findNode instanceof ContainerSchemaNode);
- assertEquals(Optional.of("New description"), ((ContainerSchemaNode) findNode).getDescription());
+ assertEquals(Optional.of("New description"), findNode.getDescription());
}
@Test