Reduce sonar code smells 78/73878/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 10 Jul 2018 11:19:21 +0000 (13:19 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 10 Jul 2018 11:31:04 +0000 (13:31 +0200)
In an effort to get Sonar cleaned up, remove valid code smells
reported by it.

Change-Id: I4fc293fbc29c786699c247648b7c0af68044bded
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java
common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemalessXMLStreamNormalizedNodeStreamWriter.java
yang/yang-data-codec-xml/src/main/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlParserStream.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ParserStreamUtils.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/repo/util/FilesystemSchemaSourceCache.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/FilteringSchemaContextProxy.java
yang/yang-model-validator/src/main/java/org/opendaylight/yangtools/yang/validator/Main.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/openconfig/stmt/OpenConfigVersionEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YinStatementStreamSource.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviation/DeviationEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/must/MustEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleEffectiveStatementImpl.java

index f833e70a6a748f9b1d65d4cd85ccf458e41818fc..6ed34b721b528871e0b13b151c29f6af5958012a 100644 (file)
@@ -8,7 +8,6 @@
 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;
@@ -108,7 +107,7 @@ public class InMemoryDataTreeBenchmark {
 
     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)
index 1625504cf733365eb6e37d2ecc4899990d633832..232a54ded9c8804e42a106d26fe3246025f674c1 100644 (file)
@@ -164,7 +164,7 @@ public final class ClassLoaderUtils {
 
     // 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);
     }
index 12cd33d32d8b505236d7d6f48729c11aee573c45..946018319c9f18457e70f2a169bb9b65f77bbabf 100644 (file)
@@ -44,7 +44,7 @@ final class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNorma
 
     @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);
     }
 
@@ -55,7 +55,7 @@ final class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNorma
 
     @Override
     public void leafSetEntryNode(final QName name, final Object value, final Map<QName, String> attributes)
-        throws IOException {
+            throws IOException {
         writeElement(name, value, attributes, null);
     }
 
@@ -70,8 +70,7 @@ final class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNorma
     }
 
     @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);
     }
 
@@ -104,8 +103,7 @@ final class SchemalessXMLStreamNormalizedNodeStreamWriter extends XMLStreamNorma
 
     @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());
     }
 
index 590fdb84f41ac57ddd68515fefdf47d7b7e61690..79901ffd9aa9edfcf151aacd2f6464f18e12447d 100644 (file)
@@ -5,7 +5,6 @@
  * 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;
@@ -160,6 +159,7 @@ public final class XmlParserStream implements Closeable, Flushable {
      * @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()) {
@@ -208,6 +208,7 @@ public final class XmlParserStream implements Closeable, Flushable {
      *              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));
@@ -262,7 +263,7 @@ public final class XmlParserStream implements Closeable, Flushable {
     }
 
     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;
         }
@@ -417,7 +418,7 @@ public final class XmlParserStream implements Closeable, Flushable {
     }
 
     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;
@@ -428,7 +429,7 @@ public final class XmlParserStream implements Closeable, Flushable {
     }
 
     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
index 66ac4c4eabddc73c85f8b443af920cd2df6918be..ce1efd96d801de121480daadd328003abb74c43a 100644 (file)
@@ -45,12 +45,10 @@ public final class ParserStreamUtils {
                     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;
                     }
                 }
             }
index 0e44a34cae4f70ddbec3669ed12987f59e1e7cf8..ddda07ddddea44c03189382bd9db2e4324351be6 100644 (file)
@@ -100,18 +100,15 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
         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);
index e804c39f5e51d748c662a498666bc885b1b35492..01c38c515e7bce3714b76496e93316389684159b 100644 (file)
@@ -176,24 +176,16 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
 
     //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());
                 }
             }
 
index 51fbe4597e3758917374d405f57410776ae96ae0..5337ff044a07040697972df0fe391e1a421e77f9 100644 (file)
@@ -12,7 +12,6 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
 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;
@@ -99,7 +98,7 @@ public final class Main {
         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);
@@ -138,7 +137,7 @@ public final class Main {
         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();
index 939933f6da022748cb854c5cc4a7e9560d650ac0..12744f7e0f37391c894934cf4322d63e88ff6668 100644 (file)
@@ -42,12 +42,7 @@ final class OpenConfigVersionEffectiveStatementImpl extends
 
     @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
@@ -55,22 +50,11 @@ final class OpenConfigVersionEffectiveStatementImpl extends
         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());
     }
 }
index 84d03bcfc8c0194ebada010e3a2a769cb88f6447..26cc6c4e32bdcd65f78e38db7003f9951d27a424 100644 (file)
@@ -342,15 +342,8 @@ public abstract class YangModelDependencyInfo {
      * 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);
         }
 
@@ -454,32 +447,12 @@ public abstract class YangModelDependencyInfo {
             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
index ac4342c3a8a73c423fbe06a34c627c5c45e3b0c0..eb03a5af20bf617fde0451e89bf17d017e68f3cc 100644 (file)
@@ -188,10 +188,9 @@ public final class YinStatementStreamSource implements StatementStreamSource {
         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;
                 }
             }
         }
@@ -200,12 +199,9 @@ public final class YinStatementStreamSource implements StatementStreamSource {
         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;
             }
         }
 
index 661c46143b07a080825d4e778ad92d5cdadd24f3..cbb6a815cc78cc8c94e9ac21f94190c8b13ceeee 100644 (file)
@@ -133,23 +133,12 @@ final class AugmentEffectiveStatementImpl
         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
index a567c32407e5f48ff301f4685befa48dbd177c15..0ba89b617454f8fa7d19df9f6fc206e16587a3b9 100644 (file)
@@ -148,7 +148,7 @@ abstract class AbstractDeviateStatementSupport extends AbstractStatementSupport<
 
         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);
index c9a4c6422e44f7b7cc5e5b49335aa7df4a91575d..1211aefc6283872dc90dc8bb545674ace2c99f82 100644 (file)
@@ -80,13 +80,7 @@ final class DeviationEffectiveStatementImpl
 
     @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
@@ -94,26 +88,13 @@ final class DeviationEffectiveStatementImpl
         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
index 6a0dcc8187e4170163fe3a60b8d5bd773fee136b..3d5416bd1826e46321aae986ff62e5d75970a57b 100644 (file)
@@ -140,12 +140,7 @@ final class ModuleEffectiveStatementImpl extends AbstractEffectiveModule<ModuleS
 
     @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
@@ -157,15 +152,7 @@ final class ModuleEffectiveStatementImpl extends AbstractEffectiveModule<ModuleS
             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());
     }
 }
index 87a6f5c82292b7da18bbe757d7d8b88bc906d004..d64fbbf2992bebf7f3c692c36bdd382ce610d5fd 100644 (file)
@@ -65,12 +65,7 @@ final class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Re
 
     @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
@@ -78,23 +73,12 @@ final class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Re
         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
index 5c652e02dfcd675fee27c65bc26667b2ead4cd9d..9e5881530987c2d01618582067688052c24ff53f 100644 (file)
@@ -47,12 +47,7 @@ final class SubmoduleEffectiveStatementImpl extends AbstractEffectiveModule<Subm
 
     @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
@@ -60,23 +55,11 @@ final class SubmoduleEffectiveStatementImpl extends AbstractEffectiveModule<Subm
         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());
     }
-
 }