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

com.hubspot.slack.client.models.blocks.Image Maven / Gradle / Ivy

package com.hubspot.slack.client.models.blocks;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.blocks.objects.Text;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code Image.builder()}. * Use the static factory method to create immutable instances: * {@code Image.of()}. */ @Generated(from = "ImageIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class Image implements ImageIF { private final @Nullable String blockId; private transient final String type; private final @Nullable String imageUrl; private final String altText; private final @Nullable Text title; private final @Nullable SlackFileObject slackFile; private Image(Optional imageUrl, String altText) { this.imageUrl = imageUrl.orElse(null); this.altText = Objects.requireNonNull(altText, "altText"); this.blockId = null; this.title = null; this.slackFile = null; this.type = Objects.requireNonNull(ImageIF.super.getType(), "type"); } private Image(@Nullable String imageUrl, String altText) { this.imageUrl = imageUrl; this.altText = Objects.requireNonNull(altText, "altText"); this.blockId = null; this.title = null; this.slackFile = null; this.type = Objects.requireNonNull(ImageIF.super.getType(), "type"); } private Image( @Nullable String blockId, @Nullable String imageUrl, String altText, @Nullable Text title, @Nullable SlackFileObject slackFile) { this.blockId = blockId; this.imageUrl = imageUrl; this.altText = altText; this.title = title; this.slackFile = slackFile; this.type = Objects.requireNonNull(ImageIF.super.getType(), "type"); } /** * @return The value of the {@code blockId} attribute */ @JsonProperty @Override public Optional getBlockId() { return Optional.ofNullable(blockId); } /** * @return The computed-at-construction value of the {@code type} attribute */ @JsonProperty @Override public String getType() { return type; } /** * @return The value of the {@code imageUrl} attribute */ @JsonProperty @Override public Optional getImageUrl() { return Optional.ofNullable(imageUrl); } /** * @return The value of the {@code altText} attribute */ @JsonProperty @Override public String getAltText() { return altText; } /** * @return The value of the {@code title} attribute */ @JsonProperty @Override public Optional getTitle() { return Optional.ofNullable(title); } /** * @return The value of the {@code slackFile} attribute */ @JsonProperty @Override public Optional getSlackFile() { return Optional.ofNullable(slackFile); } /** * Copy the current immutable object by setting a present value for the optional {@link ImageIF#getBlockId() blockId} attribute. * @param value The value for blockId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Image withBlockId(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.blockId, newValue)) return this; return new Image(newValue, this.imageUrl, this.altText, this.title, this.slackFile); } /** * Copy the current immutable object by setting an optional value for the {@link ImageIF#getBlockId() blockId} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for blockId * @return A modified copy of {@code this} object */ public final Image withBlockId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.blockId, value)) return this; return new Image(value, this.imageUrl, this.altText, this.title, this.slackFile); } /** * Copy the current immutable object by setting a present value for the optional {@link ImageIF#getImageUrl() imageUrl} attribute. * @param value The value for imageUrl, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Image withImageUrl(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.imageUrl, newValue)) return this; return new Image(this.blockId, newValue, this.altText, this.title, this.slackFile); } /** * Copy the current immutable object by setting an optional value for the {@link ImageIF#getImageUrl() imageUrl} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for imageUrl * @return A modified copy of {@code this} object */ public final Image withImageUrl(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.imageUrl, value)) return this; return new Image(this.blockId, value, this.altText, this.title, this.slackFile); } /** * Copy the current immutable object by setting a value for the {@link ImageIF#getAltText() altText} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for altText * @return A modified copy of the {@code this} object */ public final Image withAltText(String value) { String newValue = Objects.requireNonNull(value, "altText"); if (this.altText.equals(newValue)) return this; return new Image(this.blockId, this.imageUrl, newValue, this.title, this.slackFile); } /** * Copy the current immutable object by setting a present value for the optional {@link ImageIF#getTitle() title} attribute. * @param value The value for title, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Image withTitle(@Nullable Text value) { @Nullable Text newValue = value; if (this.title == newValue) return this; return new Image(this.blockId, this.imageUrl, this.altText, newValue, this.slackFile); } /** * Copy the current immutable object by setting an optional value for the {@link ImageIF#getTitle() title} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for title * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Image withTitle(Optional optional) { @Nullable Text value = optional.orElse(null); if (this.title == value) return this; return new Image(this.blockId, this.imageUrl, this.altText, value, this.slackFile); } /** * Copy the current immutable object by setting a present value for the optional {@link ImageIF#getSlackFile() slackFile} attribute. * @param value The value for slackFile, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final Image withSlackFile(@Nullable SlackFileObject value) { @Nullable SlackFileObject newValue = value; if (this.slackFile == newValue) return this; return new Image(this.blockId, this.imageUrl, this.altText, this.title, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link ImageIF#getSlackFile() slackFile} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for slackFile * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final Image withSlackFile(Optional optional) { @Nullable SlackFileObject value = optional.orElse(null); if (this.slackFile == value) return this; return new Image(this.blockId, this.imageUrl, this.altText, this.title, value); } /** * This instance is equal to all instances of {@code Image} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof Image && equalTo(0, (Image) another); } private boolean equalTo(int synthetic, Image another) { return Objects.equals(blockId, another.blockId) && type.equals(another.type) && Objects.equals(imageUrl, another.imageUrl) && altText.equals(another.altText) && Objects.equals(title, another.title) && Objects.equals(slackFile, another.slackFile); } /** * Computes a hash code from attributes: {@code blockId}, {@code type}, {@code imageUrl}, {@code altText}, {@code title}, {@code slackFile}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(blockId); h += (h << 5) + type.hashCode(); h += (h << 5) + Objects.hashCode(imageUrl); h += (h << 5) + altText.hashCode(); h += (h << 5) + Objects.hashCode(title); h += (h << 5) + Objects.hashCode(slackFile); return h; } /** * Prints the immutable value {@code Image} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("Image{"); if (blockId != null) { builder.append("blockId=").append(blockId); } if (builder.length() > 6) builder.append(", "); builder.append("type=").append(type); if (imageUrl != null) { builder.append(", "); builder.append("imageUrl=").append(imageUrl); } builder.append(", "); builder.append("altText=").append(altText); if (title != null) { builder.append(", "); builder.append("title=").append(title); } if (slackFile != null) { builder.append(", "); builder.append("slackFile=").append(slackFile); } return builder.append("}").toString(); } /** * 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 = "ImageIF", generator = "Immutables") @Deprecated @JsonTypeInfo(use=JsonTypeInfo.Id.NONE) @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ImageIF { @Nullable Optional blockId = Optional.empty(); @Nullable Optional imageUrl = Optional.empty(); @Nullable String altText; @Nullable Optional title = Optional.empty(); @Nullable Optional slackFile = Optional.empty(); @JsonProperty public void setBlockId(Optional blockId) { this.blockId = blockId; } @JsonProperty public void setImageUrl(Optional imageUrl) { this.imageUrl = imageUrl; } @JsonProperty public void setAltText(String altText) { this.altText = altText; } @JsonProperty public void setTitle(Optional title) { this.title = title; } @JsonProperty public void setSlackFile(Optional slackFile) { this.slackFile = slackFile; } @Override public Optional getBlockId() { throw new UnsupportedOperationException(); } @JsonIgnore @Override public String getType() { throw new UnsupportedOperationException(); } @Override public Optional getImageUrl() { throw new UnsupportedOperationException(); } @Override public String getAltText() { throw new UnsupportedOperationException(); } @Override public Optional getTitle() { throw new UnsupportedOperationException(); } @Override public Optional getSlackFile() { 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 Image fromJson(Json json) { Image.Builder builder = Image.builder(); if (json.blockId != null) { builder.setBlockId(json.blockId); } if (json.imageUrl != null) { builder.setImageUrl(json.imageUrl); } if (json.altText != null) { builder.setAltText(json.altText); } if (json.title != null) { builder.setTitle(json.title); } if (json.slackFile != null) { builder.setSlackFile(json.slackFile); } return builder.build(); } /** * Construct a new immutable {@code Image} instance. * @param imageUrl The value for the {@code imageUrl} attribute * @param altText The value for the {@code altText} attribute * @return An immutable Image instance */ public static Image of(Optional imageUrl, String altText) { return new Image(imageUrl, altText); } /** * Construct a new immutable {@code Image} instance. * @param imageUrl The value for the {@code imageUrl} attribute * @param altText The value for the {@code altText} attribute * @return An immutable Image instance */ public static Image of(@Nullable String imageUrl, String altText) { return new Image(imageUrl, altText); } /** * Creates an immutable copy of a {@link ImageIF} 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 Image instance */ public static Image copyOf(ImageIF instance) { if (instance instanceof Image) { return (Image) instance; } return Image.builder() .from(instance) .build(); } /** * Creates a builder for {@link Image Image}. *

   * Image.builder()
   *    .setBlockId(String) // optional {@link ImageIF#getBlockId() blockId}
   *    .setImageUrl(String) // optional {@link ImageIF#getImageUrl() imageUrl}
   *    .setAltText(String) // required {@link ImageIF#getAltText() altText}
   *    .setTitle(com.hubspot.slack.client.models.blocks.objects.Text) // optional {@link ImageIF#getTitle() title}
   *    .setSlackFile(SlackFileObject) // optional {@link ImageIF#getSlackFile() slackFile}
   *    .build();
   * 
* @return A new Image builder */ public static Image.Builder builder() { return new Image.Builder(); } /** * Builds instances of type {@link Image Image}. * 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 = "ImageIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ALT_TEXT = 0x1L; private long initBits = 0x1L; private @Nullable String blockId; private @Nullable String imageUrl; private @Nullable String altText; private @Nullable Text title; private @Nullable SlackFileObject slackFile; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.blocks.ImageIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ImageIF instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.blocks.Block} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Block instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { long bits = 0; if (object instanceof ImageIF) { ImageIF instance = (ImageIF) object; if ((bits & 0x1L) == 0) { Optional blockIdOptional = instance.getBlockId(); if (blockIdOptional.isPresent()) { setBlockId(blockIdOptional); } bits |= 0x1L; } Optional slackFileOptional = instance.getSlackFile(); if (slackFileOptional.isPresent()) { setSlackFile(slackFileOptional); } this.setAltText(instance.getAltText()); Optional titleOptional = instance.getTitle(); if (titleOptional.isPresent()) { setTitle(titleOptional); } Optional imageUrlOptional = instance.getImageUrl(); if (imageUrlOptional.isPresent()) { setImageUrl(imageUrlOptional); } } if (object instanceof Block) { Block instance = (Block) object; if ((bits & 0x1L) == 0) { Optional blockIdOptional = instance.getBlockId(); if (blockIdOptional.isPresent()) { setBlockId(blockIdOptional); } bits |= 0x1L; } } } /** * Initializes the optional value {@link ImageIF#getBlockId() blockId} to blockId. * @param blockId The value for blockId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setBlockId(@Nullable String blockId) { this.blockId = blockId; return this; } /** * Initializes the optional value {@link ImageIF#getBlockId() blockId} to blockId. * @param blockId The value for blockId * @return {@code this} builder for use in a chained invocation */ public final Builder setBlockId(Optional blockId) { this.blockId = blockId.orElse(null); return this; } /** * Initializes the optional value {@link ImageIF#getImageUrl() imageUrl} to imageUrl. * @param imageUrl The value for imageUrl, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setImageUrl(@Nullable String imageUrl) { this.imageUrl = imageUrl; return this; } /** * Initializes the optional value {@link ImageIF#getImageUrl() imageUrl} to imageUrl. * @param imageUrl The value for imageUrl * @return {@code this} builder for use in a chained invocation */ public final Builder setImageUrl(Optional imageUrl) { this.imageUrl = imageUrl.orElse(null); return this; } /** * Initializes the value for the {@link ImageIF#getAltText() altText} attribute. * @param altText The value for altText * @return {@code this} builder for use in a chained invocation */ public final Builder setAltText(String altText) { this.altText = Objects.requireNonNull(altText, "altText"); initBits &= ~INIT_BIT_ALT_TEXT; return this; } /** * Initializes the optional value {@link ImageIF#getTitle() title} to title. * @param title The value for title, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setTitle(@Nullable Text title) { this.title = title; return this; } /** * Initializes the optional value {@link ImageIF#getTitle() title} to title. * @param title The value for title * @return {@code this} builder for use in a chained invocation */ public final Builder setTitle(Optional title) { this.title = title.orElse(null); return this; } /** * Initializes the optional value {@link ImageIF#getSlackFile() slackFile} to slackFile. * @param slackFile The value for slackFile, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setSlackFile(@Nullable SlackFileObject slackFile) { this.slackFile = slackFile; return this; } /** * Initializes the optional value {@link ImageIF#getSlackFile() slackFile} to slackFile. * @param slackFile The value for slackFile * @return {@code this} builder for use in a chained invocation */ public final Builder setSlackFile(Optional slackFile) { this.slackFile = slackFile.orElse(null); return this; } /** * Builds a new {@link Image Image}. * @return An immutable instance of Image * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public Image build() { checkRequiredAttributes(); return new Image(blockId, imageUrl, altText, title, slackFile); } private boolean altTextIsSet() { return (initBits & INIT_BIT_ALT_TEXT) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!altTextIsSet()) attributes.add("altText"); return "Cannot build Image, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy