agones.dev/agones@v1.54.0/sdks/unity/model/StatusPort.cs (about) 1 // Copyright 2019 Google LLC 2 // All Rights Reserved. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // 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 20 namespace Agones.Model 21 { 22 /// <summary> 23 /// StatusPort 24 /// </summary> 25 public class StatusPort : IEquatable<StatusPort> 26 { 27 /// <summary> 28 /// Initializes a new instance of the <see cref="StatusPort" /> class. 29 /// </summary> 30 public StatusPort(IReadOnlyDictionary<string, object> data) 31 { 32 this.Name = (string) data["name"]; 33 this.Port = (Int64) data["port"]; 34 } 35 36 public string Name { get; } 37 public Int64 Port { get; } 38 39 /// <summary> 40 /// Returns the string presentation of the object 41 /// </summary> 42 /// <returns>String presentation of the object</returns> 43 public override string ToString() 44 { 45 var sb = new StringBuilder(); 46 sb.Append("class StatusPort {\n"); 47 sb.Append(" Name: ").Append(Name).Append("\n"); 48 sb.Append(" Port: ").Append(Port).Append("\n"); 49 sb.Append("}\n"); 50 return sb.ToString(); 51 } 52 53 /// <summary> 54 /// Returns true if objects are equal 55 /// </summary> 56 /// <param name="input">Object to be compared</param> 57 /// <returns>Boolean</returns> 58 public override bool Equals(object input) 59 { 60 return this.Equals(input as StatusPort); 61 } 62 63 /// <summary> 64 /// Returns true if StatusPort instances are equal 65 /// </summary> 66 /// <param name="input">Instance of StatusPort to be compared</param> 67 /// <returns>Boolean</returns> 68 public bool Equals(StatusPort input) 69 { 70 if (input == null) 71 return false; 72 73 return 74 ( 75 this.Name == input.Name || 76 (this.Name != null && 77 this.Name.Equals(input.Name)) 78 ) && 79 ( 80 this.Port == input.Port || 81 (this.Port.Equals(input.Port)) 82 ); 83 } 84 85 /// <summary> 86 /// Gets the hash code 87 /// </summary> 88 /// <returns>Hash code</returns> 89 public override int GetHashCode() 90 { 91 unchecked // Overflow is fine, just wrap 92 { 93 int hashCode = 41; 94 if (this.Name != null) 95 hashCode = hashCode * 59 + this.Name.GetHashCode(); 96 hashCode = hashCode * 59 + this.Port.GetHashCode(); 97 return hashCode; 98 } 99 } 100 } 101 }