All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.robolectric.res.ResBunch Maven / Gradle / Ivy

There is a newer version: 4.14.1
Show newest version
package org.robolectric.res;

import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import org.robolectric.res.android.ResTable_config;

public class ResBunch {
  private final Map types = new LinkedHashMap<>();

  public void put(ResName resName, TypedResource value) {
    ResBundle bundle = getBundle(resName.type);
    bundle.put(resName, value);
  }

  private ResBundle getBundle(String attrType) {
    ResBundle bundle = types.get(attrType);
    if (bundle == null) {
      bundle = new ResBundle();
      types.put(attrType, bundle);
    }
    return bundle;
  }

  public TypedResource get(@Nonnull ResName resName, ResTable_config config) {
    ResBundle bundle = getBundle(resName.type);
    return bundle.get(resName, config);
  }

  void receive(ResourceTable.Visitor visitor) {
    for (ResBundle resBundle : types.values()) {
      resBundle.receive(visitor);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy