1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.handler.codec.http;
17
18 import io.netty5.util.AsciiString;
19
20
21
22
23
24 public final class HttpScheme {
25
26
27
28
29 public static final HttpScheme HTTP = new HttpScheme(80, "http");
30
31
32
33
34 public static final HttpScheme HTTPS = new HttpScheme(443, "https");
35
36 private final int port;
37 private final AsciiString name;
38
39 private HttpScheme(int port, String name) {
40 this.port = port;
41 this.name = AsciiString.cached(name);
42 }
43
44 public AsciiString name() {
45 return name;
46 }
47
48 public int port() {
49 return port;
50 }
51
52 @Override
53 public boolean equals(Object o) {
54 if (!(o instanceof HttpScheme)) {
55 return false;
56 }
57 HttpScheme other = (HttpScheme) o;
58 return other.port() == port && other.name().equals(name);
59 }
60
61 @Override
62 public int hashCode() {
63 return port * 31 + name.hashCode();
64 }
65
66 @Override
67 public String toString() {
68 return name.toString();
69 }
70 }