Made utility classes final to explicitly forbid it's inheritance

This commit is contained in:
vraskulin 2017-02-27 17:03:38 +03:00
parent f309717616
commit 498c8cf60c
80 changed files with 83 additions and 83 deletions

View file

@ -20,7 +20,7 @@ import mage.view.*;
/**
* Created by IGOUDT on 15-9-2016.
*/
public class SessionHandler {
public final class SessionHandler {
private static Session session;

View file

@ -12,7 +12,7 @@ import java.util.Optional;
import java.util.StringTokenizer;
import java.util.UUID;
public class LocalCommands {
public final class LocalCommands {
private static final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);

View file

@ -7,7 +7,7 @@ import javax.swing.*;
/**
* @author ayratn
*/
public class TestMageFloatPane {
public final class TestMageFloatPane {
public static void main(String... args) {
JFrame f = new JFrame();

View file

@ -52,7 +52,7 @@ import mage.util.TournamentUtil;
* @author nantuko
* @author Simown
*/
public class DeckGenerator {
public final class DeckGenerator {
public static class DeckGeneratorException extends RuntimeException {

View file

@ -57,7 +57,7 @@ public final class CollectionViewerPanel extends JPanel {
private static final Logger logger = Logger.getLogger(CollectionViewerPanel.class);
protected static final String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig";
protected static final String FORMAT_CONFIG_KEY = "collectionViewerFormat";
private static final String FORMAT_CONFIG_KEY = "collectionViewerFormat";
public CollectionViewerPanel() {
initComponents();

View file

@ -346,7 +346,7 @@ public class MageBook extends JComponent {
/**
* Defines the position of the next card on the mage book
*/
private static class CardPosition {
private static final class CardPosition {
private CardPosition() {
}

View file

@ -37,7 +37,7 @@ import mage.view.CardView;
*
* @author nantuko
*/
public class CardHelper {
public final class CardHelper {
private CardHelper() {
}

View file

@ -8,7 +8,7 @@ import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
// TODO: Move all preference related logic from MageFrame and PreferencesDialog to this class.
public class MagePreferences {
public final class MagePreferences {
private static final String KEY_SERVER_ADDRESS = "serverAddress";
private static final String KEY_SERVER_PORT = "serverPort";

View file

@ -39,7 +39,7 @@ import mage.view.*;
*
* @author BetaSteward_at_googlemail.com
*/
public class CardsViewUtil {
public final class CardsViewUtil {
public static CardsView convertSimple(SimpleCardsView view) {
CardsView cards = new CardsView();

View file

@ -38,7 +38,7 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config {
public final class Config {
// TODO: Remove this class completely
private static final Logger logger = Logger.getLogger(Config.class);

View file

@ -41,7 +41,7 @@ import org.apache.log4j.Logger;
*
* @author nantuko
*/
public class DeckUtil {
public final class DeckUtil {
private static final Logger log = Logger.getLogger(DeckUtil.class);

View file

@ -34,7 +34,7 @@ import java.util.Date;
*
* @author LevelX2
*/
public class Format {
public final class Format {
/**
* calculates the duration between two dates and returns a string in the format hhh:mm:ss

View file

@ -19,7 +19,7 @@ import org.mage.card.arcane.CardRenderer;
*
* @author LevelX2
*/
public class GUISizeHelper {
public final class GUISizeHelper {
// relate the native image card size to a value of the size scale
final static int CARD_IMAGE_WIDTH = 312;

View file

@ -8,7 +8,7 @@ import mage.view.ChatMessage;
import java.util.Arrays;
import java.util.Set;
public class IgnoreList {
public final class IgnoreList {
private static final String USAGE = "<br/><font color=yellow>\\ignore - shows current ignore list on this server."
+ "<br/>\\ignore [username] - add a username to your ignore list on this server."

View file

@ -34,7 +34,7 @@ import java.util.Map;
*
* @author draxdyn
*/
public class ImageCaches {
public final class ImageCaches {
private final static ArrayList<Map> IMAGE_CACHES;

View file

@ -47,7 +47,7 @@ import org.mage.card.arcane.UI;
*
* @author BetaSteward_at_googlemail.com
*/
public class ImageHelper {
public final class ImageHelper {
protected static final HashMap<String, BufferedImage> images = new HashMap<>();
protected static final HashMap<String, BufferedImage> backgrounds = new HashMap<>();

View file

@ -6,7 +6,7 @@ import java.lang.reflect.Method;
/**
* @author noxx
*/
public class SystemUtil {
public final class SystemUtil {
public static final String OS_NAME = "os.name";
public static final String MAC_OS_X = "Mac OS X";

View file

@ -20,7 +20,7 @@ import java.util.Map;
*
* @author user
*/
public class TransformedImageCache {
public final class TransformedImageCache {
private final static class Key {

View file

@ -14,7 +14,7 @@ import java.util.UUID;
/**
* @author noxx
*/
public class ArrowUtil {
public final class ArrowUtil {
private ArrowUtil() {}

View file

@ -26,7 +26,7 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
public class GuiDisplayUtil {
public final class GuiDisplayUtil {
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
private static final Insets DEFAULT_INSETS = new Insets(0, 0, 70, 25);

View file

@ -13,7 +13,7 @@ import mage.client.dialog.PreferencesDialog;
*
* @author LevelX2
*/
public class TableUtil {
public final class TableUtil {
/**
*

View file

@ -18,7 +18,7 @@ import org.apache.log4j.Logger;
*
* @author LevelX2
*/
public class CountryUtil {
public final class CountryUtil {
private static final Logger LOGGER = Logger.getLogger(CountryUtil.class);
private static final Map<String, ImageIcon> FLAG_ICON_CACHE = new HashMap<>();

View file

@ -13,7 +13,7 @@ import java.util.Calendar;
*
* @author ayrat
*/
public class SaveObjectUtil {
public final class SaveObjectUtil {
/**
* Defines should data be saved or not.

View file

@ -16,7 +16,7 @@ import mage.deck.Standard;
*
* @author nantuko
*/
public class ConstructedFormats {
public final class ConstructedFormats {
public static final String ALL = "- All Sets";
public static final String STANDARD = "- Standard";

View file

@ -3,7 +3,7 @@ package mage.client.util.stats;
/**
* @author noxx
*/
public class MemoryUsageStatUtil {
public final class MemoryUsageStatUtil {
private MemoryUsageStatUtil() {}

View file

@ -22,7 +22,7 @@ import java.util.regex.Pattern;
*
* Various static utilities for use in the card renderer
*/
public class CardRendererUtils {
public final class CardRendererUtils {
/**
* Convert an abstract image, whose underlying implementation may or may not

View file

@ -31,7 +31,7 @@ import mage.client.util.gui.BufferedImageBuilder;
import org.apache.log4j.Logger;
import org.mage.plugins.card.constants.Constants;
public class ManaSymbols {
public final class ManaSymbols {
private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
private static final Map<Integer, Map<String, BufferedImage>> manaImages = new HashMap<>();

View file

@ -18,7 +18,7 @@ import org.apache.log4j.Logger;
*
* @author StravantUser
*/
public class TextboxRuleParser {
public final class TextboxRuleParser {
private static final Logger LOGGER = Logger.getLogger(CardPanel.class);

View file

@ -46,7 +46,7 @@ import javax.swing.text.html.ImageView;
/**
* UI utility functions.
*/
public class UI {
public final class UI {
private static final ConcurrentMap<URI, Image> imageCache = new ConcurrentHashMap<>();
public static JToggleButton getToggleButton () {

View file

@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit;
import javax.swing.SwingUtilities;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Util {
public final class Util {
public static final boolean isMac = System.getProperty("os.name").toLowerCase().contains("mac");
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase().contains("windows");

View file

@ -3,7 +3,7 @@ package org.mage.plugins.card.constants;
import java.awt.Rectangle;
import java.io.File;
public class Constants {
public final class Constants {
public static final String RESOURCE_PATH_SET = File.separator + "sets" + File.separator;

View file

@ -15,7 +15,7 @@ import org.apache.log4j.Logger;
import org.mage.plugins.card.images.CardDownloadData;
import org.mage.plugins.card.properties.SettingsManager;
public class CardImageUtils {
public final class CardImageUtils {
private static final HashMap<CardDownloadData, String> pathCache = new HashMap<>();
private static final Logger log = Logger.getLogger(CardImageUtils.class);

View file

@ -11,14 +11,14 @@ import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;
public class Transparency {
public final class Transparency {
public static Image makeColorTransparent(Image im, final Color color) {
ImageFilter filter = new RGBImageFilter() {
// the color we are looking for... Alpha bits are set to opaque
public final int markerRGB = color.getRGB() | 0xFF000000;
@Override
public final int filterRGB(int x, int y, int rgb) {
public int filterRGB(int x, int y, int rgb) {
if ((rgb | 0xFF000000) == markerRGB) {
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;

View file

@ -10,7 +10,7 @@ import java.util.List;
/**
* @author noxx
*/
public class EntityManagerTest {
public final class EntityManagerTest {
private static DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.FULL);

View file

@ -7,7 +7,7 @@ import java.util.*;
/**
* @author noxx
*/
public class Statistics {
public final class Statistics {
public static void main(String[] args) throws Exception {
List<Log> logs = EntityManager.instance.getAllLogs();

View file

@ -13,7 +13,7 @@ import mage.view.CardView;
* @version 0.1 02.11.2010
* @author nantuko
*/
public class CardUtil {
public final class CardUtil {
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";

View file

@ -8,7 +8,7 @@ import mage.remote.traffic.ZippedObjectImpl;
*
* @author ayrat
*/
public class CompressUtil {
public final class CompressUtil {
/**
* Defines should data be compressed or not. True by default. Read from

View file

@ -21,7 +21,7 @@ import mage.util.RandomUtil;
*
* @author nantuko
*/
public class DeckBuilder {
public final class DeckBuilder {
private static final int DECK_COUNT40[] = {3, 6, 6, 4, 3, 2};
private static final int DECK_COUNT60[] = {4, 9, 9, 5, 5, 3};

View file

@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit;
* @author ayrat
*/
@SuppressWarnings("unchecked")
public class ThreadUtils {
public final class ThreadUtils {
public static final ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool2;

View file

@ -9,7 +9,7 @@ import java.util.Properties;
/**
* @author noxx
*/
public class PropertiesUtil {
public final class PropertiesUtil {
private static final Logger logger = Logger.getLogger(PropertiesUtil.class);

View file

@ -3,7 +3,7 @@ package mage.utils.properties;
/**
* @author noxx
*/
public class PropertyKeys {
public final class PropertyKeys {
public static final String KEY_DB_LOG_URL = "db.log.url";
public static final String KEY_DB_FEEDBACK_URL = "db.feedback.url";

View file

@ -40,7 +40,7 @@ import java.util.Properties;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config2 {
public final class Config2 {
private static final Logger logger = Logger.getLogger(Config2.class);

View file

@ -18,7 +18,7 @@ import org.apache.log4j.Logger;
* this evaluator is only good for two player games
*
*/
public class GameStateEvaluator2 {
public final class GameStateEvaluator2 {
private static final Logger logger = Logger.getLogger(GameStateEvaluator2.class);

View file

@ -14,7 +14,7 @@ import mage.game.permanent.Permanent;
/**
* @author ubeefx, nantuko
*/
public class ArtificialScoringSystem {
public final class ArtificialScoringSystem {
public static final int WIN_GAME_SCORE = 100000000;
public static final int LOSE_GAME_SCORE = -WIN_GAME_SCORE;

View file

@ -9,7 +9,7 @@ import java.util.Map;
/**
* @author nantuko
*/
public class MagicAbility {
public final class MagicAbility {
private static Map<String, Integer> scores = new HashMap<String, Integer>() {{
put(DeathtouchAbility.getInstance().getRule(), 60);

View file

@ -21,7 +21,7 @@ import java.util.*;
*
* @author noxx
*/
public class CombatUtil {
public final class CombatUtil {
private static final List<Permanent> emptyList = new ArrayList<Permanent>();

View file

@ -21,7 +21,7 @@ import java.util.*;
*
* @author nantuko
*/
public class RateCard {
public final class RateCard {
private static Map<String, Integer> ratings;
private static final Map<String, Integer> rated = new HashMap<>();

View file

@ -39,7 +39,7 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config {
public final class Config {
private static final Logger logger = Logger.getLogger(Config.class);

View file

@ -51,7 +51,7 @@ import org.apache.log4j.Logger;
* this evaluator is only good for two player games
*
*/
public class GameStateEvaluator {
public final class GameStateEvaluator {
private static final Logger logger = Logger.getLogger(GameStateEvaluator.class);

View file

@ -37,7 +37,7 @@ import java.util.Scanner;
/**
* @author Lymia
*/
public class ExtensionPackageLoader {
public final class ExtensionPackageLoader {
public static ExtensionPackage loadExtension(File directory) throws IOException {
if(!directory.exists ()) throw new RuntimeException("File not found "+directory);
if(!directory.isDirectory()) throw new RuntimeException(directory+" is not a directory");

View file

@ -28,7 +28,7 @@ import javax.mail.internet.MimeMessage;
import mage.server.util.ConfigSettings;
import org.apache.log4j.Logger;
public class GmailClient {
public final class GmailClient {
private static final Logger logger = Logger.getLogger(Main.class);
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();

View file

@ -10,7 +10,7 @@ import javax.mail.internet.MimeMessage;
import mage.server.util.ConfigSettings;
import org.apache.log4j.Logger;
public class MailClient {
public final class MailClient {
private static final Logger logger = Logger.getLogger(Main.class);

View file

@ -9,7 +9,7 @@ import javax.ws.rs.core.MediaType;
import mage.server.util.ConfigSettings;
import org.apache.log4j.Logger;
public class MailgunClient {
public final class MailgunClient {
private static final Logger logger = Logger.getLogger(Main.class);

View file

@ -70,7 +70,7 @@ import java.util.*;
/**
* @author BetaSteward_at_googlemail.com
*/
public class Main {
public final class Main {
private static final Logger logger = Logger.getLogger(Main.class);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);

View file

@ -36,7 +36,7 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class Config {
public final class Config {
private static final Logger logger = Logger.getLogger(Config.class);

View file

@ -9,7 +9,7 @@ import mage.players.Player;
/**
* @author nantuko
*/
public class Splitter {
public final class Splitter {
public static List<UUID> split(Game game, UUID playerId) {
List<UUID> players = new ArrayList<>();

View file

@ -19,7 +19,7 @@ import java.util.regex.Pattern;
/**
* @author nantuko
*/
public class SystemUtil {
public final class SystemUtil {
public static final DateFormat dateFormat = new SimpleDateFormat("yy-M-dd HH:mm:ss");

View file

@ -4,7 +4,7 @@ import com.xmage.ws.model.DomainErrors;
import com.xmage.ws.resource.Resource;
import net.minidev.json.JSONObject;
public class ResponseBuilder {
public final class ResponseBuilder {
public static JSONObject build(int code) {
JSONObject response = new JSONObject();

View file

@ -19,7 +19,7 @@ public class XMageStatsJSONBuilder implements JSONBuilder<ServerStats> {
private static final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
static class StaticHolder {
static final class StaticHolder {
static XMageStatsJSONBuilder instance = new XMageStatsJSONBuilder();
}

View file

@ -6,7 +6,7 @@ package com.xmage.ws.util;
*
* @author noxx
*/
public class IPHolderUtil {
public final class IPHolderUtil {
private static final ThreadLocal<String> ipThreadLocal = new ThreadLocal<String>();
private static final ThreadLocal<String> userAgentThreadLocal = new ThreadLocal<String>();

View file

@ -6,7 +6,7 @@ import java.io.*;
*
* @author noxx
*/
public class FileUtil {
public final class FileUtil {
private FileUtil() {}

View file

@ -7,7 +7,7 @@ import java.security.MessageDigest;
/**
* @author Loki
*/
public class ChechsumHelper {
public final class ChechsumHelper {
public static byte[] createChecksum(String filename) throws Exception {
InputStream fis = null;

View file

@ -10,7 +10,7 @@ import java.util.List;
*
* @author noxx
*/
public class FileHelper {
public final class FileHelper {
private FileHelper() {
}

View file

@ -15,10 +15,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipInputStream;
public class MtgJson {
public final class MtgJson {
private MtgJson() {}
private static class CardHolder {
private static final class CardHolder {
private static final Map<String, JsonCard> cards;
static {
try {
@ -30,7 +30,7 @@ public class MtgJson {
}
}
private static class SetHolder {
private static final class SetHolder {
private static final Map<String, JsonSet> sets;
static {
try {

View file

@ -5,7 +5,7 @@ package mage.actions.score;
*
* @author ayratn
*/
public class ScoringConstants {
public final class ScoringConstants {
public static final int WIN_GAME_SCORE = 100000000;
public static final int LOSE_GAME_SCORE = -WIN_GAME_SCORE;

View file

@ -33,7 +33,7 @@ import mage.cards.decks.DeckCardLists;
*
* @author North
*/
public class DeckImporterUtil {
public final class DeckImporterUtil {
public static DeckImporter getDeckImporter(String file) {
if (file.toLowerCase().endsWith("dec")) {

View file

@ -36,7 +36,7 @@ import org.apache.log4j.Logger;
*
* @author North
*/
public class CardScanner {
public final class CardScanner {
public static boolean scanned = false;

View file

@ -36,7 +36,7 @@ import java.util.List;
*
* @author Lymia
*/
public class PluginClassloaderRegistery {
public final class PluginClassloaderRegistery {
static List<ClassLoader> pluginClassloaders = new ArrayList<>();
public static void registerPluginClassloader(ClassLoader cl) {

View file

@ -14,7 +14,7 @@ import java.util.List;
*
* @author North
*/
public class RepositoryUtil {
public final class RepositoryUtil {
public static boolean isDatabaseObsolete(ConnectionSource connectionSource, String entityName, long version) throws SQLException {
TableUtils.createTableIfNotExists(connectionSource, DatabaseVersion.class);

View file

@ -21,7 +21,7 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
*
* @author LevelX2
*/
public class StaticFilters {
public final class StaticFilters {
public static final FilterCreaturePermanent FILTER_ARTIFACT_CREATURE_PERMANENT = new FilterArtifactCreaturePermanent();
public static final FilterPermanent FILTER_PERMANENT_ARTIFACT_OR_CREATURE = new FilterPermanent("artifact or creature");

View file

@ -20,7 +20,7 @@ import mage.target.TargetCard;
/**
* Created by samuelsandeen on 9/6/16.
*/
public class ZonesHandler {
public final class ZonesHandler {
public static boolean cast(ZoneChangeInfo info, Game game) {
if (maybeRemoveFromSourceZone(info, game)) {

View file

@ -59,7 +59,7 @@ import mage.util.functions.CopyTokenFunction;
/**
* @author nantuko
*/
public class CardUtil {
public final class CardUtil {
private static final String regexBlack = ".*\\x7b.{0,2}B.{0,2}\\x7d.*";
private static final String regexBlue = ".*\\x7b.{0,2}U.{0,2}\\x7d.*";

View file

@ -40,7 +40,7 @@ import java.util.jar.JarInputStream;
*
* @author North
*/
public class ClassScanner {
public final class ClassScanner {
private static void checkClassForInclusion(List<Class> cards, Class type, String name, ClassLoader cl) {
try {

View file

@ -33,7 +33,7 @@ import java.util.Date;
*
* @author LevelX2
*/
public class DateFormat {
public final class DateFormat {
/**
* calculates the duration between two dates and returns a string in the format hhh:mm:ss

View file

@ -31,7 +31,7 @@ package mage.util;
*
* @author LevelX2
*/
public class DeckUtil {
public final class DeckUtil {
public static long fixedHash(String string) {
long h = 1125899906842597L; // prime

View file

@ -34,7 +34,7 @@ import mage.ObjectColor;
*
* @author LevelX2
*/
public class GameLog {
public final class GameLog {
static final String LOG_COLOR_PLAYER = "#20B2AA"; // LightSeaGreen
static final String LOG_COLOR_PLAYER_REQUEST = "#D2691E"; // Chocolate

View file

@ -28,7 +28,7 @@ import mage.game.Game;
/**
* @author noxx
*/
public class ManaUtil {
public final class ManaUtil {
private ManaUtil() {
}

View file

@ -6,7 +6,7 @@ import java.util.concurrent.ThreadLocalRandom;
/**
* Created by IGOUDT on 5-9-2016.
*/
public class RandomUtil {
public final class RandomUtil {
public static Random getRandom() {return ThreadLocalRandom.current();}

View file

@ -24,7 +24,7 @@ import mage.constants.Rarity;
*
* @author LevelX2
*/
public class TournamentUtil {
public final class TournamentUtil {
/**
* Tries to calculate the most appropiate sets to add basic lands for cards of a deck

View file

@ -25,7 +25,7 @@ import mage.constants.CardType;
/**
* @author magenoxx_at_gmail.com
*/
public class TraceUtil {
public final class TraceUtil {
private static final Logger log = Logger.getLogger(TraceUtil.class);