agones.dev/agones@v1.54.0/sdks/unity/model/SpecHealth.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 /// SpecHealth 24 /// </summary> 25 public class SpecHealth : IEquatable<SpecHealth> 26 { 27 /// <summary> 28 /// Initializes a new instance of the <see cref="SpecHealth" /> class. 29 /// </summary> 30 public SpecHealth(IReadOnlyDictionary<string, object> data) 31 { 32 this.Disabled = data.TryGetValue("disabled", out var disabled) && (bool)disabled; 33 if (!this.Disabled) 34 { 35 this.PeriodSeconds = (Int64)data["period_seconds"]; 36 this.FailureThreshold = (Int64)data["failure_threshold"]; 37 this.InitialDelaySeconds = (Int64)data["initial_delay_seconds"]; 38 } 39 } 40 41 public bool Disabled { get; } 42 public Int64 PeriodSeconds { get; } 43 public Int64 FailureThreshold { get; } 44 public Int64 InitialDelaySeconds { get; } 45 46 /// <summary> 47 /// Returns the string presentation of the object 48 /// </summary> 49 /// <returns>String presentation of the object</returns> 50 public override string ToString() 51 { 52 var sb = new StringBuilder(); 53 sb.Append("class SpecHealth {\n"); 54 sb.Append(" Disabled: ").Append(Disabled).Append("\n"); 55 sb.Append(" PeriodSeconds: ").Append(PeriodSeconds).Append("\n"); 56 sb.Append(" FailureThreshold: ").Append(FailureThreshold).Append("\n"); 57 sb.Append(" InitialDelaySeconds: ").Append(InitialDelaySeconds).Append("\n"); 58 sb.Append("}\n"); 59 return sb.ToString(); 60 } 61 62 /// <summary> 63 /// Returns true if objects are equal 64 /// </summary> 65 /// <param name="input">Object to be compared</param> 66 /// <returns>Boolean</returns> 67 public override bool Equals(object input) 68 { 69 return this.Equals(input as SpecHealth); 70 } 71 72 /// <summary> 73 /// Returns true if SpecHealth instances are equal 74 /// </summary> 75 /// <param name="input">Instance of SpecHealth to be compared</param> 76 /// <returns>Boolean</returns> 77 public bool Equals(SpecHealth input) 78 { 79 if (input == null) 80 return false; 81 82 return 83 ( 84 this.Disabled == input.Disabled || 85 (this.Disabled.Equals(input.Disabled)) 86 ) && 87 ( 88 this.PeriodSeconds == input.PeriodSeconds || 89 (this.PeriodSeconds.Equals(input.PeriodSeconds)) 90 ) && 91 ( 92 this.FailureThreshold == input.FailureThreshold || 93 (this.FailureThreshold.Equals(input.FailureThreshold)) 94 ) && 95 ( 96 this.InitialDelaySeconds == input.InitialDelaySeconds || 97 (this.InitialDelaySeconds.Equals(input.InitialDelaySeconds)) 98 ); 99 } 100 101 /// <summary> 102 /// Gets the hash code 103 /// </summary> 104 /// <returns>Hash code</returns> 105 public override int GetHashCode() 106 { 107 unchecked // Overflow is fine, just wrap 108 { 109 int hashCode = 41; 110 hashCode = hashCode * 59 + this.Disabled.GetHashCode(); 111 hashCode = hashCode * 59 + this.PeriodSeconds.GetHashCode(); 112 hashCode = hashCode * 59 + this.FailureThreshold.GetHashCode(); 113 hashCode = hashCode * 59 + this.InitialDelaySeconds.GetHashCode(); 114 return hashCode; 115 } 116 } 117 } 118 }