package com.squareup.leakcanary; import com.squareup.leakcanary.HeapDump; import com.squareup.leakcanary.Reachability; import com.squareup.leakcanary.RefWatcherBuilder; import java.util.Collections; import java.util.List; /* loaded from: classes.dex */ public class RefWatcherBuilder> { private DebuggerControl debuggerControl; private GcTrigger gcTrigger; private final HeapDump.Builder heapDumpBuilder = new HeapDump.Builder(); private HeapDump.Listener heapDumpListener; private HeapDumper heapDumper; private WatchExecutor watchExecutor; public final RefWatcher build() { if (isDisabled()) { return RefWatcher.DISABLED; } HeapDump.Builder builder = this.heapDumpBuilder; if (builder.excludedRefs == null) { builder.excludedRefs(defaultExcludedRefs()); } HeapDump.Listener listener = this.heapDumpListener; if (listener == null) { listener = defaultHeapDumpListener(); } HeapDump.Listener listener2 = listener; DebuggerControl debuggerControl = this.debuggerControl; if (debuggerControl == null) { debuggerControl = defaultDebuggerControl(); } DebuggerControl debuggerControl2 = debuggerControl; HeapDumper heapDumper = this.heapDumper; if (heapDumper == null) { heapDumper = defaultHeapDumper(); } HeapDumper heapDumper2 = heapDumper; WatchExecutor watchExecutor = this.watchExecutor; if (watchExecutor == null) { watchExecutor = defaultWatchExecutor(); } WatchExecutor watchExecutor2 = watchExecutor; GcTrigger gcTrigger = this.gcTrigger; if (gcTrigger == null) { gcTrigger = defaultGcTrigger(); } GcTrigger gcTrigger2 = gcTrigger; HeapDump.Builder builder2 = this.heapDumpBuilder; if (builder2.reachabilityInspectorClasses == null) { builder2.reachabilityInspectorClasses(defaultReachabilityInspectorClasses()); } return new RefWatcher(watchExecutor2, debuggerControl2, gcTrigger2, heapDumper2, listener2, this.heapDumpBuilder); } public final T computeRetainedHeapSize(boolean z) { this.heapDumpBuilder.computeRetainedHeapSize(z); return self(); } public final T debuggerControl(DebuggerControl debuggerControl) { this.debuggerControl = debuggerControl; return self(); } protected DebuggerControl defaultDebuggerControl() { return DebuggerControl.NONE; } protected ExcludedRefs defaultExcludedRefs() { return ExcludedRefs.builder().build(); } protected GcTrigger defaultGcTrigger() { return GcTrigger.DEFAULT; } protected HeapDump.Listener defaultHeapDumpListener() { return HeapDump.Listener.NONE; } protected HeapDumper defaultHeapDumper() { return HeapDumper.NONE; } protected List> defaultReachabilityInspectorClasses() { return Collections.emptyList(); } protected WatchExecutor defaultWatchExecutor() { return WatchExecutor.NONE; } public final T excludedRefs(ExcludedRefs excludedRefs) { this.heapDumpBuilder.excludedRefs(excludedRefs); return self(); } public final T gcTrigger(GcTrigger gcTrigger) { this.gcTrigger = gcTrigger; return self(); } public final T heapDumpListener(HeapDump.Listener listener) { this.heapDumpListener = listener; return self(); } public final T heapDumper(HeapDumper heapDumper) { this.heapDumper = heapDumper; return self(); } protected boolean isDisabled() { return false; } protected final T self() { return this; } public final T stethoscopeClasses(List> list) { this.heapDumpBuilder.reachabilityInspectorClasses(list); return self(); } public final T watchExecutor(WatchExecutor watchExecutor) { this.watchExecutor = watchExecutor; return self(); } }