Class UsageReporter
-
- All Implemented Interfaces:
public class UsageReporterEach Usage Reporter is assigned a Target ID, and reports usage by persisting the UsageRecords into the UsageStore.
-
-
Field Summary
Fields Modifier and Type Field Description public StringtargetId
-
Constructor Summary
Constructors Constructor Description UsageReporter(String targetId, UsageStore recordStore)Constructs a usage reporter by assigning a target ID and a persistence store.
-
Method Summary
Modifier and Type Method Description StringgetTargetId()Returns the targetId assigned to the reporter. booleanisEnabled()Checks if the UsageReporter is enabled. voidreport(@NonNull() UsageRecord record)Persists a UsageRecord if the reporter is enabled. <T extends Enum<T>> voidreport(@NonNull() T event, @NonNull() Date date, @NonNull() UsageInfo info)Creates a UsageRecord with the user-defined event type, date, and UsageInfo, then persists the record. voidsetEnabled(boolean enabled)Enables the usage reporter. -
-
Constructor Detail
-
UsageReporter
UsageReporter(String targetId, UsageStore recordStore)
Constructs a usage reporter by assigning a target ID and a persistence store.- Parameters:
targetId- an ID to group all records reported by this reporterrecordStore- a store to persists the usage records
-
-
Method Detail
-
getTargetId
@NonNull() String getTargetId()
Returns the targetId assigned to the reporter.
- Returns:
The targetId assigned to the reporter.
-
isEnabled
boolean isEnabled()
Checks if the UsageReporter is enabled. If it is not enabled all the call to reporter methods will be ignored.
- Returns:
Trueif enabled,falseotherwise.
-
report
void report(@NonNull() UsageRecord record)
Persists a UsageRecord if the reporter is enabled. The record will be discarded if the reporter is disabled.
- Parameters:
record- a usage record
-
report
<T extends Enum<T>> void report(@NonNull() T event, @NonNull() Date date, @NonNull() UsageInfo info)
Creates a UsageRecord with the user-defined event type, date, and UsageInfo, then persists the record.
- Parameters:
event- an instance of user defined Enum event typedate- a dateinfo- an instance of UsageInfo
-
setEnabled
void setEnabled(boolean enabled)
Enables the usage reporter.
- Parameters:
enabled-Trueto enable the reporter,falseto disable it.
-
-
-
-