All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudfoundry.client.lib.domain.ImmutableSecurityGroupRule Maven / Gradle / Ivy

The newest version!
package org.cloudfoundry.client.lib.domain;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.client.lib.domain.annotation.Nullable;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link SecurityGroupRule}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableSecurityGroupRule.builder()}. */ @Generated(from = "SecurityGroupRule", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableSecurityGroupRule implements SecurityGroupRule { private final String protocol; private final String ports; private final String destination; private final @Nullable Boolean log; private final @Nullable Integer type; private final @Nullable Integer code; private ImmutableSecurityGroupRule( String protocol, String ports, String destination, @Nullable Boolean log, @Nullable Integer type, @Nullable Integer code) { this.protocol = protocol; this.ports = ports; this.destination = destination; this.log = log; this.type = type; this.code = code; } /** * @return The value of the {@code protocol} attribute */ @JsonProperty("protocol") @Override public String getProtocol() { return protocol; } /** * @return The value of the {@code ports} attribute */ @JsonProperty("ports") @Override public String getPorts() { return ports; } /** * @return The value of the {@code destination} attribute */ @JsonProperty("destination") @Override public String getDestination() { return destination; } /** * @return The value of the {@code log} attribute */ @JsonProperty("log") @Override public @Nullable Boolean getLog() { return log; } /** * @return The value of the {@code type} attribute */ @JsonProperty("type") @Override public @Nullable Integer getType() { return type; } /** * @return The value of the {@code code} attribute */ @JsonProperty("code") @Override public @Nullable Integer getCode() { return code; } /** * Copy the current immutable object by setting a value for the {@link SecurityGroupRule#getProtocol() protocol} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for protocol * @return A modified copy of the {@code this} object */ public final ImmutableSecurityGroupRule withProtocol(String value) { String newValue = Objects.requireNonNull(value, "protocol"); if (this.protocol.equals(newValue)) return this; return new ImmutableSecurityGroupRule(newValue, this.ports, this.destination, this.log, this.type, this.code); } /** * Copy the current immutable object by setting a value for the {@link SecurityGroupRule#getPorts() ports} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for ports * @return A modified copy of the {@code this} object */ public final ImmutableSecurityGroupRule withPorts(String value) { String newValue = Objects.requireNonNull(value, "ports"); if (this.ports.equals(newValue)) return this; return new ImmutableSecurityGroupRule(this.protocol, newValue, this.destination, this.log, this.type, this.code); } /** * Copy the current immutable object by setting a value for the {@link SecurityGroupRule#getDestination() destination} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for destination * @return A modified copy of the {@code this} object */ public final ImmutableSecurityGroupRule withDestination(String value) { String newValue = Objects.requireNonNull(value, "destination"); if (this.destination.equals(newValue)) return this; return new ImmutableSecurityGroupRule(this.protocol, this.ports, newValue, this.log, this.type, this.code); } /** * Copy the current immutable object by setting a value for the {@link SecurityGroupRule#getLog() log} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for log (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableSecurityGroupRule withLog(@Nullable Boolean value) { if (Objects.equals(this.log, value)) return this; return new ImmutableSecurityGroupRule(this.protocol, this.ports, this.destination, value, this.type, this.code); } /** * Copy the current immutable object by setting a value for the {@link SecurityGroupRule#getType() type} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for type (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableSecurityGroupRule withType(@Nullable Integer value) { if (Objects.equals(this.type, value)) return this; return new ImmutableSecurityGroupRule(this.protocol, this.ports, this.destination, this.log, value, this.code); } /** * Copy the current immutable object by setting a value for the {@link SecurityGroupRule#getCode() code} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for code (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableSecurityGroupRule withCode(@Nullable Integer value) { if (Objects.equals(this.code, value)) return this; return new ImmutableSecurityGroupRule(this.protocol, this.ports, this.destination, this.log, this.type, value); } /** * This instance is equal to all instances of {@code ImmutableSecurityGroupRule} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof ImmutableSecurityGroupRule && equalTo((ImmutableSecurityGroupRule) another); } private boolean equalTo(ImmutableSecurityGroupRule another) { return protocol.equals(another.protocol) && ports.equals(another.ports) && destination.equals(another.destination) && Objects.equals(log, another.log) && Objects.equals(type, another.type) && Objects.equals(code, another.code); } /** * Computes a hash code from attributes: {@code protocol}, {@code ports}, {@code destination}, {@code log}, {@code type}, {@code code}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + protocol.hashCode(); h += (h << 5) + ports.hashCode(); h += (h << 5) + destination.hashCode(); h += (h << 5) + Objects.hashCode(log); h += (h << 5) + Objects.hashCode(type); h += (h << 5) + Objects.hashCode(code); return h; } /** * Prints the immutable value {@code SecurityGroupRule} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "SecurityGroupRule{" + "protocol=" + protocol + ", ports=" + ports + ", destination=" + destination + ", log=" + log + ", type=" + type + ", code=" + code + "}"; } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "SecurityGroupRule", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements SecurityGroupRule { String protocol; String ports; String destination; Boolean log; Integer type; Integer code; @JsonProperty("protocol") public void setProtocol(String protocol) { this.protocol = protocol; } @JsonProperty("ports") public void setPorts(String ports) { this.ports = ports; } @JsonProperty("destination") public void setDestination(String destination) { this.destination = destination; } @JsonProperty("log") public void setLog(@Nullable Boolean log) { this.log = log; } @JsonProperty("type") public void setType(@Nullable Integer type) { this.type = type; } @JsonProperty("code") public void setCode(@Nullable Integer code) { this.code = code; } @Override public String getProtocol() { throw new UnsupportedOperationException(); } @Override public String getPorts() { throw new UnsupportedOperationException(); } @Override public String getDestination() { throw new UnsupportedOperationException(); } @Override public Boolean getLog() { throw new UnsupportedOperationException(); } @Override public Integer getType() { throw new UnsupportedOperationException(); } @Override public Integer getCode() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableSecurityGroupRule fromJson(Json json) { ImmutableSecurityGroupRule.Builder builder = ImmutableSecurityGroupRule.builder(); if (json.protocol != null) { builder.protocol(json.protocol); } if (json.ports != null) { builder.ports(json.ports); } if (json.destination != null) { builder.destination(json.destination); } if (json.log != null) { builder.log(json.log); } if (json.type != null) { builder.type(json.type); } if (json.code != null) { builder.code(json.code); } return builder.build(); } /** * Creates an immutable copy of a {@link SecurityGroupRule} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable SecurityGroupRule instance */ public static ImmutableSecurityGroupRule copyOf(SecurityGroupRule instance) { if (instance instanceof ImmutableSecurityGroupRule) { return (ImmutableSecurityGroupRule) instance; } return ImmutableSecurityGroupRule.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableSecurityGroupRule ImmutableSecurityGroupRule}. *

   * ImmutableSecurityGroupRule.builder()
   *    .protocol(String) // required {@link SecurityGroupRule#getProtocol() protocol}
   *    .ports(String) // required {@link SecurityGroupRule#getPorts() ports}
   *    .destination(String) // required {@link SecurityGroupRule#getDestination() destination}
   *    .log(Boolean | null) // nullable {@link SecurityGroupRule#getLog() log}
   *    .type(Integer | null) // nullable {@link SecurityGroupRule#getType() type}
   *    .code(Integer | null) // nullable {@link SecurityGroupRule#getCode() code}
   *    .build();
   * 
* @return A new ImmutableSecurityGroupRule builder */ public static ImmutableSecurityGroupRule.Builder builder() { return new ImmutableSecurityGroupRule.Builder(); } /** * Builds instances of type {@link ImmutableSecurityGroupRule ImmutableSecurityGroupRule}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "SecurityGroupRule", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_PROTOCOL = 0x1L; private static final long INIT_BIT_PORTS = 0x2L; private static final long INIT_BIT_DESTINATION = 0x4L; private long initBits = 0x7L; private String protocol; private String ports; private String destination; private Boolean log; private Integer type; private Integer code; private Builder() { } /** * Fill a builder with attribute values from the provided {@code SecurityGroupRule} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(SecurityGroupRule instance) { Objects.requireNonNull(instance, "instance"); protocol(instance.getProtocol()); ports(instance.getPorts()); destination(instance.getDestination()); @Nullable Boolean logValue = instance.getLog(); if (logValue != null) { log(logValue); } @Nullable Integer typeValue = instance.getType(); if (typeValue != null) { type(typeValue); } @Nullable Integer codeValue = instance.getCode(); if (codeValue != null) { code(codeValue); } return this; } /** * Initializes the value for the {@link SecurityGroupRule#getProtocol() protocol} attribute. * @param protocol The value for protocol * @return {@code this} builder for use in a chained invocation */ @JsonProperty("protocol") public final Builder protocol(String protocol) { this.protocol = Objects.requireNonNull(protocol, "protocol"); initBits &= ~INIT_BIT_PROTOCOL; return this; } /** * Initializes the value for the {@link SecurityGroupRule#getPorts() ports} attribute. * @param ports The value for ports * @return {@code this} builder for use in a chained invocation */ @JsonProperty("ports") public final Builder ports(String ports) { this.ports = Objects.requireNonNull(ports, "ports"); initBits &= ~INIT_BIT_PORTS; return this; } /** * Initializes the value for the {@link SecurityGroupRule#getDestination() destination} attribute. * @param destination The value for destination * @return {@code this} builder for use in a chained invocation */ @JsonProperty("destination") public final Builder destination(String destination) { this.destination = Objects.requireNonNull(destination, "destination"); initBits &= ~INIT_BIT_DESTINATION; return this; } /** * Initializes the value for the {@link SecurityGroupRule#getLog() log} attribute. * @param log The value for log (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("log") public final Builder log(@Nullable Boolean log) { this.log = log; return this; } /** * Initializes the value for the {@link SecurityGroupRule#getType() type} attribute. * @param type The value for type (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("type") public final Builder type(@Nullable Integer type) { this.type = type; return this; } /** * Initializes the value for the {@link SecurityGroupRule#getCode() code} attribute. * @param code The value for code (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("code") public final Builder code(@Nullable Integer code) { this.code = code; return this; } /** * Builds a new {@link ImmutableSecurityGroupRule ImmutableSecurityGroupRule}. * @return An immutable instance of SecurityGroupRule * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableSecurityGroupRule build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableSecurityGroupRule(protocol, ports, destination, log, type, code); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_PROTOCOL) != 0) attributes.add("protocol"); if ((initBits & INIT_BIT_PORTS) != 0) attributes.add("ports"); if ((initBits & INIT_BIT_DESTINATION) != 0) attributes.add("destination"); return "Cannot build SecurityGroupRule, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy