[Title] Added some fixes by sonar
authorBon-Yong Lee <bonyong.lee@samsung.com>
Fri, 30 Nov 2012 01:29:43 +0000 (10:29 +0900)
committerBon-Yong Lee <bonyong.lee@samsung.com>
Fri, 30 Nov 2012 01:29:43 +0000 (10:29 +0900)
[Desc.] change null-check statement to Assert
[Issue]

18 files changed:
org.tizen.common.verrari/src/org/tizen/common/verrari/template/ClasspathResourceTemplate.java
org.tizen.common.verrari/src/org/tizen/common/verrari/template/TemplateProvider.java
org.tizen.common.verrari/src/org/tizen/common/verrari/template/TemplateProviderDelegate.java
org.tizen.common.verrari/src/org/tizen/common/verrari/template/URLTemplate.java
org.tizen.common/src/org/tizen/common/classloader/JarClassSource.java
org.tizen.common/src/org/tizen/common/config/loader/AbstractLoader.java
org.tizen.common/src/org/tizen/common/core/application/StatusLineMessageManager.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/core/command/file/FileHandlingCommand.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/core/command/prompter/AbstractPrompter.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/file/PatternFilter.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/ui/view/console/ConsoleManager2.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/util/ArrayUtil.java
org.tizen.common/src/org/tizen/common/util/CollectionUtil.java
org.tizen.common/src/org/tizen/common/util/FileUtil.java
org.tizen.common/src/org/tizen/common/util/FilenameUtil.java
org.tizen.common/src/org/tizen/common/util/MapUtil.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/util/io/BufferInputStream.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/util/io/BufferOutputStream.java

index ae8a27a..8ab5ac4 100755 (executable)
@@ -30,6 +30,7 @@ package org.tizen.common.verrari.template;
 import java.io.IOException;\r
 import java.io.InputStream;\r
 \r
