Class UsageReporter
-
- All Implemented Interfaces:
public class UsageReporter
Each 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 String
targetId
-
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 String
getTargetId()
Returns the targetId assigned to the reporter. boolean
isEnabled()
Checks if the UsageReporter is enabled. void
report(@NonNull() UsageRecord record)
Persists a UsageRecord if the reporter is enabled. <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. void
setEnabled(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:
True
if enabled,false
otherwise.
-
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
-True
to enable the reporter,false
to disable it.
-
-
-
-