Package com.tnsai.memory
Record Class MemoryNamespace
java.lang.Object
java.lang.Record
com.tnsai.memory.MemoryNamespace
- Record Components:
workspace- the workspace-level scope (e.g. project name, team ID)session- the session-level scope (e.g. conversation ID, turn ID)
Defines a hierarchical memory namespace as workspace:session.
Namespace hierarchy supports scoped retrieval patterns:
- GLOBAL — cross-workspace persistent memory
- Workspace — project/team-level scope
- Session — single conversation/interaction scope
Namespaces compose into a colon-delimited key (workspace:session)
used by NamespacedMemoryStore for scoped storage and retrieval.
- Since:
- 0.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MemoryNamespaceGlobal namespace shared across all workspaces and sessions. -
Constructor Summary
ConstructorsConstructorDescriptionMemoryNamespace(String workspace, String session) Canonical constructor with null/blank validation. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static MemoryNamespaceParses a colon-delimited key back into a MemoryNamespace.final inthashCode()Returns a hash code value for this object.static MemoryNamespaceCreates a namespace with the given workspace and session.session()Returns the value of thesessionrecord component.static MemoryNamespaceCreates a namespace in the default workspace with the given session ID.toKey()Returns the colon-delimited key for this namespace.final StringtoString()Returns a string representation of this record class.Returns the value of theworkspacerecord component.
-
Field Details
-
GLOBAL
Global namespace shared across all workspaces and sessions.
-
-
Constructor Details
-
MemoryNamespace
Canonical constructor with null/blank validation.
-
-
Method Details
-
toKey
Returns the colon-delimited key for this namespace.- Returns:
workspace:session
-
of
Creates a namespace with the given workspace and session.- Parameters:
workspace- the workspace scopesession- the session scope- Returns:
- a new MemoryNamespace
-
session
Creates a namespace in the default workspace with the given session ID.- Parameters:
sessionId- the session scope- Returns:
- a new MemoryNamespace with workspace "default"
-
fromKey
Parses a colon-delimited key back into a MemoryNamespace.- Parameters:
key- the key inworkspace:sessionformat- Returns:
- the parsed MemoryNamespace
- Throws:
IllegalArgumentException- if the key format is invalid
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
workspace
Returns the value of theworkspacerecord component.- Returns:
- the value of the
workspacerecord component
-
session
Returns the value of thesessionrecord component.- Returns:
- the value of the
sessionrecord component
-