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, Map<Integer,SdkResponseHandler> responses, ExecutorService executor)
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 ClassesModifier and TypeClassDescriptionstatic classBuilder to correctly request and create Context object -
Constructor Summary
ConstructorsConstructorDescriptionEverSdkContext(int id, int requestCount, long timeout, com.fasterxml.jackson.databind.ObjectMapper mapper) Constructor of EVER-SDK contextEverSdkContext(int id, com.fasterxml.jackson.databind.ObjectMapper mapper, long timeout, AtomicInteger requestCount, Map<Integer, SdkResponseHandler> responses, ExecutorService executor) Creates an instance of aEverSdkContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic EverSdkContext.Builderbuilder()<T,P> T 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 Call that uses event as consumer param<P> voidCalls to EVER-SDK without outputsfinal booleanIndicates whether some other object is "equal to" this one.executor()Returns the value of theexecutorrecord component.final inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.com.fasterxml.jackson.databind.ObjectMappermapper()Returns the value of themapperrecord component.Returns the value of therequestCountrecord component.Returns the value of theresponsesrecord component.longtimeout()Returns the value of thetimeoutrecord component.final StringtoString()Returns a string representation of this record class.
-
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' onestimeout- timeout for operations in millisecondsmapper- Jackson's ObjectMapper, ContextBuilder have correctly preconfigured one.
-
EverSdkContext
public EverSdkContext(int id, com.fasterxml.jackson.databind.ObjectMapper mapper, long timeout, AtomicInteger requestCount, Map<Integer, SdkResponseHandler> responses, ExecutorService executor) Creates an instance of aEverSdkContextrecord class.- Parameters:
id- the value for theidrecord componentmapper- the value for themapperrecord componenttimeout- the value for thetimeoutrecord componentrequestCount- the value for therequestCountrecord componentresponses- the value for theresponsesrecord componentexecutor- the value for theexecutorrecord component
-
-
Method Details
-
builder
-
callAppObject
public <T,P, T callAppObjectA> (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<String> consumer, Class<T> clazz) throws EverSdkException Call that uses event as consumer param- Type Parameters:
T- type of function resultP- type of function params- Parameters:
functionName-params-consumer-clazz-- Returns:
- Throws:
EverSdkException
-
call
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
Calls to EVER-SDK without outputs- Type Parameters:
P-- Parameters:
functionName-params-- Throws:
EverSdkException
-
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 '=='. -
id
public int id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
mapper
public com.fasterxml.jackson.databind.ObjectMapper mapper()Returns the value of themapperrecord component.- Returns:
- the value of the
mapperrecord component
-
timeout
public long timeout()Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
requestCount
Returns the value of therequestCountrecord component.- Returns:
- the value of the
requestCountrecord component
-
responses
Returns the value of theresponsesrecord component.- Returns:
- the value of the
responsesrecord component
-
executor
Returns the value of theexecutorrecord component.- Returns:
- the value of the
executorrecord component
-