Adjust checkstyle rules. Make checkstyle fail the build when violations are found. Correct all current checkstyle violations.
This commit is contained in:
@ -8,7 +8,7 @@ public final class IvoryTower {
|
||||
/**
|
||||
* Static to class instance of the class.
|
||||
*/
|
||||
private static final IvoryTower instance = new IvoryTower();
|
||||
private static final IvoryTower INSTANCE = new IvoryTower();
|
||||
|
||||
/**
|
||||
* Private constructor so nobody can instantiate the class.
|
||||
@ -21,6 +21,6 @@ public final class IvoryTower {
|
||||
* @return instance of the singleton.
|
||||
*/
|
||||
public static IvoryTower getInstance() {
|
||||
return instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ package com.iluwatar.singleton;
|
||||
*/
|
||||
public class ThreadSafeDoubleCheckLocking {
|
||||
|
||||
private static volatile ThreadSafeDoubleCheckLocking INSTANCE;
|
||||
private static volatile ThreadSafeDoubleCheckLocking instance;
|
||||
|
||||
/**
|
||||
* private constructor to prevent client from instantiating.
|
||||
*/
|
||||
private ThreadSafeDoubleCheckLocking() {
|
||||
// to prevent instantiating by Reflection call
|
||||
if (INSTANCE != null) {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("Already initialized.");
|
||||
}
|
||||
}
|
||||
@ -31,12 +31,12 @@ public class ThreadSafeDoubleCheckLocking {
|
||||
public static ThreadSafeDoubleCheckLocking getInstance() {
|
||||
// local variable increases performance by 25 percent
|
||||
// Joshua Bloch "Effective Java, Second Edition", p. 283-284
|
||||
ThreadSafeDoubleCheckLocking result = INSTANCE;
|
||||
ThreadSafeDoubleCheckLocking result = instance;
|
||||
if (result == null) {
|
||||
synchronized (ThreadSafeDoubleCheckLocking.class) {
|
||||
result = INSTANCE;
|
||||
result = instance;
|
||||
if (result == null) {
|
||||
INSTANCE = result = new ThreadSafeDoubleCheckLocking();
|
||||
instance = result = new ThreadSafeDoubleCheckLocking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class ThreadSafeLazyLoadedIvoryTower {
|
||||
/**
|
||||
* The instance gets created only when it is called for first time. Lazy-loading
|
||||
*/
|
||||
public synchronized static ThreadSafeLazyLoadedIvoryTower getInstance() {
|
||||
public static synchronized ThreadSafeLazyLoadedIvoryTower getInstance() {
|
||||
|
||||
if (instance == null) {
|
||||
instance = new ThreadSafeLazyLoadedIvoryTower();
|
||||
|
Reference in New Issue
Block a user