1 package org.robolectric.res; 2 3 import java.util.LinkedHashMap; 4 import java.util.Map; 5 import javax.annotation.Nonnull; 6 import org.robolectric.res.android.ResTable_config; 7 8 public class ResBunch { 9 private final Map<String, ResBundle> types = new LinkedHashMap<>(); 10 put(ResName resName, TypedResource value)11 public void put(ResName resName, TypedResource value) { 12 ResBundle bundle = getBundle(resName.type); 13 bundle.put(resName, value); 14 } 15 getBundle(String attrType)16 private ResBundle getBundle(String attrType) { 17 ResBundle bundle = types.get(attrType); 18 if (bundle == null) { 19 bundle = new ResBundle(); 20 types.put(attrType, bundle); 21 } 22 return bundle; 23 } 24 get(@onnull ResName resName, ResTable_config config)25 public TypedResource get(@Nonnull ResName resName, ResTable_config config) { 26 ResBundle bundle = getBundle(resName.type); 27 return bundle.get(resName, config); 28 } 29 receive(ResourceTable.Visitor visitor)30 void receive(ResourceTable.Visitor visitor) { 31 for (ResBundle resBundle : types.values()) { 32 resBundle.receive(visitor); 33 } 34 } 35 } 36