software.amazon.awssdk.services.fms.model.EntryViolation Maven / Gradle / Ivy
Show all versions of fms Show documentation
/*
* 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.fms.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* Detailed information about an entry violation in a network ACL. The violation is against the network ACL
* specification inside the Firewall Manager network ACL policy. This data object is part of
* InvalidNetworkAclEntriesViolation
.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EntryViolation implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField EXPECTED_ENTRY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ExpectedEntry")
.getter(getter(EntryViolation::expectedEntry)).setter(setter(Builder::expectedEntry))
.constructor(EntryDescription::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpectedEntry").build()).build();
private static final SdkField EXPECTED_EVALUATION_ORDER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ExpectedEvaluationOrder").getter(getter(EntryViolation::expectedEvaluationOrder))
.setter(setter(Builder::expectedEvaluationOrder))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpectedEvaluationOrder").build())
.build();
private static final SdkField ACTUAL_EVALUATION_ORDER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ActualEvaluationOrder").getter(getter(EntryViolation::actualEvaluationOrder))
.setter(setter(Builder::actualEvaluationOrder))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActualEvaluationOrder").build())
.build();
private static final SdkField ENTRY_AT_EXPECTED_EVALUATION_ORDER_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("EntryAtExpectedEvaluationOrder")
.getter(getter(EntryViolation::entryAtExpectedEvaluationOrder))
.setter(setter(Builder::entryAtExpectedEvaluationOrder))
.constructor(EntryDescription::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EntryAtExpectedEvaluationOrder")
.build()).build();
private static final SdkField> ENTRIES_WITH_CONFLICTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EntriesWithConflicts")
.getter(getter(EntryViolation::entriesWithConflicts))
.setter(setter(Builder::entriesWithConflicts))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EntriesWithConflicts").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(EntryDescription::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> ENTRY_VIOLATION_REASONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EntryViolationReasons")
.getter(getter(EntryViolation::entryViolationReasonsAsStrings))
.setter(setter(Builder::entryViolationReasonsWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EntryViolationReasons").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EXPECTED_ENTRY_FIELD,
EXPECTED_EVALUATION_ORDER_FIELD, ACTUAL_EVALUATION_ORDER_FIELD, ENTRY_AT_EXPECTED_EVALUATION_ORDER_FIELD,
ENTRIES_WITH_CONFLICTS_FIELD, ENTRY_VIOLATION_REASONS_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("ExpectedEntry", EXPECTED_ENTRY_FIELD);
put("ExpectedEvaluationOrder", EXPECTED_EVALUATION_ORDER_FIELD);
put("ActualEvaluationOrder", ACTUAL_EVALUATION_ORDER_FIELD);
put("EntryAtExpectedEvaluationOrder", ENTRY_AT_EXPECTED_EVALUATION_ORDER_FIELD);
put("EntriesWithConflicts", ENTRIES_WITH_CONFLICTS_FIELD);
put("EntryViolationReasons", ENTRY_VIOLATION_REASONS_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final EntryDescription expectedEntry;
private final String expectedEvaluationOrder;
private final String actualEvaluationOrder;
private final EntryDescription entryAtExpectedEvaluationOrder;
private final List entriesWithConflicts;
private final List entryViolationReasons;
private EntryViolation(BuilderImpl builder) {
this.expectedEntry = builder.expectedEntry;
this.expectedEvaluationOrder = builder.expectedEvaluationOrder;
this.actualEvaluationOrder = builder.actualEvaluationOrder;
this.entryAtExpectedEvaluationOrder = builder.entryAtExpectedEvaluationOrder;
this.entriesWithConflicts = builder.entriesWithConflicts;
this.entryViolationReasons = builder.entryViolationReasons;
}
/**
*
* The Firewall Manager-managed network ACL entry that is involved in the entry violation.
*
*
* @return The Firewall Manager-managed network ACL entry that is involved in the entry violation.
*/
public final EntryDescription expectedEntry() {
return expectedEntry;
}
/**
*
* The evaluation location within the ordered list of entries where the ExpectedEntry
should be,
* according to the network ACL policy specifications.
*
*
* @return The evaluation location within the ordered list of entries where the ExpectedEntry
should
* be, according to the network ACL policy specifications.
*/
public final String expectedEvaluationOrder() {
return expectedEvaluationOrder;
}
/**
*
* The evaluation location within the ordered list of entries where the ExpectedEntry
is currently
* located.
*
*
* @return The evaluation location within the ordered list of entries where the ExpectedEntry
is
* currently located.
*/
public final String actualEvaluationOrder() {
return actualEvaluationOrder;
}
/**
*
* The entry that's currently in the ExpectedEvaluationOrder
location, in place of the expected entry.
*
*
* @return The entry that's currently in the ExpectedEvaluationOrder
location, in place of the expected
* entry.
*/
public final EntryDescription entryAtExpectedEvaluationOrder() {
return entryAtExpectedEvaluationOrder;
}
/**
* For responses, this returns true if the service returned a value for the EntriesWithConflicts property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasEntriesWithConflicts() {
return entriesWithConflicts != null && !(entriesWithConflicts instanceof SdkAutoConstructList);
}
/**
*
* The list of entries that are in conflict with ExpectedEntry
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasEntriesWithConflicts} method.
*
*
* @return The list of entries that are in conflict with ExpectedEntry
.
*/
public final List entriesWithConflicts() {
return entriesWithConflicts;
}
/**
*
* Descriptions of the violations that Firewall Manager found for these entries.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasEntryViolationReasons} method.
*
*
* @return Descriptions of the violations that Firewall Manager found for these entries.
*/
public final List entryViolationReasons() {
return EntryViolationReasonsCopier.copyStringToEnum(entryViolationReasons);
}
/**
* For responses, this returns true if the service returned a value for the EntryViolationReasons property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasEntryViolationReasons() {
return entryViolationReasons != null && !(entryViolationReasons instanceof SdkAutoConstructList);
}
/**
*
* Descriptions of the violations that Firewall Manager found for these entries.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasEntryViolationReasons} method.
*
*
* @return Descriptions of the violations that Firewall Manager found for these entries.
*/
public final List entryViolationReasonsAsStrings() {
return entryViolationReasons;
}
@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(expectedEntry());
hashCode = 31 * hashCode + Objects.hashCode(expectedEvaluationOrder());
hashCode = 31 * hashCode + Objects.hashCode(actualEvaluationOrder());
hashCode = 31 * hashCode + Objects.hashCode(entryAtExpectedEvaluationOrder());
hashCode = 31 * hashCode + Objects.hashCode(hasEntriesWithConflicts() ? entriesWithConflicts() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasEntryViolationReasons() ? entryViolationReasonsAsStrings() : null);
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 EntryViolation)) {
return false;
}
EntryViolation other = (EntryViolation) obj;
return Objects.equals(expectedEntry(), other.expectedEntry())
&& Objects.equals(expectedEvaluationOrder(), other.expectedEvaluationOrder())
&& Objects.equals(actualEvaluationOrder(), other.actualEvaluationOrder())
&& Objects.equals(entryAtExpectedEvaluationOrder(), other.entryAtExpectedEvaluationOrder())
&& hasEntriesWithConflicts() == other.hasEntriesWithConflicts()
&& Objects.equals(entriesWithConflicts(), other.entriesWithConflicts())
&& hasEntryViolationReasons() == other.hasEntryViolationReasons()
&& Objects.equals(entryViolationReasonsAsStrings(), other.entryViolationReasonsAsStrings());
}
/**
* 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("EntryViolation").add("ExpectedEntry", expectedEntry())
.add("ExpectedEvaluationOrder", expectedEvaluationOrder()).add("ActualEvaluationOrder", actualEvaluationOrder())
.add("EntryAtExpectedEvaluationOrder", entryAtExpectedEvaluationOrder())
.add("EntriesWithConflicts", hasEntriesWithConflicts() ? entriesWithConflicts() : null)
.add("EntryViolationReasons", hasEntryViolationReasons() ? entryViolationReasonsAsStrings() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ExpectedEntry":
return Optional.ofNullable(clazz.cast(expectedEntry()));
case "ExpectedEvaluationOrder":
return Optional.ofNullable(clazz.cast(expectedEvaluationOrder()));
case "ActualEvaluationOrder":
return Optional.ofNullable(clazz.cast(actualEvaluationOrder()));
case "EntryAtExpectedEvaluationOrder":
return Optional.ofNullable(clazz.cast(entryAtExpectedEvaluationOrder()));
case "EntriesWithConflicts":
return Optional.ofNullable(clazz.cast(entriesWithConflicts()));
case "EntryViolationReasons":
return Optional.ofNullable(clazz.cast(entryViolationReasonsAsStrings()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function