[LIB-13] Rename some common classes
[chesshog-scanner.git] / src / main / java / org / hedgecode / chess / scanner / ChessHogScannerProperties.java
diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerProperties.java b/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerProperties.java
deleted file mode 100644 (file)
index fdead40..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2019-2020. Developed by Hedgecode.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.hedgecode.chess.scanner;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * ChessHogScanner properties holder.
- *
- * @author Dmitry Samoshin aka gotty
- */
-public class ChessHogScannerProperties {
-
-    /** Properties file. */
-    private static final String PROPERTIES_FILE = "scanner.properties";
-
-    /** Properties. */
-    private static final Properties PROPERTIES;
-
-    /**
-     * Static properties initialization.
-     */
-    static {
-        PROPERTIES = new Properties();
-        readProperties(PROPERTIES_FILE, PROPERTIES, true);
-    }
-
-    /**
-     * @param propsFile Properties file name.
-     * @param props Properties.
-     * @param throwExc Flag indicating whether to throw an exception or not.
-     */
-    public static void readProperties(String propsFile, Properties props, boolean throwExc) {
-        try (InputStream is = ChessHogScannerProperties.class.getClassLoader().getResourceAsStream(propsFile))
-        {
-            if (is == null) {
-                if (throwExc) {
-                    throw new RuntimeException(
-                            String.format("Failed to find properties file: %s", propsFile)
-                    );
-                } else {
-                    return;
-                }
-            }
-            props.load(is);
-        } catch (IOException cause) {
-            throw new RuntimeException(
-                    String.format("Failed to read properties file: %s", propsFile),
-                    cause
-            );
-        }
-    }
-
-    /**
-     * Empty string for not found properties.
-     */
-    private static final String EMPTY = "";
-
-    /**
-     * Gets string property value.
-     *
-     * @param key Property key.
-     * @return Property value (possibly empty string, but never {@code null}).
-     */
-    public static String get(String key) {
-        return PROPERTIES.getProperty(key, EMPTY);
-    }
-
-    /**
-     * Gets boolean property value.
-     *
-     * @param key Property key.
-     * @return Property value ({@code false} by default).
-     */
-    public static boolean is(String key) {
-        return Boolean.parseBoolean(
-                PROPERTIES.getProperty(key, Boolean.FALSE.toString())
-        );
-    }
-
-    /**
-     * Zero integer for not found properties.
-     */
-    private static final String ZERO = "0";
-
-    /**
-     * Gets integer property value.
-     *
-     * @param key Property key.
-     * @return Property value ({@code 0} by default).
-     */
-    public static int getInt(String key) {
-        return Integer.parseInt(
-                PROPERTIES.getProperty(key, ZERO)
-        );
-    }
-
-    /**
-     * Private constructor.
-     */
-    private ChessHogScannerProperties() {
-    }
-
-}