Record Class EverSdkContext

java.lang.Object
java.lang.Record
tech.deplant.java4ever.binding.EverSdkContext

public record EverSdkContext(int id, com.fasterxml.jackson.databind.ObjectMapper mapper, long timeout, AtomicInteger requestCount) extends Record
Class that represents the established environment inside EVER-SDK and is identified by id number. Holds last request id and functions to call SDK methods.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder to correctly request and create Context object
  • Constructor Summary

    Constructors
    Constructor
    Description
    EverSdkContext(int id, int requestCount, long timeout, com.fasterxml.jackson.databind.ObjectMapper mapper)
    Constructor of EVER-SDK context
    EverSdkContext(int id, com.fasterxml.jackson.databind.ObjectMapper mapper, long timeout, AtomicInteger requestCount)
    Creates an instance of a EverSdkContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    <T, P> T
    call(String functionName, P params, Class<T> clazz)
    Most used call to EVER-SDK with some output object
    <T, P, A> T
    callAppObject(String functionName, P params, A appObject, Class<T> clazz)
    Call for methods that use app_object as one of params
    <T, P> T
    callEvent(String functionName, P params, Consumer<CallbackHandler> consumer, Class<T> clazz)
    Call that uses event as consumer param
    <P> void
    callVoid(String functionName, P params)
    Calls to EVER-SDK without outputs
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    id()
    Returns the value of the id record component.
    com.fasterxml.jackson.databind.ObjectMapper
    Returns the value of the mapper record component.
    Returns the value of the requestCount record component.
    long
    Returns the value of the timeout record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EverSdkContext

      public EverSdkContext(int id, int requestCount, long timeout, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Constructor of EVER-SDK context
      Parameters:
      id - number of context received from EVER-SDK, it's provided in contextBuilder.buildNew(loader). You can call it manually from EverSdkBridge.tcCreateContext(), but it's recommended to use ContextBuilder.
      requestCount - it's 0 for new contexts or last request id for 'loaded' ones
      timeout - timeout for operations in milliseconds
      mapper - Jackson's ObjectMapper, ContextBuilder have correctly preconfigured one.
    • EverSdkContext

      public EverSdkContext(int id, com.fasterxml.jackson.databind.ObjectMapper mapper, long timeout, AtomicInteger requestCount)
      Creates an instance of a EverSdkContext record class.
      Parameters:
      id - the value for the id record component
      mapper - the value for the mapper record component
      timeout - the value for the timeout record component
      requestCount - the value for the requestCount record component
  • Method Details

    • builder

      public static EverSdkContext.Builder builder()
    • callAppObject

      public <T, P, A> T callAppObject(String functionName, P params, A appObject, Class<T> clazz) throws EverSdkException
      Call for methods that use app_object as one of params
      Type Parameters:
      T -
      P -
      A -
      Parameters:
      functionName -
      params -
      appObject -
      clazz -
      Returns:
      Throws:
      EverSdkException
    • callEvent

      public <T, P> T callEvent(String functionName, P params, Consumer<CallbackHandler> consumer, Class<T> clazz) throws EverSdkException
      Call that uses event as consumer param
      Type Parameters:
      T - type of function result
      P - type of function params
      Parameters:
      functionName -
      params -
      consumer -
      clazz -
      Returns:
      Throws:
      EverSdkException
    • call

      public <T, P> T call(String functionName, P params, Class<T> clazz) throws EverSdkException
      Most used call to EVER-SDK with some output object
      Type Parameters:
      T -
      P -
      Parameters:
      functionName -
      params - record of input type, usually ParamsOf...
      clazz - class of output type record, usually ResultOf...class
      Returns:
      output type record, usually ResultOf...
      Throws:
      EverSdkException
    • callVoid

      public <P> void callVoid(String functionName, P params) throws EverSdkException
      Calls to EVER-SDK without outputs
      Type Parameters:
      P -
      Parameters:
      functionName -
      params -
      Throws:
      EverSdkException
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public int id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • mapper

      public com.fasterxml.jackson.databind.ObjectMapper mapper()
      Returns the value of the mapper record component.
      Returns:
      the value of the mapper record component
    • timeout

      public long timeout()
      Returns the value of the timeout record component.
      Returns:
      the value of the timeout record component
    • requestCount

      public AtomicInteger requestCount()
      Returns the value of the requestCount record component.
      Returns:
      the value of the requestCount record component