]> git.mxchange.org Git - jcore.git/commitdiff
Better compare this way:
authorRoland Haeder <roland@mxchange.org>
Thu, 27 Aug 2015 06:51:19 +0000 (08:51 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 27 Aug 2015 06:51:19 +0000 (08:51 +0200)
if (null == foo)

Otherwise could lead to a bug if you miss only one equal sign
Signed-off-by:Roland Häder <roland@mxchange.org>

16 files changed:
src/org/mxchange/jcore/BaseFrameworkSystem.java
src/org/mxchange/jcore/contact/BaseContact.java
src/org/mxchange/jcore/contact/Gender.java
src/org/mxchange/jcore/criteria/logical/Logical.java
src/org/mxchange/jcore/criteria/logical/and/AndLogicalMatcher.java
src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java
src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java
src/org/mxchange/jcore/database/backend/DatabaseBackend.java
src/org/mxchange/jcore/database/backend/base64/Base64CsvDatabaseBackend.java
src/org/mxchange/jcore/database/backend/datasource/DataSourceDatabaseBackend.java
src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java
src/org/mxchange/jcore/database/frontend/BaseDatabaseFrontend.java
src/org/mxchange/jcore/factory/database/backend/BackendFactory.java
src/org/mxchange/jcore/manager/application/ApplicationManager.java
src/org/mxchange/jcore/model/BaseModel.java
src/org/mxchange/jcore/model/swing/contact/ContactTableModel.java

index 3bb76beab8424eec61d837a7019143b856376a43..cee4a1aa697ae1cf364b98cf405e86df7edb1463 100644 (file)
@@ -779,7 +779,7 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                this.getLogger().trace(MessageFormat.format("str={0}", str)); //NOI18N
 
                // Is it null?
-               if (str == null) {
+               if (null == str) {
                        // Return empty string
                        return ""; //NOI18N
                }
@@ -1014,10 +1014,10 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value)); //NOI18N
 
                // Both should not be null
