* made all singleton classes final

This commit is contained in:
Reinhard Pointner 2008-10-10 19:20:37 +00:00
parent e61472c2f4
commit 661e079f2b
8 changed files with 44 additions and 15 deletions

View File

@ -11,7 +11,7 @@ import java.util.regex.Pattern;
import net.sourceforge.tuned.FileUtil; import net.sourceforge.tuned.FileUtil;
public class FileBotUtil { public final class FileBotUtil {
/** /**
* Invalid characters in filenames: \, /, :, *, ?, ", <, >, |, \r and \n * Invalid characters in filenames: \, /, :, *, ?, ", <, >, |, \r and \n
@ -104,8 +104,11 @@ public class FileBotUtil {
}; };
/**
* Dummy constructor to prevent instantiation.
*/
private FileBotUtil() { private FileBotUtil() {
// hide constructor throw new UnsupportedOperationException();
} }
} }

View File

@ -10,7 +10,7 @@ import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
public class ResourceManager { public final class ResourceManager {
public static ImageIcon getIcon(String name) { public static ImageIcon getIcon(String name) {
return getIcon(name, null); return getIcon(name, null);
@ -48,7 +48,7 @@ public class ResourceManager {
/** /**
* Get the URL of an image resource in this jar. Image must be located in * Get the URL of an image resource in this jar. Image must be located in
* <code>/resources</code> and the file type is assumed to be png. * <code>resources/</code> and the file type is assumed to be png.
* *
* @param name simple name of the resource (without extension) * @param name simple name of the resource (without extension)
* @return URL of the resource or null if resource does not exist * @return URL of the resource or null if resource does not exist
@ -68,6 +68,9 @@ public class ResourceManager {
} }
/**
* Dummy constructor to prevent instantiation.
*/
private ResourceManager() { private ResourceManager() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -2,7 +2,7 @@
package net.sourceforge.tuned; package net.sourceforge.tuned;
public class ExceptionUtil { public final class ExceptionUtil {
public static Throwable getRootCause(Throwable t) { public static Throwable getRootCause(Throwable t) {
while (t.getCause() != null) { while (t.getCause() != null) {
@ -21,4 +21,12 @@ public class ExceptionUtil {
return new RuntimeException(t); return new RuntimeException(t);
} }
/**
* Dummy constructor to prevent instantiation.
*/
private ExceptionUtil() {
throw new UnsupportedOperationException();
}
} }

View File

@ -5,7 +5,7 @@ package net.sourceforge.tuned;
import java.io.File; import java.io.File;
public class FileUtil { public final class FileUtil {
public final static long KILO = 1024; public final static long KILO = 1024;
@ -115,4 +115,12 @@ public class FileUtil {
return "File"; return "File";
} }
/**
* Dummy constructor to prevent instantiation.
*/
private FileUtil() {
throw new UnsupportedOperationException();
}
} }

View File

@ -22,11 +22,6 @@ public class MessageBus {
private final Map<String, List<MessageHandler>> handlers = new HashMap<String, List<MessageHandler>>(); private final Map<String, List<MessageHandler>> handlers = new HashMap<String, List<MessageHandler>>();
private MessageBus() {
}
public synchronized void addMessageHandler(String topic, MessageHandler handler) { public synchronized void addMessageHandler(String topic, MessageHandler handler) {
List<MessageHandler> list = handlers.get(topic.toLowerCase()); List<MessageHandler> list = handlers.get(topic.toLowerCase());
@ -70,4 +65,5 @@ public class MessageBus {
} }
}); });
} }
} }

View File

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class TemporaryFolder { public final class TemporaryFolder {
private static final String tmpdir = System.getProperty("java.io.tmpdir"); private static final String tmpdir = System.getProperty("java.io.tmpdir");

View File

@ -14,7 +14,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
public class XPathUtil { public final class XPathUtil {
public static Node selectNode(String xpath, Object node) { public static Node selectNode(String xpath, Object node) {
try { try {
@ -79,4 +79,12 @@ public class XPathUtil {
return XPathFactory.newInstance().newXPath().compile(xpath); return XPathFactory.newInstance().newXPath().compile(xpath);
} }
/**
* Dummy constructor to prevent instantiation.
*/
private XPathUtil() {
throw new UnsupportedOperationException();
}
} }

View File

@ -21,7 +21,7 @@ import javax.swing.SwingUtilities;
import javax.swing.Timer; import javax.swing.Timer;
public class TunedUtil { public final class TunedUtil {
public static void checkEventDispatchThread() { public static void checkEventDispatchThread() {
if (!SwingUtilities.isEventDispatchThread()) { if (!SwingUtilities.isEventDispatchThread()) {
@ -82,8 +82,11 @@ public class TunedUtil {
} }
/**
* Dummy constructor to prevent instantiation.
*/
private TunedUtil() { private TunedUtil() {
// hide constructor throw new UnsupportedOperationException();
} }
} }