Skip to content

Commit e3355d7

Browse files
committed
Caching pattern: Style fix for null check
1 parent 865f788 commit e3355d7

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

caching/src/main/java/com/iluwatar/caching/CacheStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private CacheStore() {
4040
* Init cache capacity
4141
*/
4242
public static void initCapacity(int capacity) {
43-
if (null == cache) {
43+
if (cache == null) {
4444
cache = new LruCache(capacity);
4545
} else {
4646
cache.setCapacity(capacity);
@@ -121,7 +121,7 @@ public static void writeBehind(UserAccount userAccount) {
121121
* Clears cache
122122
*/
123123
public static void clearCache() {
124-
if (null != cache) {
124+
if (cache != null) {
125125
cache.clear();
126126
}
127127
}

caching/src/main/java/com/iluwatar/caching/DbManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static UserAccount readFromDb(String userId) {
8282
}
8383
return null;
8484
}
85-
if (null == db) {
85+
if (db == null) {
8686
try {
8787
connect();
8888
} catch (ParseException e) {
@@ -106,7 +106,7 @@ public static void writeToDb(UserAccount userAccount) {
106106
virtualDB.put(userAccount.getUserId(), userAccount);
107107
return;
108108
}
109-
if (null == db) {
109+
if (db == null) {
110110
try {
111111
connect();
112112
} catch (ParseException e) {
@@ -126,7 +126,7 @@ public static void updateDb(UserAccount userAccount) {
126126
virtualDB.put(userAccount.getUserId(), userAccount);
127127
return;
128128
}
129-
if (null == db) {
129+
if (db == null) {
130130
try {
131131
connect();
132132
} catch (ParseException e) {
@@ -148,7 +148,7 @@ public static void upsertDb(UserAccount userAccount) {
148148
virtualDB.put(userAccount.getUserId(), userAccount);
149149
return;
150150
}
151-
if (null == db) {
151+
if (db == null) {
152152
try {
153153
connect();
154154
} catch (ParseException e) {

0 commit comments

Comments
 (0)