-               if (key == null) {
+               if (null == key) {
                        // key is null
                        throw new NullPointerException("key is null"); //NOI18N
-               } else if (value == null) {
+               } else if (null == value) {
                        // value is null
                        throw new NullPointerException("value is null"); //NOI18N
                }
@@ -1187,7 +1187,7 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                this.getLogger().debug(MessageFormat.format("type={0}", type));
 
                // type should not be null
-               if (type == null) {
+               if (null == type) {
                        // No null allowed
                        throw new NullPointerException("type is null"); //NOI18N
                }
index 9bf742624a6466c5b3b2ba4dfe7af58b77e1961d..a6238a9f067c52b596f75ceefecd75e9eb388845 100644 (file)
@@ -594,7 +594,7 @@ public class BaseContact extends BaseFrameworkSystem implements Contact {
                this.getLogger().trace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
 
                // The client must be set
-               if (client == null) {
+               if (null == client) {
                        // Not set
                        throw new NullPointerException("client is null"); //NOI18N
                }
index b257fd9827a4664b59feba28ae0b83fce82b1399..3ba9ef5ea3dba5a9f6febd03636a16ab3fe3235c 100644 (file)
@@ -81,7 +81,7 @@ public enum Gender {
                }
 
                // Still null?
-               if (g == null) {
+               if (null == g) {
                        // Didn't found a valid one
                        throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c));
                }
index 2f26db4265cc2ed01b0a9173c834adabfdaf4519..0de068a20095e9bcec3973af274822d8030b002f 100644 (file)
@@ -31,8 +31,8 @@ public interface Logical extends FrameworkInterface {
         * Checks logical match condition
         * 
         * @param entrySet Entry set where the values are
-        * @param criteraMatches Criteria matches
+        * @param criteriaMatches Criteria matches
         * @return Whether it matches
         */
-       public boolean matches (final Set<Map.Entry<String, Object>> entrySet, final Map<String, Boolean> criteraMatches);
+       public boolean matches (final Set<Map.Entry<String, Object>> entrySet, final Map<String, Boolean> criteriaMatches);
 }
index 6dfb4f3a306da20b59e10ddfbe0efc653a065d96..91430ef953ad67b15551f0b4e94fdd78fa024959 100644 (file)
@@ -35,9 +35,9 @@ public class AndLogicalMatcher extends BaseFrameworkSystem implements Logical {
        }
 
        @Override
-       public boolean matches (final Set<Map.Entry<String, Object>> entrySet, final Map<String, Boolean> criteraMatches) {
+       public boolean matches (final Set<Map.Entry<String, Object>> entrySet, final Map<String, Boolean> criteriaMatches) {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("entrySet={0},criteriaMatches={1} - CALLED!", entrySet, criteraMatches)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("entrySet={0},criteriaMatches={1} - CALLED!", entrySet, criteriaMatches)); //NOI18N
 
                // Default is matching, then check if something is not matching and set result to false
                boolean matches = true;
@@ -48,18 +48,18 @@ public class AndLogicalMatcher extends BaseFrameworkSystem implements Logical {
                        this.getLogger().debug(MessageFormat.format("entry.key={0},entry.value={1}", entry.getKey(), entry.getValue())); //NOI18N
 
                        // Check all matches
-                       for (Map.Entry<String, Boolean> criteriaMatch : criteraMatches.entrySet()) {
+                       for (Map.Entry<String, Boolean> criteriaMatch : criteriaMatches.entrySet()) {
                                // Get key and value
                                String criteriaKey = criteriaMatch.getKey();
-                               Boolean criteriaMatches = criteriaMatch.getValue();
+                               Boolean criteriaMatching = criteriaMatch.getValue();
 
                                // Debug message
-                               this.getLogger().debug(MessageFormat.format("criteriaKey={0},criteriaMatches={1}", criteriaKey, criteriaMatches)); //NOI18N
+                               this.getLogger().debug(MessageFormat.format("criteriaKey={0},criteriaMatching={1}", criteriaKey, criteriaMatching)); //NOI18N
 
                                // Is both the same and false?
-                               if ((entry.getKey().equals(criteriaKey)) && (!criteriaMatches)) {
+                               if ((entry.getKey().equals(criteriaKey)) && (!criteriaMatching)) {
                                        // Debug message
-                                       this.getLogger().debug("Not matching, aborting search.");
+                                       this.getLogger().debug("Not matching, aborting search."); //NOI18N
 
                                        // Doesn't match
                                        matches = false;
index ae25c6b8ad74ab3803b1c6ce3bc7c2afc041b67b..b276026183ac80531c60a03d2213b7d4949e1fe0 100644 (file)
@@ -71,7 +71,7 @@ public class SearchCriteria extends BaseCriteria implements SearchableCriteria {
                this.getLogger().trace(MessageFormat.format("storeable={0} - CALLED!", storeable)); //NOI18N
 
                // Must not be null
-               if (storeable == null) {
+               if (null == storeable) {
                        // Abort here
                        throw new NullPointerException("storeable is null"); //NOI18N
                }
@@ -89,7 +89,7 @@ public class SearchCriteria extends BaseCriteria implements SearchableCriteria {
                }
 
                // Init matches array
-               Map<String, Boolean> criteraMatches = new HashMap<>(this.entrySet().size());
+               Map<String, Boolean> criteriaMatches = new HashMap<>(this.entrySet().size());
 
                // Check all conditions
                for (final Map.Entry<String, Object> criteria : this.entrySet()) {
@@ -108,26 +108,26 @@ public class SearchCriteria extends BaseCriteria implements SearchableCriteria {
                                this.getLogger().debug(MessageFormat.format("value={0} - MATCHES!", value)); //NOI18N
 
                                // Matching criteria found
-                               criteraMatches.put(criteria.getKey(), true);
+                               criteriaMatches.put(criteria.getKey(), true);
                        }
                }
 
                // Init matches
-               boolean matches;
+               boolean matches = false;
 
                // Is only one entry given?
                if (this.entrySet().size() == 1) {
                        // Okay, one criteria only, no need for a "complex" logical match check
-                       matches = (criteraMatches.size() == 1);
+                       matches = (criteriaMatches.size() == 1);
                } else if (this.getLogical() == null) {
                        // Logical instance is null
-                       throw new NullPointerException(MessageFormat.format("logical is not set, but more than one column ({0}/{1}) shall be matched.", this.entrySet().size(), criteraMatches.size())); //NOI18N
-               } else {
+                       throw new NullPointerException(MessageFormat.format("logical is not set, but more than one column ({0}/{1}) shall be matched.", this.entrySet().size(), criteriaMatches.size())); //NOI18N
+               } else if (this.entrySet().size() == criteriaMatches.size()) {
                        // Debug message
-                       this.getLogger().debug(MessageFormat.format("entrySet.size()={0},criteriaMatches.size()={1} - Calling matches() on {2} ...", this.entrySet().size(), criteraMatches.size(), this.getLogical()));
+                       this.getLogger().debug(MessageFormat.format("entrySet.size()={0},criteriaMatches.size()={1} - Calling matches() on {2} ...", this.entrySet().size(), criteriaMatches.size(), this.getLogical()));
 
                        // Now for the final test
-                       matches = this.getLogical().matches(this.entrySet(), criteraMatches);
+                       matches = this.getLogical().matches(this.entrySet(), criteriaMatches);
                }
 
                // Trace message
index d63fafc5ab4af894217ab3432db6377f309a2d4a..73df2bfad97f9465cb181000e9e29c523f1d1e85 100644 (file)
@@ -47,7 +47,7 @@ public class BaseDatabaseBackend extends BaseFrameworkSystem {
                this.getLogger().trace(MessageFormat.format("driverName={0} - CALLED!", driverName)); //NOI18N
 
                // driverName shall not be null
-               if (driverName == null) {
+               if (null == driverName) {
                        // Is null
                        throw new NullPointerException("driverName is null");
                }
index a787304317422d9453fccfb8bb84c22f9decd783..ef014e7287c10adb823fda3642595c1f14d4f681 100644 (file)
@@ -61,7 +61,7 @@ public interface DatabaseBackend extends FrameworkInterface {
         *
         * The callee should not modify any content of the criteria instance.
         *
-        * @param critera Search critera
+        * @param criteria Search criteria
         * @return A result instance
         * @throws java.io.IOException If any IO error occurs
         * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
@@ -71,7 +71,7 @@ public interface DatabaseBackend extends FrameworkInterface {
         * @throws java.lang.IllegalAccessException If the method cannot be accessed
         * @throws java.lang.reflect.InvocationTargetException Any other problems?
         */
-       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria critera) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException;
+       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException;
 
        /**
         * Shuts down this backend
index e96886c220b763ea6a555665990d111f02564511..f1186a81f78b8a196dcd7b731dce899e3206c7e3 100644 (file)
@@ -109,7 +109,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat
                this.getLogger().trace(MessageFormat.format("dataset={0} - CALLED!", dataset)); //NOI18N
 
                // dataset should not be null and not empty
-               if (dataset == null) {
+               if (null == dataset) {
                        // It is null, so abort here
                        throw new NullPointerException("dataset is null"); //NOI18N
                } else if (dataset.isEmpty()) {
@@ -173,9 +173,9 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat
        }
 
        @Override
-       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria critera) throws IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", critera)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", criteria)); //NOI18N
 
                // Init result instance
                Result<? extends Storeable> result = new DatabaseResult();
@@ -201,7 +201,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat
                        this.getLogger().debug(MessageFormat.format("storeable={0}", storeable)); //NOI18N
 
                        // Now matches the found instance
-                       if (critera.matches(storeable)) {
+                       if (criteria.matches(storeable)) {
                                // Then add it to result
                                result.add(storeable);
                        }
@@ -269,7 +269,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat
                this.getLogger().debug(MessageFormat.format("line={0} - CALLED!", line)); //NOI18N
                
                // "line" must not be null or empty
-               if (line == null) {
+               if (null == line) {
                        // Is null
                        throw new NullPointerException("line is null"); //NOI18N
                } else if (line.isEmpty()) {
@@ -402,7 +402,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat
                        String base64 = this.getStorageFile().readLine();
 
                        // Is the line null?
-                       if (base64 == null) {
+                       if (null == base64) {
                                // Then throw NPE here
                                throw new NullPointerException("base64 is null, maybe missed to call isEndOfFile() ?"); //NOI18N
                        }
@@ -447,7 +447,7 @@ public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements Dat
                this.getLogger().trace(MessageFormat.format("output={0} - CALLED!", output)); //NOI18N
 
                // No null or empty strings
-               if (output == null) {
+               if (null == output) {
                        // Is null
                        throw new NullPointerException("output is null"); //NOI18N
                } else  if (output.length() == 0) {
index 6843d194b293da2ad57fa200e75fd23d562768bf..d5265d37b4abe052b95767cd1c5f4399b31d6031 100644 (file)
@@ -82,7 +82,7 @@ public class DataSourceDatabaseBackend extends BaseDatabaseBackend implements Da
                this.getLogger().trace("CALLED!");
 
                // Is the connection given?
-               if (connection == null) {
+               if (null == connection) {
                        // Initial context
                        Context context = new InitialContext();
 
@@ -115,8 +115,8 @@ public class DataSourceDatabaseBackend extends BaseDatabaseBackend implements Da
        }
 
        @Override
-       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria critera) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-               throw new UnsupportedOperationException("Not supported yet: criteria=" + critera); //To change body of generated methods, choose Tools | Templates.
+       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria criteria) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+               throw new UnsupportedOperationException("Not supported yet: criteria=" + criteria); //To change body of generated methods, choose Tools | Templates.
        }
 
        @Override
index 25091e427a4c04a4b0ee22c3dd3d4a5d887f6644..86f487e900284564cc0cd54f401f60a063593731 100644 (file)
@@ -139,7 +139,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
                this.getLogger().trace(MessageFormat.format("dataset={0} - CALLED!", dataset)); //NOI18N
 
                // dataset should not be null and not empty
-               if (dataset == null) {
+               if (null == dataset) {
                        // It is null, so abort here
                        throw new NullPointerException("dataset is null"); //NOI18N
                } else if (dataset.isEmpty()) {
@@ -181,7 +181,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
                        this.getLogger().debug(MessageFormat.format("value={0} - AFTER!", value)); //NOI18N
 
                        // Is the value null?
-                       if (value == null) {
+                       if (null == value) {
                                // Add null
                                valueQuery.append("NULL,"); //NOI18N
                        } else {
@@ -222,12 +222,12 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
        }
 
        @Override
-       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria critera) throws SQLException {
+       public Result<? extends Storeable> doSelectByCriteria (final SearchableCriteria criteria) throws SQLException {
                // Trace message
-               this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", critera)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("criteria={0} - CALLED!", criteria)); //NOI18N
 
                // criteria must not be null
-               if (critera == null) {
+               if (null == criteria) {
                        // Abort here
                        throw new NullPointerException("criteria is null"); //NOI18N
                }
@@ -236,7 +236,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
                StringBuilder query = new StringBuilder(String.format("SELECT * FROM `%s`", this.getTableName())); //NOI18N
 
                // Get entry set
-               Set<Map.Entry<String, Object>> set = critera.entrySet();
+               Set<Map.Entry<String, Object>> set = criteria.entrySet();
 
                // Debug message
                this.getLogger().debug(MessageFormat.format("set.isEmpty()={0}", set.isEmpty())); //NOI18N
@@ -279,14 +279,14 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
                }
 
                // Is limit set?
-               if (critera.getLimit() > 0) {
+               if (criteria.getLimit() > 0) {
                        // Is skip set?
-                       if (critera.getSkip() > 0) {
+                       if (criteria.getSkip() > 0) {
                                // Limit with skip
-                               query.append(String.format(" LIMIT %d,%d", critera.getSkip(), critera.getLimit())); //NOI18N
+                               query.append(String.format(" LIMIT %d,%d", criteria.getSkip(), criteria.getLimit())); //NOI18N
                        } else {
                                // Only limit
-                               query.append(String.format(" LIMIT %d", critera.getLimit())); //NOI18N
+                               query.append(String.format(" LIMIT %d", criteria.getLimit())); //NOI18N
                        }
                }
 
@@ -413,7 +413,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
 
                                // Found ineteger
                                statement.setFloat(index, (float) value);
-                       } else if (value == null) {
+                       } else if (null == value) {
                                // Debug message
                                this.getLogger().warn(MessageFormat.format("Null value in index={0} is not supported (yet)", index)); //NOI18N
                        } else {
index 598d5750596eaa7fa244e34cf2438e52ac3288c9..ca28543cea9b1bf96ea47506abc4cf18967de2a1 100644 (file)
@@ -85,10 +85,10 @@ public abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implement
                this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value)); //NOI18N
 
                // Is key null?
-               if (key == null) {
+               if (null == key) {
                        // Key is null
                        throw new NullPointerException("key is null"); //NOI18N
-               } else if (value == null) {
+               } else if (null == value) {
                        // Issue warning about null reference
                        this.getLogger().warn(MessageFormat.format("value for key={0} is null, this may cause problems.", key));
                }
index 65e216a9b254a831cefc3bd4d77fc66cf8633e8f..8e1f3a4f4ff5acb4f045197f277eaf0f5c81411c 100644 (file)
@@ -49,7 +49,7 @@ public class BackendFactory extends BaseFrameworkSystem {
                factory.getLogger().trace(MessageFormat.format("frontend={0} - CALLED!", frontend)); //NOI18N
 
                // frontend must be set
-               if (frontend == null) {
+               if (null == frontend) {
                        // Is null
                        throw new NullPointerException("frontend is null");
                }
index ecbfff709706572c049307a9e3d87906978f5192..c47f0ae0d8be64ec686eb6ddf0efa880ac69ea6b 100644 (file)
@@ -34,7 +34,7 @@ public class ApplicationManager extends BaseManager implements ManageableApplica
         */
        public static final ManageableApplication getManager (final Application application) {
                // Application instance must be set
-               if (application == null) {
+               if (null == application) {
                        // Abort here
                        throw new NullPointerException("application is null"); //NOI18N
                }
@@ -53,7 +53,7 @@ public class ApplicationManager extends BaseManager implements ManageableApplica
         */
        private ApplicationManager (final Application application) {
                // Application instance must be set
-               if (application == null) {
+               if (null == application) {
                        // Abort here
                        throw new NullPointerException("application is null"); //NOI18N
                }
index 821d57c7a49d30ddb2ee039307ce876cb3a8da26..5caaba83455be505c7c5109cd09c4a5c0193c62e 100644 (file)
@@ -54,7 +54,7 @@ public class BaseModel extends BaseFrameworkSystem {
                this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
 
                // Listener must not be null
-               if (listener == null) {
+               if (null == listener) {
                        // Abort here
                        throw new NullPointerException("listener is null");
                }
@@ -79,7 +79,7 @@ public class BaseModel extends BaseFrameworkSystem {
                this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
 
                // Listener must not be null
-               if (listener == null) {
+               if (null == listener) {
                        // Abort here
                        throw new NullPointerException("listener is null");
                }
@@ -104,7 +104,7 @@ public class BaseModel extends BaseFrameworkSystem {
                this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
 
                // Listener must not be null
-               if (listener == null) {
+               if (null == listener) {
                        // Abort here
                        throw new NullPointerException("listener is null");
                }
@@ -129,7 +129,7 @@ public class BaseModel extends BaseFrameworkSystem {
                this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
 
                // Listener must not be null
-               if (listener == null) {
+               if (null == listener) {
                        // Abort here
                        throw new NullPointerException("listener is null");
                }
index 9638240073e7fe62e7c05669f5e21b31cb7d98a4..67061c4d48ca00641a40822d722bee3404d487ba 100644 (file)
@@ -41,7 +41,7 @@ public class ContactTableModel extends BaseModel implements TableModel {
                this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
 
                // Client must not be null
-               if (client == null)  {
+               if (null == client)  {
                        // Abort here
                        throw new NullPointerException("client is null"); //NOI18N
                }