001// Generated by delombok at Sat Feb 25 17:58:34 UTC 2023 002package io.cui.tools.io; 003 004import static java.util.Objects.requireNonNull; 005 006/** 007 * Utility class to define file type prefixes. 008 * 009 * @author Sven Haag 010 */ 011public enum FileTypePrefix { 012 /** 013 * "file:" 014 */ 015 FILE("file:"), /** 016 * "classpath:" 017 */ 018 CLASSPATH("classpath:"), /** 019 * "external:" 020 */ 021 EXTERNAL("external:"), /** 022 * "url:" 023 */ 024 URL("url:"); 025 private final String prefix; 026 027 FileTypePrefix(final String prefix) { 028 this.prefix = prefix; 029 } 030 031 /** 032 * @param path to be checked 033 * 034 * @return true if the given path is prefixed with this enum 035 */ 036 public boolean is(final String path) { 037 return null != path && path.startsWith(getPrefix()); 038 } 039 040 /** 041 * @param path from which the prefix should be removed 042 * 043 * @return path without {@link #getPrefix()} 044 */ 045 public String removePrefix(final String path) { 046 requireNonNull(path); 047 if (is(path)) { 048 return path.substring(getPrefix().length()); 049 } 050 return path; 051 } 052 053 @Override 054 public String toString() { 055 return prefix; 056 } 057 058 @java.lang.SuppressWarnings("all") 059 @lombok.Generated 060 public String getPrefix() { 061 return this.prefix; 062 } 063}