software.amazon.awssdk.services.bedrockagent.model.OpenSearchServerlessFieldMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bedrockagent Show documentation
Show all versions of bedrockagent Show documentation
The AWS Java SDK for Bedrock Agent module holds the client classes that are used for
communicating with Bedrock Agent.
/*
* 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.bedrockagent.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;
/**
*
* Contains the names of the fields to which to map information about the vector store.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class OpenSearchServerlessFieldMapping implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField METADATA_FIELD_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("metadataField").getter(getter(OpenSearchServerlessFieldMapping::metadataField))
.setter(setter(Builder::metadataField))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("metadataField").build()).build();
private static final SdkField TEXT_FIELD_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("textField").getter(getter(OpenSearchServerlessFieldMapping::textField))
.setter(setter(Builder::textField))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("textField").build()).build();
private static final SdkField VECTOR_FIELD_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("vectorField").getter(getter(OpenSearchServerlessFieldMapping::vectorField))
.setter(setter(Builder::vectorField))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("vectorField").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(METADATA_FIELD_FIELD,
TEXT_FIELD_FIELD, VECTOR_FIELD_FIELD));
private static final long serialVersionUID = 1L;
private final String metadataField;
private final String textField;
private final String vectorField;
private OpenSearchServerlessFieldMapping(BuilderImpl builder) {
this.metadataField = builder.metadataField;
this.textField = builder.textField;
this.vectorField = builder.vectorField;
}
/**
*
* The name of the field in which Amazon Bedrock stores metadata about the vector store.
*
*
* @return The name of the field in which Amazon Bedrock stores metadata about the vector store.
*/
public final String metadataField() {
return metadataField;
}
/**
*
* The name of the field in which Amazon Bedrock stores the raw text from your data. The text is split according to
* the chunking strategy you choose.
*
*
* @return The name of the field in which Amazon Bedrock stores the raw text from your data. The text is split
* according to the chunking strategy you choose.
*/
public final String textField() {
return textField;
}
/**
*
* The name of the field in which Amazon Bedrock stores the vector embeddings for your data sources.
*
*
* @return The name of the field in which Amazon Bedrock stores the vector embeddings for your data sources.
*/
public final String vectorField() {
return vectorField;
}
@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(metadataField());
hashCode = 31 * hashCode + Objects.hashCode(textField());
hashCode = 31 * hashCode + Objects.hashCode(vectorField());
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 OpenSearchServerlessFieldMapping)) {
return false;
}
OpenSearchServerlessFieldMapping other = (OpenSearchServerlessFieldMapping) obj;
return Objects.equals(metadataField(), other.metadataField()) && Objects.equals(textField(), other.textField())
&& Objects.equals(vectorField(), other.vectorField());
}
/**
* 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("OpenSearchServerlessFieldMapping").add("MetadataField", metadataField())
.add("TextField", textField()).add("VectorField", vectorField()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "metadataField":
return Optional.ofNullable(clazz.cast(metadataField()));
case "textField":
return Optional.ofNullable(clazz.cast(textField()));
case "vectorField":
return Optional.ofNullable(clazz.cast(vectorField()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function