1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.ssl;
17
18 import io.netty.util.internal.ObjectUtil;
19
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.Iterator;
24 import java.util.List;
25
26
27
28
29 public final class OpenSslCertificateCompressionConfig implements
30 Iterable<OpenSslCertificateCompressionConfig.AlgorithmConfig> {
31 private final List<AlgorithmConfig> pairList;
32
33 private OpenSslCertificateCompressionConfig(AlgorithmConfig... pairs) {
34 pairList = Collections.unmodifiableList(Arrays.asList(pairs));
35 }
36
37 @Override
38 public Iterator<AlgorithmConfig> iterator() {
39 return pairList.iterator();
40 }
41
42
43
44
45
46
47 public static Builder newBuilder() {
48 return new Builder();
49 }
50
51
52
53
54 public static final class Builder {
55 private final List<AlgorithmConfig> algorithmList = new ArrayList<AlgorithmConfig>();
56
57 private Builder() { }
58
59
60
61
62
63
64
65
66
67
68
69
70
71 public Builder addAlgorithm(OpenSslCertificateCompressionAlgorithm algorithm, AlgorithmMode mode) {
72 algorithmList.add(new AlgorithmConfig(algorithm, mode));
73 return this;
74 }
75
76
77
78
79
80
81
82 public OpenSslCertificateCompressionConfig build() {
83 return new OpenSslCertificateCompressionConfig(algorithmList.toArray(new AlgorithmConfig[0]));
84 }
85 }
86
87
88
89
90 public static final class AlgorithmConfig {
91 private final OpenSslCertificateCompressionAlgorithm algorithm;
92 private final AlgorithmMode mode;
93
94 private AlgorithmConfig(OpenSslCertificateCompressionAlgorithm algorithm, AlgorithmMode mode) {
95 this.algorithm = ObjectUtil.checkNotNull(algorithm, "algorithm");
96 this.mode = ObjectUtil.checkNotNull(mode, "mode");
97 }
98
99
100
101
102
103
104 public AlgorithmMode mode() {
105 return mode;
106 }
107
108
109
110
111
112
113 public OpenSslCertificateCompressionAlgorithm algorithm() {
114 return algorithm;
115 }
116 }
117
118
119
120
121 public enum AlgorithmMode {
122
123
124
125 Compress,
126
127
128
129
130 Decompress,
131
132
133
134
135 Both
136 }
137 }