
software.amazon.awssdk.services.gamelift.model.GameSessionConnectionInfo Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.gamelift.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Connection information for the new game session that is created with matchmaking. (with StartMatchmaking).
* Once a match is set, the FlexMatch engine places the match and creates a new game session for it. This information,
* including the game session endpoint and player sessions for each player in the original matchmaking request, is added
* to the MatchmakingTicket, which can be retrieved by calling DescribeMatchmaking.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class GameSessionConnectionInfo implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField GAME_SESSION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(GameSessionConnectionInfo::gameSessionArn)).setter(setter(Builder::gameSessionArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GameSessionArn").build()).build();
private static final SdkField IP_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(GameSessionConnectionInfo::ipAddress)).setter(setter(Builder::ipAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IpAddress").build()).build();
private static final SdkField DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(GameSessionConnectionInfo::dnsName)).setter(setter(Builder::dnsName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DnsName").build()).build();
private static final SdkField PORT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(GameSessionConnectionInfo::port)).setter(setter(Builder::port))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Port").build()).build();
private static final SdkField> MATCHED_PLAYER_SESSIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(GameSessionConnectionInfo::matchedPlayerSessions))
.setter(setter(Builder::matchedPlayerSessions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MatchedPlayerSessions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(MatchedPlayerSession::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(GAME_SESSION_ARN_FIELD,
IP_ADDRESS_FIELD, DNS_NAME_FIELD, PORT_FIELD, MATCHED_PLAYER_SESSIONS_FIELD));
private static final long serialVersionUID = 1L;
private final String gameSessionArn;
private final String ipAddress;
private final String dnsName;
private final Integer port;
private final List matchedPlayerSessions;
private GameSessionConnectionInfo(BuilderImpl builder) {
this.gameSessionArn = builder.gameSessionArn;
this.ipAddress = builder.ipAddress;
this.dnsName = builder.dnsName;
this.port = builder.port;
this.matchedPlayerSessions = builder.matchedPlayerSessions;
}
/**
*
* Amazon Resource Name (ARN) that is assigned to a
* game session and uniquely identifies it.
*
*
* @return Amazon Resource Name (ARN) that is
* assigned to a game session and uniquely identifies it.
*/
public String gameSessionArn() {
return gameSessionArn;
}
/**
*
* IP address of the instance that is running the game session. When connecting to a Amazon GameLift game server, a
* client needs to reference an IP address (or DNS name) and port number.
*
*
* @return IP address of the instance that is running the game session. When connecting to a Amazon GameLift game
* server, a client needs to reference an IP address (or DNS name) and port number.
*/
public String ipAddress() {
return ipAddress;
}
/**
*
* DNS identifier assigned to the instance that is running the game session. Values have the following format:
*
*
* -
*
* TLS-enabled fleets: <unique identifier>.<region identifier>.amazongamelift.com
.
*
*
* -
*
* Non-TLS-enabled fleets: ec2-<unique identifier>.compute.amazonaws.com
. (See Amazon EC2 Instance IP Addressing.)
*
*
*
*
* When connecting to a game session that is running on a TLS-enabled fleet, you must use the DNS name, not the IP
* address.
*
*
* @return DNS identifier assigned to the instance that is running the game session. Values have the following
* format:
*
* -
*
* TLS-enabled fleets: <unique identifier>.<region identifier>.amazongamelift.com
.
*
*
* -
*
* Non-TLS-enabled fleets: ec2-<unique identifier>.compute.amazonaws.com
. (See Amazon EC2 Instance IP Addressing.)
*
*
*
*
* When connecting to a game session that is running on a TLS-enabled fleet, you must use the DNS name, not
* the IP address.
*/
public String dnsName() {
return dnsName;
}
/**
*
* Port number for the game session. To connect to a Amazon GameLift game server, an app needs both the IP address
* and port number.
*
*
* @return Port number for the game session. To connect to a Amazon GameLift game server, an app needs both the IP
* address and port number.
*/
public Integer port() {
return port;
}
/**
* Returns true if the MatchedPlayerSessions property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasMatchedPlayerSessions() {
return matchedPlayerSessions != null && !(matchedPlayerSessions instanceof SdkAutoConstructList);
}
/**
*
* A collection of player session IDs, one for each player ID that was included in the original matchmaking request.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasMatchedPlayerSessions()} to see if a value was sent in this field.
*
*
* @return A collection of player session IDs, one for each player ID that was included in the original matchmaking
* request.
*/
public List matchedPlayerSessions() {
return matchedPlayerSessions;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(gameSessionArn());
hashCode = 31 * hashCode + Objects.hashCode(ipAddress());
hashCode = 31 * hashCode + Objects.hashCode(dnsName());
hashCode = 31 * hashCode + Objects.hashCode(port());
hashCode = 31 * hashCode + Objects.hashCode(matchedPlayerSessions());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GameSessionConnectionInfo)) {
return false;
}
GameSessionConnectionInfo other = (GameSessionConnectionInfo) obj;
return Objects.equals(gameSessionArn(), other.gameSessionArn()) && Objects.equals(ipAddress(), other.ipAddress())
&& Objects.equals(dnsName(), other.dnsName()) && Objects.equals(port(), other.port())
&& Objects.equals(matchedPlayerSessions(), other.matchedPlayerSessions());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("GameSessionConnectionInfo").add("GameSessionArn", gameSessionArn())
.add("IpAddress", ipAddress()).add("DnsName", dnsName()).add("Port", port())
.add("MatchedPlayerSessions", matchedPlayerSessions()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "GameSessionArn":
return Optional.ofNullable(clazz.cast(gameSessionArn()));
case "IpAddress":
return Optional.ofNullable(clazz.cast(ipAddress()));
case "DnsName":
return Optional.ofNullable(clazz.cast(dnsName()));
case "Port":
return Optional.ofNullable(clazz.cast(port()));
case "MatchedPlayerSessions":
return Optional.ofNullable(clazz.cast(matchedPlayerSessions()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function