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 timesinnerwas 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
FieldsModifier and TypeFieldDescriptionThe field for theinnerrecord component.private final AtomicIntegerThe field for theinvocationCountrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionInvocationCounter(Function<A, B> inner, AtomicInteger invocationCount) Creates an instance of aInvocationCounterrecord 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.inner()Returns the value of theinnerrecord component.Returns the value of theinvocationCountrecord 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 ofinnerby wrapping it.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
inner
The field for theinnerrecord component. -
invocationCount
The field for theinvocationCountrecord component.
-
-
Constructor Details
-
InvocationCounter
Creates an instance of aInvocationCounterrecord class.- Parameters:
inner- the value for theinnerrecord componentinvocationCount- the value for theinvocationCountrecord component
-
-
Method Details
-
of
Count the number of invocations ofinnerby 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 theinnerrecord component.- Returns:
- the value of the
innerrecord component
-
invocationCount
Returns the value of theinvocationCountrecord component.- Returns:
- the value of the
invocationCountrecord component
-