]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Licensed to the Apache Software Foundation (ASF) under one or more |
2 | // contributor license agreements. See the NOTICE file distributed with | |
3 | // this work for additional information regarding copyright ownership. | |
4 | // The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | // (the "License"); you may not use this file except in compliance with | |
6 | // the License. You may obtain a copy of the License at | |
7 | // | |
8 | // http://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, | |
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | // See the License for the specific language governing permissions and | |
14 | // limitations under the License. | |
15 | ||
16 | using System; | |
17 | using System.Collections.Generic; | |
18 | using System.Text; | |
19 | using Google.Protobuf; | |
20 | ||
21 | namespace Apache.Arrow.Flight | |
22 | { | |
23 | public class FlightTicket | |
24 | { | |
25 | private readonly Protocol.Ticket _ticket; | |
26 | internal FlightTicket(Protocol.Ticket ticket) | |
27 | { | |
28 | _ticket = ticket; | |
29 | } | |
30 | ||
31 | public FlightTicket(ByteString ticket) | |
32 | { | |
33 | _ticket = new Protocol.Ticket() | |
34 | { | |
35 | Ticket_ = ticket | |
36 | }; | |
37 | } | |
38 | ||
39 | public FlightTicket(string ticket) | |
40 | : this(ByteString.CopyFromUtf8(ticket)) | |
41 | { | |
42 | } | |
43 | ||
44 | public FlightTicket(byte[] bytes) | |
45 | : this(ByteString.CopyFrom(bytes)) | |
46 | { | |
47 | } | |
48 | ||
49 | public ByteString Ticket => _ticket.Ticket_; | |
50 | ||
51 | internal Protocol.Ticket ToProtocol() | |
52 | { | |
53 | return _ticket; | |
54 | } | |
55 | ||
56 | public override bool Equals(object obj) | |
57 | { | |
58 | if(obj is FlightTicket other) | |
59 | { | |
60 | return Equals(_ticket, other._ticket); | |
61 | } | |
62 | return false; | |
63 | } | |
64 | ||
65 | public override int GetHashCode() | |
66 | { | |
67 | return _ticket.GetHashCode(); | |
68 | } | |
69 | } | |
70 | } |