package org.opendaylight.yangtools.yang.data.impl.tree;
import com.google.common.collect.Streams;
-import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
private DataTree datastore;
- public static void main(final String... args) throws IOException, RunnerException {
+ public static void main(final String... args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(".*" + InMemoryDataTreeBenchmark.class.getSimpleName() + ".*")
.forks(1)
// FIXME: 3.0.0: Remove or improve this to be an explicit cast to a receiver <T>?
public static Object construct(final Constructor<?> constructor, final List<Object> objects)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ throws InstantiationException, IllegalAccessException, InvocationTargetException {
final Object[] initargs = objects.toArray();
return constructor.newInstance(initargs);
}
@Override
public void leafNode(final NodeIdentifier name, final Object value, final Map<QName, String> attributes)
- throws IOException {
+ throws IOException {
writeElement(name.getNodeType(), value, attributes, null);
}
@Override
public void leafSetEntryNode(final QName name, final Object value, final Map<QName, String> attributes)
- throws IOException {
+ throws IOException {
writeElement(name, value, attributes, null);
}
}
@Override
- public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint)
- throws IOException, IllegalArgumentException {
+ public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
containerTypeStack.push(ContainerType.LEAF_SET);
}
@Override
protected void writeValue(final XMLStreamWriter xmlWriter, final QName qname, @Nonnull final Object value,
- final Object context)
- throws XMLStreamException {
+ final Object context) throws XMLStreamException {
xmlWriter.writeCharacters(value.toString());
}
* 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.data.codec.xml;
import static com.google.common.base.Preconditions.checkArgument;
* @throws SAXException
* if an error occurs while parsing the value of an anyxml node
*/
+ // FIXME: 3.0.0 remove ParserConfigurationException
public XmlParserStream parse(final XMLStreamReader reader) throws XMLStreamException, URISyntaxException,
IOException, ParserConfigurationException, SAXException {
if (reader.hasNext()) {
* if an error occurs while parsing the value of an anyxml node
*/
@Beta
+ // FIXME: 3.0.0 remove ParserConfigurationException
public XmlParserStream traverse(final DOMSource src) throws XMLStreamException, URISyntaxException,
IOException, ParserConfigurationException, SAXException {
return parse(new DOMSourceXMLStreamReader(src));
}
private void read(final XMLStreamReader in, final AbstractNodeDataWithSchema parent, final String rootElement)
- throws XMLStreamException, URISyntaxException, ParserConfigurationException, SAXException, IOException {
+ throws XMLStreamException, URISyntaxException, SAXException, IOException {
if (!in.hasNext()) {
return;
}
}
private void setValue(final AbstractNodeDataWithSchema parent, final String value, final NamespaceContext nsContext)
- throws ParserConfigurationException, SAXException, IOException {
+ throws SAXException, IOException {
checkArgument(parent instanceof SimpleNodeDataWithSchema, "Node %s is not a simple type",
parent.getSchema().getQName());
final SimpleNodeDataWithSchema parentSimpleNode = (SimpleNodeDataWithSchema) parent;
}
private Object translateValueByType(final String value, final DataSchemaNode node,
- final NamespaceContext namespaceCtx) throws IOException, SAXException, ParserConfigurationException {
+ final NamespaceContext namespaceCtx) throws IOException, SAXException {
if (node instanceof AnyXmlSchemaNode) {
/*
* FIXME: Figure out some YANG extension dispatch, which will
childChoices.add((ChoiceSchemaNode) childNode);
} else {
final QName childQName = childNode.getQName();
-
- if (childQName.getLocalName().equals(childName) && childQName.getNamespace().equals(namespace)) {
- if (potentialChildNode == null || Revision.compare(childQName.getRevision(),
- potentialChildNode.getQName().getRevision()) > 0) {
- potentialChildNode = childNode;
- }
+ if (childQName.getLocalName().equals(childName) && childQName.getNamespace().equals(namespace)
+ && (potentialChildNode == null || Revision.compare(childQName.getRevision(),
+ potentialChildNode.getQName().getRevision()) > 0)) {
+ potentialChildNode = childNode;
}
}
}
try {
Files.walkFileTree(storageDirectory.toPath(), fileVisitor);
} catch (final IOException e) {
- LOG.warn("Unable to restore cache from {}. Starting with empty cache", storageDirectory);
+ LOG.warn("Unable to restore cache from {}. Starting with an empty cache", storageDirectory, e);
return;
}
- for (final SourceIdentifier cachedSchema : fileVisitor.getCachedSchemas()) {
- register(cachedSchema);
- }
+ fileVisitor.getCachedSchemas().stream().forEach(this::register);
}
@Override
- public synchronized FluentFuture<? extends T> getSource(
- final SourceIdentifier sourceIdentifier) {
+ public synchronized FluentFuture<? extends T> getSource(final SourceIdentifier sourceIdentifier) {
final File file = sourceIdToFile(sourceIdentifier, storageDirectory);
if (file.exists() && file.canRead()) {
LOG.trace("Source {} found in cache as {}", sourceIdentifier, file);
//check for any dependency regarding given string
private boolean checkModuleDependency(final Module module, final Collection<ModuleId> rootModules) {
-
for (ModuleId rootModule : rootModules) {
-
if (rootModule.equals(new ModuleId(module.getName(), module.getRevision()))) {
return true;
}
//handling/checking imports regarding root modules
for (ModuleImport moduleImport : module.getImports()) {
-
if (moduleImport.getModuleName().equals(rootModule.getName())) {
-
- if (moduleImport.getRevision().isPresent()
- && !moduleImport.getRevision().equals(rootModule.getRev())) {
- return false;
- }
-
- return true;
+ return !moduleImport.getRevision().isPresent()
+ || moduleImport.getRevision().equals(rootModule.getRev());
}
}
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.FileAppender;
import com.google.common.base.Stopwatch;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
return options;
}
- public static void main(final String[] args) throws IOException {
+ public static void main(final String[] args) {
final HelpFormatter formatter = new HelpFormatter();
final Options options = createOptions();
final CommandLine arguments = parseArguments(args, options, formatter);
LOG_ROOT.getLoggerContext().reset();
}
- private static void setOutput(final String... paths) throws IOException {
+ private static void setOutput(final String... paths) {
LOG_ROOT.getLoggerContext().reset();
final PatternLayoutEncoder encoder = new PatternLayoutEncoder();
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Objects.hashCode(path);
- result = prime * result + Objects.hashCode(getNodeType());
- result = prime * result + Objects.hashCode(getNodeParameter());
- return result;
+ return Objects.hash(path, getNodeType(), getNodeParameter());
}
@Override
if (this == obj) {
return true;
}
- if (obj == null) {
+ if (!(obj instanceof OpenConfigVersionEffectiveStatementImpl)) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- OpenConfigVersionEffectiveStatementImpl other = (OpenConfigVersionEffectiveStatementImpl) obj;
- if (!Objects.equals(path, other.path)) {
- return false;
- }
- if (!Objects.equals(getNodeType(), other.getNodeType())) {
- return false;
- }
- if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
- return false;
- }
- return true;
+ final OpenConfigVersionEffectiveStatementImpl other = (OpenConfigVersionEffectiveStatementImpl) obj;
+ return Objects.equals(path, other.path) && Objects.equals(getNodeType(), other.getNodeType())
+ && Objects.equals(getNodeParameter(), other.getNodeParameter());
}
}
* Dependency information for YANG module.
*/
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);
- }
-
- private ModuleDependencyInfo(final String name, final String latestRevision,
- final ImmutableSet<ModuleImport> imports,
- final ImmutableSet<ModuleImport> includes,
- final Optional<SemVer> semVer) {
+ ModuleDependencyInfo(final String name, final String latestRevision, final ImmutableSet<ModuleImport> imports,
+ final ImmutableSet<ModuleImport> includes, final Optional<SemVer> semVer) {
super(name, latestRevision, imports, includes, semVer);
}
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof ModuleImportImpl)) {
return false;
}
final ModuleImportImpl other = (ModuleImportImpl) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (revision == null) {
- if (other.revision != null) {
- return false;
- }
- } else if (!revision.equals(other.revision)) {
- return false;
- }
-
- if (!Objects.equals(getSemanticVersion(), other.getSemanticVersion())) {
- return false;
- }
- return true;
+ return name.equals(other.name) && Objects.equals(revision, other.revision)
+ && Objects.equals(getSemanticVersion(), other.getSemanticVersion());
}
@Override
if (attributes != null) {
for (int i = 0, len = attributes.getLength(); i < len; ++i) {
final Attr attr = (Attr) attributes.item(i);
- if (allAttrs || !isArgument(argName, attr)) {
- if (!processAttribute(childCounter++, attr, writer, stmtDef, ref)) {
- fullyDefined = false;
- }
+ if ((allAttrs || !isArgument(argName, attr))
+ && !processAttribute(childCounter++, attr, writer, stmtDef, ref)) {
+ fullyDefined = false;
}
}
}
final NodeList children = element.getChildNodes();
for (int i = 0, len = children.getLength(); i < len; ++i) {
final Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- if (allElements || !isArgument(argName, child)) {
- if (!processElement(childCounter++, (Element) child, writer, stmtDef)) {
- fullyDefined = false;
- }
- }
+ if (child.getNodeType() == Node.ELEMENT_NODE && (allElements || !isArgument(argName, child))
+ && !processElement(childCounter++, (Element) child, writer, stmtDef)) {
+ fullyDefined = false;
}
}
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof AugmentEffectiveStatementImpl)) {
return false;
}
final AugmentEffectiveStatementImpl other = (AugmentEffectiveStatementImpl) obj;
- if (!Objects.equals(targetPath, other.targetPath)) {
- return false;
- }
- if (!Objects.equals(whenCondition, other.whenCondition)) {
- return false;
- }
- if (!getChildNodes().equals(other.getChildNodes())) {
- return false;
- }
- return true;
+ return Objects.equals(targetPath, other.targetPath) && Objects.equals(whenCondition, other.whenCondition)
+ && getChildNodes().equals(other.getChildNodes());
}
@Override
deviateAction.apply(new InferenceAction() {
@Override
- public void apply(final InferenceContext ctx) throws InferenceException {
+ public void apply(final InferenceContext ctx) {
// FIXME once BUG-7760 gets fixed, there will be no need for these dirty casts
final StatementContextBase<?, ?, ?> sourceNodeStmtCtx =
(StatementContextBase<?, ?, ?>) sourceCtxPrerequisite.resolve(ctx);
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Objects.hashCode(targetPath);
- result = prime * result + Objects.hashCode(deviateDefinitions);
- result = prime * result + Objects.hashCode(description);
- result = prime * result + Objects.hashCode(reference);
- return result;
+ return Objects.hash(targetPath, deviateDefinitions, description, reference);
}
@Override
if (this == obj) {
return true;
}
- if (obj == null) {
+ if (!(obj instanceof DeviationEffectiveStatementImpl)) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- DeviationEffectiveStatementImpl other = (DeviationEffectiveStatementImpl) obj;
- if (!Objects.equals(targetPath, other.targetPath)) {
- return false;
- }
- if (!Objects.equals(deviateDefinitions, other.deviateDefinitions)) {
- return false;
- }
- if (!Objects.equals(description, other.description)) {
- return false;
- }
- if (!Objects.equals(reference, other.reference)) {
- return false;
- }
- return true;
+ final DeviationEffectiveStatementImpl other = (DeviationEffectiveStatementImpl) obj;
+ return Objects.equals(targetPath, other.targetPath)
+ && Objects.equals(deviateDefinitions, other.deviateDefinitions)
+ && Objects.equals(description, other.description) && Objects.equals(reference, other.reference);
}
@Override
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Objects.hashCode(getName());
- result = prime * result + Objects.hashCode(getYangVersion());
- result = prime * result + Objects.hashCode(qnameModule);
- return result;
+ return Objects.hash(getName(), getYangVersion(), qnameModule);
}
@Override
return false;
}
ModuleEffectiveStatementImpl other = (ModuleEffectiveStatementImpl) obj;
- if (!Objects.equals(getName(), other.getName())) {
- return false;
- }
- if (!qnameModule.equals(other.qnameModule)) {
- return false;
- }
- if (!Objects.equals(getYangVersion(), other.getYangVersion())) {
- return false;
- }
- return true;
+ return Objects.equals(getName(), other.getName()) && qnameModule.equals(other.qnameModule)
+ && Objects.equals(getYangVersion(), other.getYangVersion());
}
}
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Objects.hashCode(xpath);
- result = prime * result + Objects.hashCode(description);
- result = prime * result + Objects.hashCode(reference);
- return result;
+ return Objects.hash(xpath, description, reference);
}
@Override
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
+ if (!(obj instanceof MustEffectiveStatementImpl)) {
return false;
}
final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj;
- if (!Objects.equals(xpath, other.xpath)) {
- return false;
- }
- if (!Objects.equals(description, other.description)) {
- return false;
- }
- if (!Objects.equals(reference, other.reference)) {
- return false;
- }
- return true;
+ return Objects.equals(xpath, other.xpath) && Objects.equals(description, other.description)
+ && Objects.equals(reference, other.reference);
}
@Override
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Objects.hashCode(getName());
- result = prime * result + Objects.hashCode(getYangVersion());
- result = prime * result + Objects.hashCode(qnameModule);
- return result;
+ return Objects.hash(getName(), getYangVersion(), qnameModule);
}
@Override
if (this == obj) {
return true;
}
- if (obj == null) {
+ if (!(obj instanceof SubmoduleEffectiveStatementImpl)) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- SubmoduleEffectiveStatementImpl other = (SubmoduleEffectiveStatementImpl) obj;
- if (!Objects.equals(getName(), other.getName())) {
- return false;
- }
- if (!qnameModule.equals(other.qnameModule)) {
- return false;
- }
- if (!Objects.equals(getYangVersion(), other.getYangVersion())) {
- return false;
- }
- return true;
+ final SubmoduleEffectiveStatementImpl other = (SubmoduleEffectiveStatementImpl) obj;
+ return Objects.equals(getName(), other.getName()) && qnameModule.equals(other.qnameModule)
+ && Objects.equals(getYangVersion(), other.getYangVersion());
}
-
}