Package net.obvj.performetrics
Class UnmodifiableCounter
- java.lang.Object
-
- net.obvj.performetrics.Counter
-
- net.obvj.performetrics.UnmodifiableCounter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.obvj.performetrics.Counter
Counter.Type
-
-
Constructor Summary
Constructors Constructor Description UnmodifiableCounter(Counter counter)Creates an unmodifiableCounter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DurationelapsedTime()Returns the elapsed time.doubleelapsedTime(TimeUnit timeUnit)Returns the elapsed time in the specifiedTimeUnit.doubleelapsedTime(TimeUnit timeUnit, ConversionMode conversionMode)Returns the elapsed time, in a givenTimeUnit, with a customConversionMode.longgetUnitsAfter()Returns the value of theunitsAfterfield.longgetUnitsBefore()Returns the value of theunitsBeforefield.voidsetUnitsAfter(long unitsAfter)Populates theunitsAfterfield with an arbitrary value.voidsetUnitsBefore(long unitsBefore)Populates theunitsBeforefield with an arbitrary value.StringtoString()Returns a string representation of this object.-
Methods inherited from class net.obvj.performetrics.Counter
getConversionMode, getType
-
-
-
-
Constructor Detail
-
UnmodifiableCounter
public UnmodifiableCounter(Counter counter)
Creates an unmodifiableCounter.- Parameters:
counter- theCounterto be wrapped; not null- Throws:
NullPointerException- if the specified counter is null
-
-
Method Detail
-
getUnitsBefore
public long getUnitsBefore()
Description copied from class:CounterReturns the value of theunitsBeforefield.- Overrides:
getUnitsBeforein classCounter- Returns:
- the value of the
unitsBeforefield
-
setUnitsBefore
public void setUnitsBefore(long unitsBefore)
Description copied from class:CounterPopulates theunitsBeforefield with an arbitrary value.- Overrides:
setUnitsBeforein classCounter- Parameters:
unitsBefore- the units to be set
-
getUnitsAfter
public long getUnitsAfter()
Description copied from class:CounterReturns the value of theunitsAfterfield.- Overrides:
getUnitsAfterin classCounter- Returns:
- the value of the
unitsAfterfield
-
setUnitsAfter
public void setUnitsAfter(long unitsAfter)
Description copied from class:CounterPopulates theunitsAfterfield with an arbitrary value.- Overrides:
setUnitsAfterin classCounter- Parameters:
unitsAfter- the units to be set
-
elapsedTime
public Duration elapsedTime()
Description copied from class:CounterReturns the elapsed time.- Overrides:
elapsedTimein classCounter- Returns:
- the difference between
unitsBeforeandunitsAfter, if both units are set; or the difference betweenunitsBeforeand the current value retrieved by the counter's time source, ifunitsAfteris not set.
-
elapsedTime
public double elapsedTime(TimeUnit timeUnit)
Description copied from class:CounterReturns the elapsed time in the specifiedTimeUnit.- Overrides:
elapsedTimein classCounter- Parameters:
timeUnit- the time unit to which the elapsed time will be converted- Returns:
- the difference between
unitsBeforeandunitsAfter, if both units are set; or the difference betweenunitsBeforeand the current value retrieved by the counter's time source, ifunitsAfteris not set. The value is converted into the specified time unit applying the default conversion mode.
-
elapsedTime
public double elapsedTime(TimeUnit timeUnit, ConversionMode conversionMode)
Description copied from class:CounterReturns the elapsed time, in a givenTimeUnit, with a customConversionMode.- Overrides:
elapsedTimein classCounter- Parameters:
timeUnit- the time unit to which the elapsed time will be convertedconversionMode- theConversionModeto be used- Returns:
- the difference between
unitsBeforeandunitsAfter, if both units are set; or the difference betweenunitsBeforeand the current value retrieved by the counter's time source, ifunitsAfteris not set. The value is converted into the specified time unit applying the given conversion mode.
-
toString
public String toString()
Description copied from class:CounterReturns a string representation of this object.- Overrides:
toStringin classCounter- See Also:
Object.toString()
-
-