Record Class InvocationCounter<A,B>
java.lang.Object
java.lang.Record
org.variantsync.diffdetective.util.InvocationCounter<A,B>
- Record Components:
inner
- the wrapped functioninvocationCount
- the number of timesinner
was called
- All Implemented Interfaces:
Function<A,
B>
public record InvocationCounter<A,B> (Function<A,B> inner, AtomicInteger invocationCount)
extends Record
implements Function<A,B>
Counter for the number of times a wrapped function is called.
This class is thread safe.
-
Field Summary
Modifier and TypeFieldDescriptionThe field for theinner
record component.private final AtomicInteger
The field for theinvocationCount
record component. -
Constructor Summary
ConstructorDescriptionInvocationCounter
(Function<A, B> inner, AtomicInteger invocationCount) Creates an instance of aInvocationCounter
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.inner()
Returns the value of theinner
record component.Returns the value of theinvocationCount
record component.static <A> InvocationCounter<A,
A> Count the number of invocations of the identity function.static <A,
B> InvocationCounter<A, B> Count the number of invocations ofinner
by wrapping it.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
inner
The field for theinner
record component. -
invocationCount
The field for theinvocationCount
record component.
-
-
Constructor Details
-
InvocationCounter
Creates an instance of aInvocationCounter
record class.- Parameters:
inner
- the value for theinner
record componentinvocationCount
- the value for theinvocationCount
record component
-
-
Method Details
-
of
Count the number of invocations ofinner
by wrapping it. -
justCount
Count the number of invocations of the identity function. -
apply
-
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)
. -
inner
Returns the value of theinner
record component.- Returns:
- the value of the
inner
record component
-
invocationCount
Returns the value of theinvocationCount
record component.- Returns:
- the value of the
invocationCount
record component
-