Package org.springframework.ai.model
Class MutableResponseMetadata
java.lang.Object
org.springframework.ai.model.MutableResponseMetadata
- All Implemented Interfaces:
ResponseMetadata
- Direct Known Subclasses:
AudioTranscriptionResponseMetadata
,ImageResponseMetadata
,OpenAiAudioSpeechResponseMetadata
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the entries from the context.<T> T
computeIfAbsent
(String key, Function<Object, ? extends T> mappingFunction) Returns an element or calls a mapping function if entry not present.boolean
containsKey
(Object key) Checks if context contains a key.entrySet()
<T> T
Gets an entry from the context.<T> T
getOrDefault
(Object key, T defaultObject) Returns an element or default if not present.<T> T
getRequired
(Object key) Gets an entry from the context.boolean
isEmpty()
Returnstrue
if this map contains no key-value mappings.keySet()
Puts an element to the context.Removes an entry from the context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.model.ResponseMetadata
getOrDefault
-
Constructor Details
-
MutableResponseMetadata
public MutableResponseMetadata()
-
-
Method Details
-
put
Puts an element to the context.- Type Parameters:
T
- value type- Parameters:
key
- keyobject
- value- Returns:
- this for chaining
-
get
Gets an entry from the context. Returnsnull
when entry is not present.- Specified by:
get
in interfaceResponseMetadata
- Type Parameters:
T
- value type- Parameters:
key
- key- Returns:
- entry or
null
if not present
-
remove
Removes an entry from the context.- Parameters:
key
- key by which to remove an entry- Returns:
- the previous value associated with the key, or null if there was no mapping for the key
-
getRequired
Gets an entry from the context. Throws exception when entry is not present.- Specified by:
getRequired
in interfaceResponseMetadata
- Type Parameters:
T
- value type- Parameters:
key
- key- Returns:
- entry
- Throws:
IllegalArgumentException
- if not present
-
containsKey
Checks if context contains a key.- Specified by:
containsKey
in interfaceResponseMetadata
- Parameters:
key
- key- Returns:
true
when the context contains the entry with the given key
-
getOrDefault
Returns an element or default if not present.- Specified by:
getOrDefault
in interfaceResponseMetadata
- Type Parameters:
T
- value type- Parameters:
key
- keydefaultObject
- default object to return- Returns:
- object or default if not present
-
entrySet
- Specified by:
entrySet
in interfaceResponseMetadata
-
keySet
- Specified by:
keySet
in interfaceResponseMetadata
-
isEmpty
public boolean isEmpty()Description copied from interface:ResponseMetadata
Returnstrue
if this map contains no key-value mappings.- Specified by:
isEmpty
in interfaceResponseMetadata
- Returns:
true
if this map contains no key-value mappings
-
computeIfAbsent
Returns an element or calls a mapping function if entry not present. The function will insert the value to the map.- Type Parameters:
T
- value type- Parameters:
key
- keymappingFunction
- mapping function- Returns:
- object or one derived from the mapping function if not present
-
clear
public void clear()Clears the entries from the context. -
getRawMap
-