Class BetaImageBlockParam.Source
-
- All Implemented Interfaces:
public final class BetaImageBlockParam.Source
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaImageBlockParam.Source.VisitorAn interface that defines how to map each variant of Source to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<BetaBase64ImageSource>base64()final Optional<BetaUrlImageSource>url()final Optional<BetaFileImageSource>file()final BooleanisBase64()final BooleanisUrl()final BooleanisFile()final BetaBase64ImageSourceasBase64()final BetaUrlImageSourceasUrl()final BetaFileImageSourceasFile()final Optional<JsonValue>_json()final <T extends Any> Taccept(BetaImageBlockParam.Source.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaImageBlockParam.Sourcevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static BetaImageBlockParam.SourceofBase64(BetaBase64ImageSource base64)final static BetaImageBlockParam.SourceofUrl(BetaUrlImageSource url)final static BetaImageBlockParam.SourceofFile(BetaFileImageSource file)-
-
Method Detail
-
base64
final Optional<BetaBase64ImageSource> base64()
-
url
final Optional<BetaUrlImageSource> url()
-
file
final Optional<BetaFileImageSource> file()
-
asBase64
final BetaBase64ImageSource asBase64()
-
asUrl
final BetaUrlImageSource asUrl()
-
asFile
final BetaFileImageSource asFile()
-
accept
final <T extends Any> T accept(BetaImageBlockParam.Source.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = source.accept(new Source.Visitor<Optional<String>>() { @Override public Optional<String> visitBase64(BetaBase64ImageSource base64) { return Optional.of(base64.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaImageBlockParam.Source validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofBase64
final static BetaImageBlockParam.Source ofBase64(BetaBase64ImageSource base64)
-
ofUrl
final static BetaImageBlockParam.Source ofUrl(BetaUrlImageSource url)
-
ofFile
final static BetaImageBlockParam.Source ofFile(BetaFileImageSource file)
-
-
-
-