Package com.tnsai.intelligence.knowledge
Record Class TemporalKnowledge
java.lang.Object
java.lang.Record
com.tnsai.intelligence.knowledge.TemporalKnowledge
- Record Components:
fact- the knowledge statementsource- where this fact was extracted fromextractedAt- when this fact was extractedvalidFrom- start of validity window (null = no lower bound)validUntil- end of validity window (null = no expiry)confidence- confidence score (0.0 to 1.0)
public record TemporalKnowledge(String fact, String source, Instant extractedAt, Instant validFrom, Instant validUntil, double confidence)
extends Record
A fact with temporal validity boundaries.
Temporal knowledge associates extracted facts with a time window during which they are considered valid. This enables automatic expiration of stale knowledge and point-in-time validity checks.
Usage
// Fact valid for 30 days from extraction
TemporalKnowledge fact = new TemporalKnowledge(
"Java 21 is the latest LTS release",
"release-notes",
Instant.now(),
Instant.now(),
Instant.now().plus(Duration.ofDays(30)),
0.95
);
fact.isValid(); // true if within window
fact.isExpired(); // true if past validUntil
// Fact with no expiry
TemporalKnowledge permanent = new TemporalKnowledge(
"Water boils at 100C at sea level",
"physics",
Instant.now(),
null,
null,
1.0
);
permanent.isValid(); // always true
- Since:
- 0.3.0
- Author:
- TnsAI Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theconfidencerecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theextractedAtrecord component.fact()Returns the value of thefactrecord component.final inthashCode()Returns a hash code value for this object.booleanChecks if this knowledge has expired (not valid at the current instant).booleanChecks if this knowledge has no expiry date.booleanisValid()Checks if this knowledge is valid at the current instant.booleanChecks if this knowledge is valid at a specific instant.source()Returns the value of thesourcerecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalidFromrecord component.Returns the value of thevalidUntilrecord component.
-
Constructor Details
-
Method Details
-
isValid
public boolean isValid()Checks if this knowledge is valid at the current instant.- Returns:
- true if valid now
-
isValid
Checks if this knowledge is valid at a specific instant.- Parameters:
at- the instant to check- Returns:
- true if valid at the given instant
-
isExpired
public boolean isExpired()Checks if this knowledge has expired (not valid at the current instant).- Returns:
- true if expired
-
isPermanent
public boolean isPermanent()Checks if this knowledge has no expiry date.- Returns:
- true if validUntil is null
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
fact
Returns the value of thefactrecord component.- Returns:
- the value of the
factrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
extractedAt
Returns the value of theextractedAtrecord component.- Returns:
- the value of the
extractedAtrecord component
-
validFrom
Returns the value of thevalidFromrecord component.- Returns:
- the value of the
validFromrecord component
-
validUntil
Returns the value of thevalidUntilrecord component.- Returns:
- the value of the
validUntilrecord component
-
confidence
public double confidence()Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-