+import org.tizen.common.util.Assert;\r
 import org.tizen.common.verrari.ITemplate;\r
 \r
 /**\r
@@ -83,14 +84,8 @@ implements ITemplate
         final ClassLoader loader\r
     )\r
     {\r
-        if ( null == path )\r
-        {\r
-            throw new IllegalArgumentException();\r
-        }\r
-        if ( null == loader )\r
-        {\r
-            throw new IllegalArgumentException();\r
-        }\r
+        Assert.notNull( path );\r
+        Assert.notNull( loader );\r
         this.path = path;\r
         this.loader = loader;\r
     }\r
index 4072eb3..ace9a2d 100755 (executable)
@@ -36,6 +36,7 @@ import java.util.Collections;
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
+import org.tizen.common.util.Assert;\r
 import org.tizen.common.verrari.ITemplate;\r
 import org.tizen.common.verrari.ITemplateProvider;\r
 \r
@@ -75,10 +76,7 @@ implements ITemplateProvider, Closeable
         final Map<String, ITemplate> templates\r
     )\r
     {\r
-        if ( null == templates )\r
-        {\r
-            throw new IllegalArgumentException();\r
-        }\r
+        Assert.notNull( templates );\r
         this.templates = templates;\r
     }\r
 \r
index a0cd912..9d7c48d 100755 (executable)
@@ -31,6 +31,7 @@ import java.util.Collection;
 \r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
+import org.tizen.common.util.Assert;\r
 import org.tizen.common.verrari.ITemplate;\r
 import org.tizen.common.verrari.ITemplateProvider;\r
 \r
@@ -65,10 +66,7 @@ implements ITemplateProvider
         final ITemplateProvider provider\r
     )\r
     {\r
-        if ( null == provider )\r
-        {\r
-            throw new IllegalArgumentException();\r
-        }\r
+        Assert.notNull( provider );\r
         this.provider = provider;\r
     }\r
 \r
index 6073540..5f1c5a0 100755 (executable)
@@ -32,6 +32,7 @@ import java.io.InputStream;
 import java.net.MalformedURLException;\r
 import java.net.URL;\r
 \r
+import org.tizen.common.util.Assert;\r
 import org.tizen.common.verrari.ITemplate;\r
 \r
 /**\r
@@ -97,10 +98,7 @@ implements ITemplate
     )\r
     {\r
         super( encoding );\r
-        if ( null == url )\r
-        {\r
-            throw new IllegalArgumentException();\r
-        }\r
+        Assert.notNull( url );\r
         this.url = url;\r
     }\r
     \r
index 578600a..8135ffd 100755 (executable)
@@ -28,6 +28,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 
+import org.tizen.common.util.Assert;
+
 /**
  * <p>
  * JarClassSource.
@@ -59,10 +61,7 @@ implements ClassSource
        )
        {
            logger.info( "URL :{}", url );
-               if ( null == url )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( url );
                this.url = url;
        }
 
index c25f65c..fbfbc71 100755 (executable)
@@ -25,6 +25,7 @@
 package org.tizen.common.config.loader;\r
 \r
 import org.tizen.common.config.Loader;\r
+import org.tizen.common.util.Assert;\r
 \r
 /**\r
  * AbstractLoader.\r
@@ -53,10 +54,7 @@ implements Loader
     )\r
     {\r
         this.src = src;\r
-        if ( null == src ) \r
-        {\r
-            throw new IllegalArgumentException();\r
-        }\r
+        Assert.notNull( src );\r
     }\r
     \r
     /**\r
old mode 100644 (file)
new mode 100755 (executable)
index 46f8f17..95f54d8
@@ -26,6 +26,7 @@ package org.tizen.common.core.application;
 
 import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.ui.IViewPart;
+import org.tizen.common.util.Assert;
 
 public class StatusLineMessageManager
 {
@@ -51,10 +52,7 @@ public class StatusLineMessageManager
                final IStatusLineManager manager
        )
        {
-               if ( null == manager )
-               {       // Fast Fail
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( manager );
                this.manager = manager;
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index 7cc72a4..517aa23
@@ -32,6 +32,7 @@ import org.tizen.common.core.command.Executor;
 import org.tizen.common.file.Filter;
 import org.tizen.common.file.SimpleFileFilter;
 import org.tizen.common.file.filter.WildCardFilterFactory;
+import org.tizen.common.util.Assert;
 
 /**
  * FileHandlingCommand.
@@ -84,10 +85,7 @@ extends AbstractCommand<T>
        void
        setFilter( SimpleFileFilter filter )
        {
-               if ( null == filter )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( filter );
                this.filter = filter;
                logger.debug( "Configured filter :{}", filter );
        }
old mode 100644 (file)
new mode 100755 (executable)
index ed82fff..cbbb499
@@ -31,6 +31,7 @@ import java.util.LinkedHashSet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.core.command.Prompter;
+import org.tizen.common.util.Assert;
 
 /**
  * AbstractPrompter.
@@ -50,12 +51,11 @@ AbstractPrompter
 
        protected
        void
-       checkOptions( ChoiceOption[] options )
+       checkOptions(
+           final ChoiceOption[] options
+       )
        {
-               if ( null == options )
-               {
-                       throw new IllegalArgumentException(); 
-               }
+           Assert.notNull( options );
                
                final HashSet<Option> reducedOptions = new LinkedHashSet<Option>();
                Option defaultOption = null;
old mode 100644 (file)
new mode 100755 (executable)
index ea3d5e6..4995915
@@ -24,6 +24,8 @@
  */
 package org.tizen.common.file;
 
