software.amazon.awssdk.services.devicefarm.model.Rule 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.devicefarm.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.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;
/**
*
* Represents a condition for a device pool.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Rule implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ATTRIBUTE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("attribute").getter(getter(Rule::attributeAsString)).setter(setter(Builder::attribute))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("attribute").build()).build();
private static final SdkField OPERATOR_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("operator").getter(getter(Rule::operatorAsString)).setter(setter(Builder::operator))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("operator").build()).build();
private static final SdkField VALUE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("value")
.getter(getter(Rule::value)).setter(setter(Builder::value))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("value").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTRIBUTE_FIELD,
OPERATOR_FIELD, VALUE_FIELD));
private static final long serialVersionUID = 1L;
private final String attribute;
private final String operator;
private final String value;
private Rule(BuilderImpl builder) {
this.attribute = builder.attribute;
this.operator = builder.operator;
this.value = builder.value;
}
/**
*
* The rule's stringified attribute. For example, specify the value as "\"abc\""
.
*
*
* The supported operators for each attribute are provided in the following list.
*
*
* - APPIUM_VERSION
* -
*
* The Appium version for the test.
*
*
* Supported operators: CONTAINS
*
*
* - ARN
* -
*
* The Amazon Resource Name (ARN) of the device (for example,
* arn:aws:devicefarm:us-west-2::device:12345Example
.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - AVAILABILITY
* -
*
* The current availability of the device. Valid values are AVAILABLE, HIGHLY_AVAILABLE, BUSY, or
* TEMPORARY_NOT_AVAILABLE.
*
*
* Supported operators: EQUALS
*
*
* - FLEET_TYPE
* -
*
* The fleet type. Valid values are PUBLIC or PRIVATE.
*
*
* Supported operators: EQUALS
*
*
* - FORM_FACTOR
* -
*
* The device form factor. Valid values are PHONE or TABLET.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - INSTANCE_ARN
* -
*
* The Amazon Resource Name (ARN) of the device instance.
*
*
* Supported operators: IN
, NOT_IN
*
*
* - INSTANCE_LABELS
* -
*
* The label of the device instance.
*
*
* Supported operators: CONTAINS
*
*
* - MANUFACTURER
* -
*
* The device manufacturer (for example, Apple).
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - MODEL
* -
*
* The device model, such as Apple iPad Air 2 or Google Pixel.
*
*
* Supported operators: CONTAINS
, EQUALS
, IN
, NOT_IN
*
*
* - OS_VERSION
* -
*
* The operating system version (for example, 10.3.2).
*
*
* Supported operators: EQUALS
, GREATER_THAN
, GREATER_THAN_OR_EQUALS
,
* IN
, LESS_THAN
, LESS_THAN_OR_EQUALS
, NOT_IN
*
*
* - PLATFORM
* -
*
* The device platform. Valid values are ANDROID or IOS.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - REMOTE_ACCESS_ENABLED
* -
*
* Whether the device is enabled for remote access. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* - REMOTE_DEBUG_ENABLED
* -
*
* Whether the device is enabled for remote debugging. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* Because remote debugging is no longer supported, this
* filter is ignored.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #attribute} will
* return {@link DeviceAttribute#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #attributeAsString}.
*
*
* @return The rule's stringified attribute. For example, specify the value as "\"abc\""
.
*
* The supported operators for each attribute are provided in the following list.
*
*
* - APPIUM_VERSION
* -
*
* The Appium version for the test.
*
*
* Supported operators: CONTAINS
*
*
* - ARN
* -
*
* The Amazon Resource Name (ARN) of the device (for example,
* arn:aws:devicefarm:us-west-2::device:12345Example
.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - AVAILABILITY
* -
*
* The current availability of the device. Valid values are AVAILABLE, HIGHLY_AVAILABLE, BUSY, or
* TEMPORARY_NOT_AVAILABLE.
*
*
* Supported operators: EQUALS
*
*
* - FLEET_TYPE
* -
*
* The fleet type. Valid values are PUBLIC or PRIVATE.
*
*
* Supported operators: EQUALS
*
*
* - FORM_FACTOR
* -
*
* The device form factor. Valid values are PHONE or TABLET.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - INSTANCE_ARN
* -
*
* The Amazon Resource Name (ARN) of the device instance.
*
*
* Supported operators: IN
, NOT_IN
*
*
* - INSTANCE_LABELS
* -
*
* The label of the device instance.
*
*
* Supported operators: CONTAINS
*
*
* - MANUFACTURER
* -
*
* The device manufacturer (for example, Apple).
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - MODEL
* -
*
* The device model, such as Apple iPad Air 2 or Google Pixel.
*
*
* Supported operators: CONTAINS
, EQUALS
, IN
, NOT_IN
*
*
* - OS_VERSION
* -
*
* The operating system version (for example, 10.3.2).
*
*
* Supported operators: EQUALS
, GREATER_THAN
, GREATER_THAN_OR_EQUALS
,
* IN
, LESS_THAN
, LESS_THAN_OR_EQUALS
, NOT_IN
*
*
* - PLATFORM
* -
*
* The device platform. Valid values are ANDROID or IOS.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - REMOTE_ACCESS_ENABLED
* -
*
* Whether the device is enabled for remote access. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* - REMOTE_DEBUG_ENABLED
* -
*
* Whether the device is enabled for remote debugging. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* Because remote debugging is no longer supported,
* this filter is ignored.
*
*
* @see DeviceAttribute
*/
public final DeviceAttribute attribute() {
return DeviceAttribute.fromValue(attribute);
}
/**
*
* The rule's stringified attribute. For example, specify the value as "\"abc\""
.
*
*
* The supported operators for each attribute are provided in the following list.
*
*
* - APPIUM_VERSION
* -
*
* The Appium version for the test.
*
*
* Supported operators: CONTAINS
*
*
* - ARN
* -
*
* The Amazon Resource Name (ARN) of the device (for example,
* arn:aws:devicefarm:us-west-2::device:12345Example
.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - AVAILABILITY
* -
*
* The current availability of the device. Valid values are AVAILABLE, HIGHLY_AVAILABLE, BUSY, or
* TEMPORARY_NOT_AVAILABLE.
*
*
* Supported operators: EQUALS
*
*
* - FLEET_TYPE
* -
*
* The fleet type. Valid values are PUBLIC or PRIVATE.
*
*
* Supported operators: EQUALS
*
*
* - FORM_FACTOR
* -
*
* The device form factor. Valid values are PHONE or TABLET.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - INSTANCE_ARN
* -
*
* The Amazon Resource Name (ARN) of the device instance.
*
*
* Supported operators: IN
, NOT_IN
*
*
* - INSTANCE_LABELS
* -
*
* The label of the device instance.
*
*
* Supported operators: CONTAINS
*
*
* - MANUFACTURER
* -
*
* The device manufacturer (for example, Apple).
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - MODEL
* -
*
* The device model, such as Apple iPad Air 2 or Google Pixel.
*
*
* Supported operators: CONTAINS
, EQUALS
, IN
, NOT_IN
*
*
* - OS_VERSION
* -
*
* The operating system version (for example, 10.3.2).
*
*
* Supported operators: EQUALS
, GREATER_THAN
, GREATER_THAN_OR_EQUALS
,
* IN
, LESS_THAN
, LESS_THAN_OR_EQUALS
, NOT_IN
*
*
* - PLATFORM
* -
*
* The device platform. Valid values are ANDROID or IOS.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - REMOTE_ACCESS_ENABLED
* -
*
* Whether the device is enabled for remote access. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* - REMOTE_DEBUG_ENABLED
* -
*
* Whether the device is enabled for remote debugging. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* Because remote debugging is no longer supported, this
* filter is ignored.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #attribute} will
* return {@link DeviceAttribute#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #attributeAsString}.
*
*
* @return The rule's stringified attribute. For example, specify the value as "\"abc\""
.
*
* The supported operators for each attribute are provided in the following list.
*
*
* - APPIUM_VERSION
* -
*
* The Appium version for the test.
*
*
* Supported operators: CONTAINS
*
*
* - ARN
* -
*
* The Amazon Resource Name (ARN) of the device (for example,
* arn:aws:devicefarm:us-west-2::device:12345Example
.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - AVAILABILITY
* -
*
* The current availability of the device. Valid values are AVAILABLE, HIGHLY_AVAILABLE, BUSY, or
* TEMPORARY_NOT_AVAILABLE.
*
*
* Supported operators: EQUALS
*
*
* - FLEET_TYPE
* -
*
* The fleet type. Valid values are PUBLIC or PRIVATE.
*
*
* Supported operators: EQUALS
*
*
* - FORM_FACTOR
* -
*
* The device form factor. Valid values are PHONE or TABLET.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - INSTANCE_ARN
* -
*
* The Amazon Resource Name (ARN) of the device instance.
*
*
* Supported operators: IN
, NOT_IN
*
*
* - INSTANCE_LABELS
* -
*
* The label of the device instance.
*
*
* Supported operators: CONTAINS
*
*
* - MANUFACTURER
* -
*
* The device manufacturer (for example, Apple).
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - MODEL
* -
*
* The device model, such as Apple iPad Air 2 or Google Pixel.
*
*
* Supported operators: CONTAINS
, EQUALS
, IN
, NOT_IN
*
*
* - OS_VERSION
* -
*
* The operating system version (for example, 10.3.2).
*
*
* Supported operators: EQUALS
, GREATER_THAN
, GREATER_THAN_OR_EQUALS
,
* IN
, LESS_THAN
, LESS_THAN_OR_EQUALS
, NOT_IN
*
*
* - PLATFORM
* -
*
* The device platform. Valid values are ANDROID or IOS.
*
*
* Supported operators: EQUALS
, IN
, NOT_IN
*
*
* - REMOTE_ACCESS_ENABLED
* -
*
* Whether the device is enabled for remote access. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* - REMOTE_DEBUG_ENABLED
* -
*
* Whether the device is enabled for remote debugging. Valid values are TRUE or FALSE.
*
*
* Supported operators: EQUALS
*
*
* Because remote debugging is no longer supported,
* this filter is ignored.
*
*
* @see DeviceAttribute
*/
public final String attributeAsString() {
return attribute;
}
/**
*
* Specifies how Device Farm compares the rule's attribute to the value. For the operators that are supported by
* each attribute, see the attribute descriptions.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #operator} will
* return {@link RuleOperator#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #operatorAsString}.
*
*
* @return Specifies how Device Farm compares the rule's attribute to the value. For the operators that are
* supported by each attribute, see the attribute descriptions.
* @see RuleOperator
*/
public final RuleOperator operator() {
return RuleOperator.fromValue(operator);
}
/**
*
* Specifies how Device Farm compares the rule's attribute to the value. For the operators that are supported by
* each attribute, see the attribute descriptions.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #operator} will
* return {@link RuleOperator#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #operatorAsString}.
*
*
* @return Specifies how Device Farm compares the rule's attribute to the value. For the operators that are
* supported by each attribute, see the attribute descriptions.
* @see RuleOperator
*/
public final String operatorAsString() {
return operator;
}
/**
*
* The rule's value.
*
*
* @return The rule's value.
*/
public final String value() {
return value;
}
@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(attributeAsString());
hashCode = 31 * hashCode + Objects.hashCode(operatorAsString());
hashCode = 31 * hashCode + Objects.hashCode(value());
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 Rule)) {
return false;
}
Rule other = (Rule) obj;
return Objects.equals(attributeAsString(), other.attributeAsString())
&& Objects.equals(operatorAsString(), other.operatorAsString()) && Objects.equals(value(), other.value());
}
/**
* 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("Rule").add("Attribute", attributeAsString()).add("Operator", operatorAsString())
.add("Value", value()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "attribute":
return Optional.ofNullable(clazz.cast(attributeAsString()));
case "operator":
return Optional.ofNullable(clazz.cast(operatorAsString()));
case "value":
return Optional.ofNullable(clazz.cast(value()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function