Package com.tnsai.payment
Record Class Service
java.lang.Object
java.lang.Record
com.tnsai.payment.Service
- Record Components:
name- canonical service identifier ("github.create_pr","embed.text")unit- billing unit ("request","1k_tokens","second","byte")quantity- quantity ofunit; brokers multiply by their per-unit priceexpectedPriceUSD- optional caller-side price expectation in USD; the broker cross-checks against its policy and fails thePaymentBroker.quote(com.tnsai.identity.AgentPrincipal, com.tnsai.identity.AgentPrincipal, com.tnsai.payment.Service)when the spread is too widemetadata- free-form annotations the broker may use (region, urgency, …); never carries sensitive payload
public record Service(String name, String unit, BigDecimal quantity, Optional<BigDecimal> expectedPriceUSD, Map<String,String> metadata)
extends Record
Description of a unit-of-work an agent offers (TNS-298). The
PaymentBroker uses it to derive a Quote between
a payer and a payee.
Pricing is the broker's concern, not this record's. The fields here describe what is being paid for; the broker decides how much based on the payee's price list, the payer's subscription, market rates (for x402-style settlement), or any other policy the broker implements.
- Since:
- 0.10.0 (TNS-298)
-
Constructor Summary
ConstructorsConstructorDescriptionService(String name, String unit, BigDecimal quantity, Optional<BigDecimal> expectedPriceUSD, Map<String, String> metadata) Creates an instance of aServicerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpectedPriceUSDrecord component.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.name()Returns the value of thenamerecord component.quantity()Returns the value of thequantityrecord component.final StringtoString()Returns a string representation of this record class.unit()Returns the value of theunitrecord component.
-
Constructor Details
-
Service
public Service(String name, String unit, BigDecimal quantity, Optional<BigDecimal> expectedPriceUSD, Map<String, String> metadata) Creates an instance of aServicerecord class.- Parameters:
name- the value for thenamerecord componentunit- the value for theunitrecord componentquantity- the value for thequantityrecord componentexpectedPriceUSD- the value for theexpectedPriceUSDrecord componentmetadata- the value for themetadatarecord component
-
-
Method Details
-
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). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
unit
Returns the value of theunitrecord component.- Returns:
- the value of the
unitrecord component
-
quantity
Returns the value of thequantityrecord component.- Returns:
- the value of the
quantityrecord component
-
expectedPriceUSD
Returns the value of theexpectedPriceUSDrecord component.- Returns:
- the value of the
expectedPriceUSDrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-