Class CacheControl

java.lang.Object
com.sap.ai.sdk.prompt.registry.model.CacheControl

public class CacheControl extends Object
Cache control directive for Anthropic prompt caching. Only applicable to Anthropic Claude models. When set, marks the content block as a cache breakpoint.
  • Constructor Details

    • CacheControl

      protected CacheControl()
      Default constructor for CacheControl.
  • Method Details

    • type

      @Nonnull public CacheControl type(@Nonnull CacheControl.TypeEnum type)
      Set the type of this CacheControl instance and return the same instance.
      Parameters:
      type - The type of this CacheControl
      Returns:
      The same instance of this CacheControl class
    • getType

      @Nonnull public CacheControl.TypeEnum getType()
      Get type
      Returns:
      type The type of this CacheControl instance.
    • setType

      public void setType(@Nonnull CacheControl.TypeEnum type)
      Set the type of this CacheControl instance.
      Parameters:
      type - The type of this CacheControl
    • ttl

      @Nonnull public CacheControl ttl(@Nullable CacheControl.TtlEnum ttl)
      Set the ttl of this CacheControl instance and return the same instance.
      Parameters:
      ttl - Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5).
      Returns:
      The same instance of this CacheControl class
    • getTtl

      @Nonnull public CacheControl.TtlEnum getTtl()
      Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5).
      Returns:
      ttl The ttl of this CacheControl instance.
    • setTtl

      public void setTtl(@Nullable CacheControl.TtlEnum ttl)
      Set the ttl of this CacheControl instance.
      Parameters:
      ttl - Time-to-live for the cache entry. Default is \"5m\" (5 minutes). \"1h\" (1 hour) is supported on select models (e.g. Claude Opus 4.5, Haiku 4.5, Sonnet 4.5).
    • getCustomFieldNames

      @Nonnull public Set<String> getCustomFieldNames()
      Get the names of the unrecognizable properties of the CacheControl.
      Returns:
      The set of properties names
    • getCustomField

      @Nullable @Deprecated public Object getCustomField(@Nonnull String name) throws NoSuchElementException
      Deprecated.
      Use toMap() instead.
      Get the value of an unrecognizable property of this CacheControl instance.
      Parameters:
      name - The name of the property
      Returns:
      The value of the property
      Throws:
      NoSuchElementException - If no property with the given name could be found.
    • toMap

      @Nonnull public Map<String,Object> toMap()
      Get the value of all properties of this CacheControl instance including unrecognized properties.
      Returns:
      The map of all properties
    • setCustomField

      public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue)
      Set an unrecognizable property of this CacheControl instance. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
      Parameters:
      customFieldName - The name of the property
      customFieldValue - The value of the property
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • create

      public static CacheControl.Builder create()
      Create a type-safe, fluent-api builder object to construct a new CacheControl instance with all required arguments.