agones.dev/agones@v1.53.0/sdks/unity/model/StatusAddresses.cs (about)

     1  // Copyright 2024 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    /// StatusAddresses represents an address with a specific type.
    24    /// </summary>
    25    public class StatusAddresses : IEquatable<StatusAddresses>
    26    {
    27      /// <summary>
    28      /// Initializes a new instance of the <see cref="StatusAddresses" /> class.
    29      /// </summary>
    30      /// <param name="data">The data dictionary containing the address and type.</param>
    31      public StatusAddresses(IReadOnlyDictionary<string, object> data)
    32      {
    33        this.Address = (string)data["address"];
    34        this.Type = (string)data["type"];
    35      }
    36  
    37      public string Address { get; }
    38      public string Type { get; }
    39  
    40      /// <summary>
    41      /// Returns the string presentation of the object
    42      /// </summary>
    43      /// <returns>String presentation of the object</returns>
    44      public override string ToString()
    45      {
    46        var sb = new StringBuilder();
    47        sb.Append("class StatusAddresses {\n");
    48        sb.Append("  Address: ").Append(Address).Append("\n");
    49        sb.Append("  Type: ").Append(Type).Append("\n");
    50        sb.Append("}\n");
    51        return sb.ToString();
    52      }
    53  
    54      /// <summary>
    55      /// Returns true if objects are equal
    56      /// </summary>
    57      /// <param name="input">Object to be compared</param>
    58      /// <returns>Boolean</returns>
    59      public override bool Equals(object input)
    60      {
    61        return this.Equals(input as StatusAddresses);
    62      }
    63  
    64      /// <summary>
    65      /// Returns true if StatusAddresses instances are equal
    66      /// </summary>
    67      /// <param name="input">Instance of StatusAddresses to be compared</param>
    68      /// <returns>Boolean</returns>
    69      public bool Equals(StatusAddresses input)
    70      {
    71        if (input == null)
    72          return false;
    73  
    74        return
    75            (
    76                this.Address == input.Address ||
    77                (this.Address != null &&
    78                 this.Address.Equals(input.Address))
    79            ) &&
    80            (
    81                this.Type == input.Type ||
    82                (this.Type != null &&
    83                 this.Type.Equals(input.Type))
    84            );
    85      }
    86  
    87      /// <summary>
    88      /// Gets the hash code
    89      /// </summary>
    90      /// <returns>Hash code</returns>
    91      public override int GetHashCode()
    92      {
    93        unchecked // Overflow is fine, just wrap
    94        {
    95          int hashCode = 41;
    96          if (this.Address != null)
    97            hashCode = hashCode * 59 + this.Address.GetHashCode();
    98          if (this.Type != null)
    99            hashCode = hashCode * 59 + this.Type.GetHashCode();
   100          return hashCode;
   101        }
   102      }
   103    }
   104  }