001/*******************************************************************************
002The MIT License (MIT)
003
004Copyright (c) 2024 KILLCODING.COM
005
006Permission is hereby granted, free of charge, to any person obtaining a copy
007of this software and associated documentation files (the "Software"), to deal
008in the Software without restriction, including without limitation the rights
009to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
010copies of the Software, and to permit persons to whom the Software is
011furnished to do so, subject to the following conditions:
012
013The above copyright notice and this permission notice shall be included in
014all copies or substantial portions of the Software.
015
016THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
017IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
018FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
019AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
020LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
021OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
022THE SOFTWARE.
023*****************************************************************************/
024package com.killcoding.tool;
025
026public enum CodeEscapeLevel {
027
028    LEVEL_1_BASIC_ESCAPE_SET(1),
029
030    LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET(2),
031
032    LEVEL_3_ALL_NON_ALPHANUMERIC(3),
033
034    LEVEL_4_ALL_CHARACTERS(4);
035
036    private final int escapeLevel;
037
038    public static CodeEscapeLevel forLevel(final int level) {
039        switch (level) {
040            case 1: return LEVEL_1_BASIC_ESCAPE_SET;
041            case 2: return LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET;
042            case 3: return LEVEL_3_ALL_NON_ALPHANUMERIC;
043            case 4: return LEVEL_4_ALL_CHARACTERS;
044            default:
045                throw new IllegalArgumentException(String.format("No escape level: ",level));
046        }
047    }
048
049
050    CodeEscapeLevel(final int escapeLevel) {
051        this.escapeLevel = escapeLevel;
052    }
053
054
055    public int getEscapeLevel() {
056        return this.escapeLevel;
057    }
058
059}