/* * 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 static org.hedgecode.chess.scanner.ScannerConstants.*; /** * ScannerType * * @author Dmitry Samoshin aka gotty */ public enum ScannerType { CHESSGAMES ( TYPE_CHESSGAMES, DOMAIN_CHESSGAMES ), LICHESS ( TYPE_LICHESS, DOMAIN_LICHESS ), CHESSBOMB ( TYPE_CHESSBOMB, DOMAIN_CHESSBOMB ), CHESS24 ( TYPE_CHESS24, DOMAIN_CHESS24 ), CHESSCOM ( TYPE_CHESSCOM, DOMAIN_CHESSCOM ), CHESS2700 ( TYPE_2700CHESS, DOMAIN_2700CHESS ); private String type; private String domain; ScannerType(String type, String domain) { this.type = type; this.domain = domain; } public String type() { return type; } public String domain() { return domain; } public static ScannerType byType(String type) { for (ScannerType scannerType : ScannerType.values()) { if (scannerType.type.equals(type)) return scannerType; } return null; } public static ScannerType byHost(String host) { if (host != null) { for (ScannerType scannerType : ScannerType.values()) { if (StringUtils.belongDomain(scannerType.domain, host)) { return scannerType; } } } return null; } }