+import org.tizen.common.util.Assert;
+
 /**
  * <p>
  * PatternFilter.
@@ -67,10 +69,7 @@ PatternFilter
                final String pattern
        )
        {
-               if ( null == pattern )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( pattern );
                this.pattern = pattern;
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index e6fc169..e3289a1
@@ -41,6 +41,7 @@ import org.eclipse.ui.console.IConsoleConstants;
 import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.IConsoleView;
 import org.eclipse.ui.console.MessageConsoleStream;
+import org.tizen.common.util.Assert;
 
 /**
  * ConsoleManager2.
@@ -138,10 +139,7 @@ implements IConsolePrinter, IHyperlinkManager
                final String newName
        )
        {
-               if ( null == newName )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( newName );
                this.consoleName = newName;
                asyncExec( new Runnable()
                {
index 394c858..c259b33 100755 (executable)
@@ -838,10 +838,7 @@ public class ArrayUtil
                final int end
        )
        {
-               if ( null == array )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( array );
                Assert.isTrue(
                        start <= end,
                        "start indnex(" + start + ") is greater than end index(" + end + ")"
index 5ab4ca3..fde2ed3 100755 (executable)
@@ -523,11 +523,7 @@ public class CollectionUtil
                        final Enumeration<K> enumeration
                )
                {
-                       if ( null == enumeration )
-                       {       // Fast fail
-                               throw new IllegalArgumentException();
-                       }
-                       
+                   Assert.notNull( enumeration );
                        this.enumeration = enumeration;
                }
 
@@ -616,11 +612,7 @@ public class CollectionUtil
                final Collection<Object> collection
        )
        {
-               if ( null == collection )
-               {
-                       throw new IllegalArgumentException();
-               }
-
+           Assert.notNull( collection );
                final Object[] arr = ArrayUtil.toObjectArray( array );
                for ( int i=0, n=arr.length ; i<n ; ++i )
                {
index c61269b..250a72c 100755 (executable)
@@ -79,10 +79,7 @@ public class FileUtil {
      * @return If directory couldn't be created, return false. Otherwise, return true.
      */
     public static boolean createDirectory(String dirName, String destDir) {
-        if (dirName == null)
-        {
-            throw new IllegalArgumentException();
-        }
+        Assert.notNull( dirName );
 
         if (destDir == null)
         {
@@ -142,10 +139,7 @@ public class FileUtil {
      * @throws IOException If creating file's directory does not exist, it throws IOException
      */
     public static boolean createTextFile(String fileName, String text, String destDir, String encoding) throws IOException {
-        if (fileName == null)
-        {
-            throw new IllegalArgumentException();
-        }
+        Assert.notNull( fileName );
 
         if (destDir == null)
         {
@@ -576,20 +570,12 @@ public class FileUtil {
      */
     private static void validateDirectory(File aDirectory)
             throws FileNotFoundException {
-        if (aDirectory == null) {
-            throw new IllegalArgumentException("Directory should not be null.");
-        }
+        Assert.notNull( aDirectory, "Directory should not be null." );
         if (!aDirectory.exists()) {
             throw new FileNotFoundException("Directory does not exist: "
                     + aDirectory);
         }
-        if (!aDirectory.isDirectory()) {
-            throw new IllegalArgumentException("Is not a directory: "
-                    + aDirectory);
-        }
-        if (!aDirectory.canRead()) {
-            throw new IllegalArgumentException("Directory cannot be read: "
-                    + aDirectory);
-        }
+        Assert.isTrue( aDirectory.isDirectory(), "Is not a directory: " + aDirectory );
+        Assert.isTrue( aDirectory.canRead(), "Directory cannot be read: " + aDirectory );
     }
 }
index c878e76..fd766c6 100755 (executable)
@@ -430,10 +430,7 @@ public class FilenameUtil
         */
        public static String getName( final String nameWithExt )
        {
-               if ( null == nameWithExt )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( nameWithExt );
                
                final int index = nameWithExt.lastIndexOf( '.' );
                
@@ -454,10 +451,7 @@ public class FilenameUtil
         */
        public static String getExtension( final String nameWithExt )
        {
-               if ( null == nameWithExt )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( nameWithExt );
                
                final int index = nameWithExt.lastIndexOf( '.' );
                
@@ -487,7 +481,7 @@ public class FilenameUtil
                        );
                } catch ( final IOException e )
                {
-                       throw new IllegalArgumentException();
+                       throw new IllegalArgumentException( e );
                }
        }
        
old mode 100644 (file)
new mode 100755 (executable)
index 72934e7..663b4dd
@@ -162,10 +162,7 @@ public class MapUtil
                final Map<Object, Object> map
        )
        {
-               if ( null == map )
-               {
-                       throw new IllegalArgumentException();
-               }
+           Assert.notNull( map );
                if ( null == props )
                {
                        return ;
old mode 100644 (file)
new mode 100755 (executable)
index 2a0b33c..3b2e315
@@ -28,6 +28,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 
+import org.tizen.common.util.Assert;
+
 /**
  * <p>
  * BufferInputStream.
@@ -58,11 +60,7 @@ extends InputStream
                final Buffer buffer
        )
        {
-               if ( null == buffer )
-               {
-                       throw new IllegalArgumentException();
-               }
-
+           Assert.notNull( buffer );
                this.buffer = buffer;
        }
 
index 0e9c615..cf3c571 100755 (executable)
@@ -27,6 +27,8 @@ package org.tizen.common.util.io;
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.tizen.common.util.Assert;
+
 /**
  * <p>
  * BufferOutputStream.
@@ -57,10 +59,7 @@ extends OutputStream
                final Buffer buffer
        )
        {
-               if ( null == buffer )
-               {
-                       throw new IllegalArgumentException();
-               }
+        Assert.notNull( buffer );
                this.buffer = buffer;
        }