Class DecisionInput

java.lang.Object
com.tnsai.context.decision.DecisionInput

public final class DecisionInput extends Object
Represents what information was considered when making a decision.

DecisionInput captures all the context that fed into a decision: relevant beliefs, entities, and any external data. This enables understanding what the agent "knew" when it made its choice.

Usage Example


 DecisionInput input = DecisionInput.builder()
     .belief(new Belief("Customer has premium account", 0.95, "crm"))
     .belief(new Belief("Previous request was denied", 0.8, "history"))
     .entity(customerEntity)
     .data("requestedDiscount", 0.20)
     .data("orderTotal", 1500.00)
     .query("Should we approve the 20% discount?")
     .build();
 
  • Method Details

    • builder

      public static DecisionInput.Builder builder()
      Creates a new builder.
    • ofQuery

      public static DecisionInput ofQuery(String query)
      Creates a simple input with just a query.
    • getRelevantBeliefs

      public List<Belief> getRelevantBeliefs()
    • getRelevantEntities

      public List<Entity> getRelevantEntities()
    • getContextData

      public Map<String,Object> getContextData()
    • getQuery

      public String getQuery()
    • getConstraints

      public List<String> getConstraints()
    • getPrecedents

      public List<String> getPrecedents()
    • getData

      public Optional<Object> getData(String key)
      Gets a context data value.
      Parameters:
      key - data key
      Returns:
      Optional containing the value if present
    • getData

      public <T> Optional<T> getData(String key, Class<T> type)
      Gets a typed context data value.
      Parameters:
      key - data key
      type - expected type
      Returns:
      Optional containing the typed value if present and castable
    • getBeliefsBySource

      public List<Belief> getBeliefsBySource(String source)
      Finds beliefs by source.
      Parameters:
      source - source identifier
      Returns:
      list of beliefs from that source
    • getHighConfidenceBeliefs

      public List<Belief> getHighConfidenceBeliefs()
      Finds high-confidence beliefs.
      Returns:
      beliefs with confidence >= 0.9
    • getInputCount

      public int getInputCount()
      Returns the total number of input elements.
    • hasBeliefs

      public boolean hasBeliefs()
      Returns true if there are any beliefs.
    • hasEntities

      public boolean hasEntities()
      Returns true if there are any entities.
    • hasConstraints

      public boolean hasConstraints()
      Returns true if there are any constraints.
    • hasPrecedents

      public boolean hasPrecedents()
      Returns true if there are any precedents.
    • toString

      public String toString()
      Overrides:
      toString in class Object