package com.bumptech.glide.load.data; import com.bumptech.glide.load.data.DataRewinder; import com.bumptech.glide.util.Preconditions; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /* loaded from: classes.dex */ public class DataRewinderRegistry { private static final DataRewinder.Factory b = new DataRewinder.Factory() { // from class: com.bumptech.glide.load.data.DataRewinderRegistry.1 @Override // com.bumptech.glide.load.data.DataRewinder.Factory public DataRewinder a(Object obj) { return new DefaultRewinder(obj); } @Override // com.bumptech.glide.load.data.DataRewinder.Factory public Class a() { throw new UnsupportedOperationException("Not implemented"); } }; private final Map, DataRewinder.Factory> a = new HashMap(); private static final class DefaultRewinder implements DataRewinder { private final Object a; DefaultRewinder(Object obj) { this.a = obj; } @Override // com.bumptech.glide.load.data.DataRewinder public Object a() { return this.a; } @Override // com.bumptech.glide.load.data.DataRewinder public void b() { } } public synchronized void a(DataRewinder.Factory factory) { this.a.put(factory.a(), factory); } public synchronized DataRewinder a(T t) { DataRewinder.Factory factory; Preconditions.a(t); factory = this.a.get(t.getClass()); if (factory == null) { Iterator> it = this.a.values().iterator(); while (true) { if (!it.hasNext()) { break; } DataRewinder.Factory next = it.next(); if (next.a().isAssignableFrom(t.getClass())) { factory = next; break; } } } if (factory == null) { factory = b; } return (DataRewinder) factory.a(t); } }