Class TranslationCreateResponse
-
- All Implemented Interfaces:
public final class TranslationCreateResponse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceTranslationCreateResponse.VisitorAn interface that defines how to map each variant of TranslationCreateResponse to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<Translation>translation()final Optional<TranslationVerbose>verbose()final BooleanisTranslation()final BooleanisVerbose()final TranslationasTranslation()final TranslationVerboseasVerbose()final Optional<JsonValue>_json()final <T extends Any> Taccept(TranslationCreateResponse.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final TranslationCreateResponsevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static TranslationCreateResponseofTranslation(Translation translation)final static TranslationCreateResponseofVerbose(TranslationVerbose verbose)-
-
Method Detail
-
translation
final Optional<Translation> translation()
-
verbose
final Optional<TranslationVerbose> verbose()
-
isTranslation
final Boolean isTranslation()
-
asTranslation
final Translation asTranslation()
-
asVerbose
final TranslationVerbose asVerbose()
-
accept
final <T extends Any> T accept(TranslationCreateResponse.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.openai.core.JsonValue; import java.util.Optional; Optional<String> result = translationCreateResponse.accept(new TranslationCreateResponse.Visitor<Optional<String>>() { @Override public Optional<String> visitTranslation(Translation translation) { return Optional.of(translation.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final TranslationCreateResponse 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.
-
ofTranslation
final static TranslationCreateResponse ofTranslation(Translation translation)
-
ofVerbose
final static TranslationCreateResponse ofVerbose(TranslationVerbose verbose)
-
-
-
-