Record Class ParameterInvocationHint
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.network.http.annotation.parser.ParameterInvocationHint
- Record Components:
index- the index of the parameter to override.target- the parameter this hint is associated with.valueResolver- the resolver of the value to inject into handling http methods depending on the context.
public record ParameterInvocationHint(int index, @NonNull Parameter target, @NonNull BiFunction<String,HttpContext,Object> valueResolver)
extends Record
Represents a hint which can be added to a http context while pre-processing to indicate that the parameter at the
specified index should get overridden with the value returned by the given resolver.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe field for theindexrecord component.The field for thetargetrecord component.private final @NonNull BiFunction<String,HttpContext, Object> The field for thevalueResolverrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionParameterInvocationHint(int index, @NonNull Parameter target, @NonNull BiFunction<String, HttpContext, Object> valueResolver) Creates an instance of aParameterInvocationHintrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intindex()Returns the value of theindexrecord component.resolveValue(@NonNull String requestPath, @NonNull HttpContext context) Resolves the value of this hint which should be injected into the method parameter at the associated index depending on the calling context and path.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalueResolverrecord component.
-
Field Details
-
index
private final int indexThe field for theindexrecord component. -
target
The field for thetargetrecord component. -
valueResolver
The field for thevalueResolverrecord component.
-
-
Constructor Details
-
ParameterInvocationHint
public ParameterInvocationHint(int index, @NonNull @NonNull Parameter target, @NonNull @NonNull BiFunction<String, HttpContext, Object> valueResolver) Creates an instance of aParameterInvocationHintrecord class.- Parameters:
index- the value for theindexrecord componenttarget- the value for thetargetrecord componentvalueResolver- the value for thevalueResolverrecord component
-
-
Method Details
-
resolveValue
@Nullable public @Nullable Object resolveValue(@NonNull @NonNull String requestPath, @NonNull @NonNull HttpContext context) Resolves the value of this hint which should be injected into the method parameter at the associated index depending on the calling context and path.- Parameters:
requestPath- the path to which the http request to handle by the method was sent.context- the http context to resolve the parameter value based on.- Returns:
- the value to inject into the parameter, can be null.
- Throws:
NullPointerException- if the given request path or context is null.
-
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 '=='. -
index
public int index()Returns the value of theindexrecord component.- Returns:
- the value of the
indexrecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
valueResolver
Returns the value of thevalueResolverrecord component.- Returns:
- the value of the
valueResolverrecord component
-