
software.amazon.awssdk.services.cloudfront.model.OriginGroup 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.cloudfront.model;
import java.io.Serializable;
import java.util.Arrays;
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 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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* An origin group includes two origins (a primary origin and a second origin to failover to) and a failover criteria
* that you specify. You create an origin group to support origin failover in CloudFront. When you create or update a
* distribution, you can specifiy the origin group instead of a single origin, and CloudFront will failover from the
* primary origin to the second origin under the failover conditions that you've chosen.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class OriginGroup implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Id")
.getter(getter(OriginGroup::id))
.setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").unmarshallLocationName("Id")
.build()).build();
private static final SdkField FAILOVER_CRITERIA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("FailoverCriteria")
.getter(getter(OriginGroup::failoverCriteria))
.setter(setter(Builder::failoverCriteria))
.constructor(OriginGroupFailoverCriteria::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FailoverCriteria")
.unmarshallLocationName("FailoverCriteria").build()).build();
private static final SdkField MEMBERS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("Members")
.getter(getter(OriginGroup::members))
.setter(setter(Builder::members))
.constructor(OriginGroupMembers::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Members")
.unmarshallLocationName("Members").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD,
FAILOVER_CRITERIA_FIELD, MEMBERS_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final OriginGroupFailoverCriteria failoverCriteria;
private final OriginGroupMembers members;
private OriginGroup(BuilderImpl builder) {
this.id = builder.id;
this.failoverCriteria = builder.failoverCriteria;
this.members = builder.members;
}
/**
*
* The origin group's ID.
*
*
* @return The origin group's ID.
*/
public final String id() {
return id;
}
/**
*
* A complex type that contains information about the failover criteria for an origin group.
*
*
* @return A complex type that contains information about the failover criteria for an origin group.
*/
public final OriginGroupFailoverCriteria failoverCriteria() {
return failoverCriteria;
}
/**
*
* A complex type that contains information about the origins in an origin group.
*
*
* @return A complex type that contains information about the origins in an origin group.
*/
public final OriginGroupMembers members() {
return members;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(failoverCriteria());
hashCode = 31 * hashCode + Objects.hashCode(members());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof OriginGroup)) {
return false;
}
OriginGroup other = (OriginGroup) obj;
return Objects.equals(id(), other.id()) && Objects.equals(failoverCriteria(), other.failoverCriteria())
&& Objects.equals(members(), other.members());
}
/**
* 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 final String toString() {
return ToString.builder("OriginGroup").add("Id", id()).add("FailoverCriteria", failoverCriteria())
.add("Members", members()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "FailoverCriteria":
return Optional.ofNullable(clazz.cast(failoverCriteria()));
case "Members":
return Optional.ofNullable(clazz.cast(members()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy