Package org.shredzone.geordi.service
Class CompactingServiceImpl
java.lang.Object
org.shredzone.geordi.service.CompactingServiceImpl
- All Implemented Interfaces:
CompactingService
@Singleton public class CompactingServiceImpl extends Object implements CompactingService
Implementation of CompactingService. It stores the last sample value in a hash map.
This implementation is threadsafe.
-
Constructor Summary
Constructors Constructor Description CompactingServiceImpl()
-
Method Summary
Modifier and Type Method Description Sample
lastUnchanged(Sample sample)
Regenerates the last unchangedSample
before the value has changed.void
rememberSample(Sample sample)
Remember aSample
value.boolean
wasUnchanged(Sample sample)
Checks if the givenSample
can be compacted.
-
Constructor Details
-
Method Details
-
wasUnchanged
Description copied from interface:CompactingService
Checks if the givenSample
can be compacted.- Specified by:
wasUnchanged
in interfaceCompactingService
- Parameters:
sample
-Sample
to check- Returns:
true
if the corresponding sensor is in compact mode, and the sample's value is equal to the previously stored sensor value.
-
lastUnchanged
Description copied from interface:CompactingService
Regenerates the last unchangedSample
before the value has changed. This way, interpolations can start from the timestamp of the last unchanged value, instead of the first unchanged value.- Specified by:
lastUnchanged
in interfaceCompactingService
- Parameters:
sample
-Sample
to regenerate the last unchanged sample for- Returns:
- Regenerated
Sample
, ornull
if there was no last sample that could be generated
-
rememberSample
Description copied from interface:CompactingService
Remember aSample
value.- Specified by:
rememberSample
in interfaceCompactingService
- Parameters:
sample
-Sample
to remember
-