1 package com.android.helpers; 2 3 import java.util.Map; 4 import java.util.function.Function; 5 6 public interface ICollectorHelper<T> { 7 8 /** 9 * This method will have setup to start collecting the metrics. 10 */ startCollecting()11 boolean startCollecting(); 12 13 /** 14 * This method will take args which passes an identifier for the helper. 15 * The default implementation is to invoke {@link #startCollecting()} directly. 16 */ startCollecting(String id)17 default boolean startCollecting(String id) { 18 return startCollecting(); 19 } 20 21 /** 22 * This method will have setup to start collecting the metrics. The default implementation is to 23 * invoke {@link #startCollecting()} directly. To apply the filters, must overload this method 24 * and use the filters. 25 * 26 * @param filters a filter which is used to filter unwanted metrics. 27 */ startCollecting(Function<String, Boolean> filters)28 default boolean startCollecting(Function<String, Boolean> filters) { 29 return startCollecting(); 30 } 31 32 /** 33 * This method will retrieve the metrics. 34 */ getMetrics()35 Map<String, T> getMetrics(); 36 37 /** 38 * This method will do the tear down to stop collecting the metrics. 39 */ stopCollecting()40 boolean stopCollecting(); 41 42 } 43