BUG-731: add curly braces 03/6803/2
authorRobert Varga <rovarga@cisco.com>
Thu, 8 May 2014 06:11:01 +0000 (08:11 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Sat, 10 May 2014 17:55:24 +0000 (17:55 +0000)
Automated addition of curly braces.

Change-Id: I475657dc778601124610d0415cdf05e6a4495cc5
Signed-off-by: Robert Varga <rovarga@cisco.com>
restconf/restconf-util/src/main/java/org/opendaylight/yangtools/restconf/utils/XmlTools.java
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/BindingMapping.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/repo/SourceIdentifier.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java

index 76ed6a9404d1ecf5a6e197ac29ac7031de506c24..05b95be0e37b656a888d3b40cd3c3fa5035a1ef4 100644 (file)
@@ -39,7 +39,7 @@ import org.xml.sax.SAXException;
 
 import com.google.common.base.Preconditions;
 
-public class XmlTools {
+public final class XmlTools {
     private static final String JAXP_SCHEMA_LOCATION =
             "http://java.sun.com/xml/jaxp/properties/schemaSource";
 
index f7c6f728ddf304a28e6b29e7e8b18a3fe35ac215..7abb03b7841935f9f272c5f4cbe8791a50559048 100644 (file)
@@ -41,6 +41,10 @@ public final class BindingMapping {
     public static final String RPC_INPUT_SUFFIX = "Input";
     public static final String RPC_OUTPUT_SUFFIX = "Output";
 
+    private BindingMapping() {
+        throw new UnsupportedOperationException("Utility class should not be instantiated");
+    }
+
     public static final String getMethodName(final QName name) {
         checkArgument(name != null, "Name should not be null.");
         return getMethodName(name.getLocalName());
@@ -105,12 +109,15 @@ public final class BindingMapping {
      *         <code>null</code>.
      */
     private static String toFirstUpper(final String s) {
-        if (s == null || s.length() == 0)
+        if (s == null || s.length() == 0) {
             return s;
-        if (Character.isUpperCase(s.charAt(0)))
+        }
+        if (Character.isUpperCase(s.charAt(0))) {
             return s;
-        if (s.length() == 1)
+        }
+        if (s.length() == 1) {
             return s.toUpperCase();
+        }
         return s.substring(0, 1).toUpperCase() + s.substring(1);
     }
 
@@ -127,12 +134,15 @@ public final class BindingMapping {
      *         <code>null</code>.
      */
     private static String toFirstLower(final String s) {
-        if (s == null || s.length() == 0)
+        if (s == null || s.length() == 0) {
             return s;
-        if (Character.isLowerCase(s.charAt(0)))
+        }
+        if (Character.isLowerCase(s.charAt(0))) {
             return s;
-        if (s.length() == 1)
+        }
+        if (s.length() == 1) {
             return s.toLowerCase();
+        }
         return s.substring(0, 1).toLowerCase() + s.substring(1);
     }
 }
index 2152ba6a4acfed125bf0018e217193b5fb4b1b0f..5e06a57efa9b9a5d0a865c319345853c3dca2ce4 100644 (file)
@@ -14,7 +14,7 @@ public final class SourceIdentifier {
     private final String name;
     private final String revision;
 
-    public SourceIdentifier(String name, Optional<String> formattedRevision) {
+    public SourceIdentifier(final String name, final Optional<String> formattedRevision) {
         super();
         this.name = name;
         this.revision = formattedRevision.orNull();
@@ -30,24 +30,31 @@ public final class SourceIdentifier {
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         SourceIdentifier other = (SourceIdentifier) obj;
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         if (revision == null) {
-            if (other.revision != null)
+            if (other.revision != null) {
                 return false;
-        } else if (!revision.equals(other.revision))
+            }
+        } else if (!revision.equals(other.revision)) {
             return false;
+        }
         return true;
     }
 
@@ -59,20 +66,20 @@ public final class SourceIdentifier {
         return revision;
     }
 
-    public static SourceIdentifier create(String moduleName, Optional<String> revision) {
+    public static SourceIdentifier create(final String moduleName, final Optional<String> revision) {
         return new SourceIdentifier(moduleName, revision);
     }
-    
+
     public String toYangFilename() {
         return toYangFileName(name, Optional.fromNullable(revision));
     }
-    
+
     @Override
     public String toString() {
         return "SourceIdentifier [name=" + name + "@" + revision + "]";
     }
 
-    public static final String toYangFileName(String moduleName, Optional<String> revision) {
+    public static final String toYangFileName(final String moduleName, final Optional<String> revision) {
         StringBuilder filename = new StringBuilder(moduleName);
         if (revision.isPresent()) {
             filename.append("@");
@@ -82,4 +89,4 @@ public final class SourceIdentifier {
         return filename.toString();
     }
 
-}
\ No newline at end of file
+}
index bdd54bc8134f8b3bf15185f4704bdd0ef4cce62b..6530c92510c8d6aabd43eb5640a4ae146b5c71ca 100644 (file)
@@ -39,8 +39,8 @@ public abstract class YangModelDependencyInfo {
     private final ImmutableSet<ModuleImport> moduleImports;
     private final ImmutableSet<ModuleImport> dependencies;
 
-    public YangModelDependencyInfo(String name, String formattedRevision, ImmutableSet<ModuleImport> imports,
-            ImmutableSet<ModuleImport> includes) {
+    public YangModelDependencyInfo(final String name, final String formattedRevision, final ImmutableSet<ModuleImport> imports,
+            final ImmutableSet<ModuleImport> includes) {
         this.name = name;
         this.formattedRevision = formattedRevision;
         this.revision = QName.parseRevision(formattedRevision);
@@ -78,28 +78,35 @@ public abstract class YangModelDependencyInfo {
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
+    public boolean equals(final Object obj) {
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (!(obj instanceof YangModelDependencyInfo))
+        }
+        if (!(obj instanceof YangModelDependencyInfo)) {
             return false;
+        }
         YangModelDependencyInfo other = (YangModelDependencyInfo) obj;
         if (formattedRevision == null) {
-            if (other.formattedRevision != null)
+            if (other.formattedRevision != null) {
                 return false;
-        } else if (!formattedRevision.equals(other.formattedRevision))
+            }
+        } else if (!formattedRevision.equals(other.formattedRevision)) {
             return false;
+        }
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         return true;
     }
 
-    public static YangModelDependencyInfo fromInputStream(InputStream yangStream) {
+    public static YangModelDependencyInfo fromInputStream(final InputStream yangStream) {
         YangContext yangContext = YangParserImpl.parseStreamWithoutErrorListeners(yangStream);
 
         Optional<Module_stmtContext> moduleCtx = getFirstContext(yangContext, Module_stmtContext.class);
@@ -113,7 +120,7 @@ public abstract class YangModelDependencyInfo {
         throw new IllegalArgumentException("Supplied stream is not valid yang file.");
     }
 
-    private static YangModelDependencyInfo fromModuleContext(Module_stmtContext module) {
+    private static YangModelDependencyInfo fromModuleContext(final Module_stmtContext module) {
         String name = getArgumentString(module);
         // String prefix =
         // getArgumentString(module.module_header_stmts().prefix_stmt(0));
@@ -125,7 +132,7 @@ public abstract class YangModelDependencyInfo {
         return new ModuleDependencyInfo(name, latestRevision, namespace, imports, includes);
     }
 
-    private static ImmutableSet<ModuleImport> getImports(List<Import_stmtContext> importStatements) {
+    private static ImmutableSet<ModuleImport> getImports(final List<Import_stmtContext> importStatements) {
         ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
         for (Import_stmtContext importStmt : importStatements) {
             String moduleName = getArgumentString(importStmt);
@@ -135,7 +142,7 @@ public abstract class YangModelDependencyInfo {
         return builder.build();
     }
 
-    private static String getLatestRevision(Revision_stmtsContext revision_stmts) {
+    private static String getLatestRevision(final Revision_stmtsContext revision_stmts) {
         List<Revision_stmtContext> revisions = revision_stmts.getRuleContexts(Revision_stmtContext.class);
         String latestRevision = null;
         for (Revision_stmtContext revisionStmt : revisions) {
@@ -147,7 +154,7 @@ public abstract class YangModelDependencyInfo {
         return latestRevision;
     }
 
-    private static YangModelDependencyInfo fromSubmoduleContext(Submodule_stmtContext submodule) {
+    private static YangModelDependencyInfo fromSubmoduleContext(final Submodule_stmtContext submodule) {
         String name = getArgumentString(submodule);
         Belongs_to_stmtContext belongsToStmt = submodule.submodule_header_stmts().belongs_to_stmt(0);
         String belongsTo = getArgumentString(belongsToStmt);
@@ -159,7 +166,7 @@ public abstract class YangModelDependencyInfo {
         return new SubmoduleDependencyInfo(name, latestRevision, belongsTo, imports, includes);
     }
 
-    private static ImmutableSet<ModuleImport> getIncludes(List<Include_stmtContext> importStatements) {
+    private static ImmutableSet<ModuleImport> getIncludes(final List<Include_stmtContext> importStatements) {
         ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
         for (Include_stmtContext importStmt : importStatements) {
             String moduleName = getArgumentString(importStmt);
@@ -169,7 +176,7 @@ public abstract class YangModelDependencyInfo {
         return builder.build();
     }
 
-    private static Date getRevision(Revision_date_stmtContext revision_date_stmt) {
+    private static Date getRevision(final Revision_date_stmtContext revision_date_stmt) {
         if (revision_date_stmt == null) {
             return null;
         }
@@ -179,8 +186,8 @@ public abstract class YangModelDependencyInfo {
 
     public static final class ModuleDependencyInfo extends YangModelDependencyInfo {
 
-        private ModuleDependencyInfo(String name, String latestRevision, String namespace,
-                ImmutableSet<ModuleImport> imports, ImmutableSet<ModuleImport> includes) {
+        private ModuleDependencyInfo(final String name, final String latestRevision, final String namespace,
+                final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
             super(name, latestRevision, imports, includes);
         }
 
@@ -189,7 +196,6 @@ public abstract class YangModelDependencyInfo {
             return "Module [name=" + getName() + ", revision=" + getRevision()
                     + ", dependencies=" + getDependencies() + "]";
         }
-
     }
 
     public static final class SubmoduleDependencyInfo extends YangModelDependencyInfo {
@@ -200,8 +206,8 @@ public abstract class YangModelDependencyInfo {
             return belongsTo;
         }
 
-        private SubmoduleDependencyInfo(String name, String latestRevision, String belongsTo,
-                ImmutableSet<ModuleImport> imports, ImmutableSet<ModuleImport> includes) {
+        private SubmoduleDependencyInfo(final String name, final String latestRevision, final String belongsTo,
+                final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
             super(name, latestRevision, imports, includes);
             this.belongsTo = belongsTo;
         }
@@ -211,15 +217,14 @@ public abstract class YangModelDependencyInfo {
             return "Submodule [name=" + getName() + ", revision=" + getRevision()
                     + ", dependencies=" + getDependencies() + "]";
         }
-
     }
 
     private static final class ModuleImportImpl implements ModuleImport {
 
-        private Date revision;
-        private String name;
+        private final Date revision;
+        private final String name;
 
-        public ModuleImportImpl(String moduleName, Date revision) {
+        public ModuleImportImpl(final String moduleName, final Date revision) {
             this.name = moduleName;
             this.revision = revision;
         }
@@ -249,24 +254,31 @@ public abstract class YangModelDependencyInfo {
         }
 
         @Override
-        public boolean equals(Object obj) {
-            if (this == obj)
+        public boolean equals(final Object obj) {
+            if (this == obj) {
                 return true;
-            if (obj == null)
+            }
+            if (obj == null) {
                 return false;
-            if (getClass() != obj.getClass())
+            }
+            if (getClass() != obj.getClass()) {
                 return false;
+            }
             ModuleImportImpl other = (ModuleImportImpl) obj;
             if (name == null) {
-                if (other.name != null)
+                if (other.name != null) {
                     return false;
-            } else if (!name.equals(other.name))
+                }
+            } else if (!name.equals(other.name)) {
                 return false;
+            }
             if (revision == null) {
-                if (other.revision != null)
+                if (other.revision != null) {
                     return false;
-            } else if (!revision.equals(other.revision))
+                }
+            } else if (!revision.equals(other.revision)) {
                 return false;
+            }
             return true;
         }
 
@@ -274,7 +286,5 @@ public abstract class YangModelDependencyInfo {
         public String toString() {
             return "ModuleImportImpl [name=" + name + ", revision=" + QName.formattedRevision(revision) + "]";
         }
-
-
     }
 }