1 /*
2 * Copyright 2024 The Netty Project
3 *
4 * The Netty Project licenses this file to you under the Apache License,
5 * version 2.0 (the "License"); you may not use this file except in compliance
6 * with the License. You may obtain a copy of the License at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16 package io.netty.handler.codec.compression;
17
18 import com.aayushatharva.brotli4j.encoder.Encoder;
19
20 import static com.aayushatharva.brotli4j.encoder.Encoder.Mode;
21
22 /**
23 * Provides a way to specify the Brotli compression mode.
24 */
25 public enum BrotliMode {
26
27 /**
28 * The compressor does not make any assumptions about the input data's properties,
29 * making it suitable for a wide range of data types.
30 * default mode.
31 */
32 GENERIC,
33
34 /**
35 * Optimized for UTF-8 formatted text input.
36 */
37 TEXT,
38
39 /**
40 * Designed specifically for font data compression, as used in WOFF 2.0.
41 */
42 FONT;
43
44 /**
45 * Convert to Brotli {@link Encoder.Mode}.
46 *
47 * @return a new {@link Encoder.Mode}
48 */
49 Mode adapt() {
50 switch (this) {
51 case GENERIC:
52 return Mode.GENERIC;
53 case TEXT:
54 return Mode.TEXT;
55 case FONT:
56 return Mode.FONT;
57 default:
58 throw new IllegalStateException("Unsupported enum value: " + this);
59 }
60 }
61 }