
com.amazonaws.services.bedrockagentruntime.model.Citation Maven / Gradle / Ivy
/*
* Copyright 2019-2024 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 com.amazonaws.services.bedrockagentruntime.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* An object containing a segment of the generated response that is based on a source in the knowledge base, alongside
* information about the source.
*
*
* This data type is used in the following API operations:
*
*
* -
*
* InvokeAgent response – in the citations
field
*
*
* -
*
* RetrieveAndGenerate response – in the citations
field
*
*
*
*
* @see AWS API
* Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Citation implements Serializable, Cloneable, StructuredPojo {
/**
*
* Contains the generated response and metadata
*
*/
private GeneratedResponsePart generatedResponsePart;
/**
*
* Contains metadata about the sources cited for the generated response.
*
*/
private java.util.List retrievedReferences;
/**
*
* Contains the generated response and metadata
*
*
* @param generatedResponsePart
* Contains the generated response and metadata
*/
public void setGeneratedResponsePart(GeneratedResponsePart generatedResponsePart) {
this.generatedResponsePart = generatedResponsePart;
}
/**
*
* Contains the generated response and metadata
*
*
* @return Contains the generated response and metadata
*/
public GeneratedResponsePart getGeneratedResponsePart() {
return this.generatedResponsePart;
}
/**
*
* Contains the generated response and metadata
*
*
* @param generatedResponsePart
* Contains the generated response and metadata
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Citation withGeneratedResponsePart(GeneratedResponsePart generatedResponsePart) {
setGeneratedResponsePart(generatedResponsePart);
return this;
}
/**
*
* Contains metadata about the sources cited for the generated response.
*
*
* @return Contains metadata about the sources cited for the generated response.
*/
public java.util.List getRetrievedReferences() {
return retrievedReferences;
}
/**
*
* Contains metadata about the sources cited for the generated response.
*
*
* @param retrievedReferences
* Contains metadata about the sources cited for the generated response.
*/
public void setRetrievedReferences(java.util.Collection retrievedReferences) {
if (retrievedReferences == null) {
this.retrievedReferences = null;
return;
}
this.retrievedReferences = new java.util.ArrayList(retrievedReferences);
}
/**
*
* Contains metadata about the sources cited for the generated response.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setRetrievedReferences(java.util.Collection)} or {@link #withRetrievedReferences(java.util.Collection)}
* if you want to override the existing values.
*
*
* @param retrievedReferences
* Contains metadata about the sources cited for the generated response.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Citation withRetrievedReferences(RetrievedReference... retrievedReferences) {
if (this.retrievedReferences == null) {
setRetrievedReferences(new java.util.ArrayList(retrievedReferences.length));
}
for (RetrievedReference ele : retrievedReferences) {
this.retrievedReferences.add(ele);
}
return this;
}
/**
*
* Contains metadata about the sources cited for the generated response.
*
*
* @param retrievedReferences
* Contains metadata about the sources cited for the generated response.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Citation withRetrievedReferences(java.util.Collection retrievedReferences) {
setRetrievedReferences(retrievedReferences);
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getGeneratedResponsePart() != null)
sb.append("GeneratedResponsePart: ").append(getGeneratedResponsePart()).append(",");
if (getRetrievedReferences() != null)
sb.append("RetrievedReferences: ").append(getRetrievedReferences());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Citation == false)
return false;
Citation other = (Citation) obj;
if (other.getGeneratedResponsePart() == null ^ this.getGeneratedResponsePart() == null)
return false;
if (other.getGeneratedResponsePart() != null && other.getGeneratedResponsePart().equals(this.getGeneratedResponsePart()) == false)
return false;
if (other.getRetrievedReferences() == null ^ this.getRetrievedReferences() == null)
return false;
if (other.getRetrievedReferences() != null && other.getRetrievedReferences().equals(this.getRetrievedReferences()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getGeneratedResponsePart() == null) ? 0 : getGeneratedResponsePart().hashCode());
hashCode = prime * hashCode + ((getRetrievedReferences() == null) ? 0 : getRetrievedReferences().hashCode());
return hashCode;
}
@Override
public Citation clone() {
try {
return (Citation) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.bedrockagentruntime.model.transform.CitationMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}