
org.robolectric.res.ResBunch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of robolectric-resources Show documentation
Show all versions of robolectric-resources Show documentation
An alternative Android testing framework.
package org.robolectric.res;
import java.util.LinkedHashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
public class ResBunch {
private final Map> types = new LinkedHashMap<>();
public void put(String attrType, String name, TypedResource value, XmlLoader.XmlContext xmlContext) {
ResBundle bundle = getBundle(attrType);
bundle.put(attrType, name, value, xmlContext);
}
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(@NotNull ResName resName, String qualifiers) {
ResBundle.Value value = getValue(resName, qualifiers);
return value == null ? null : value.getValue();
}
public ResBundle.Value getValue(@NotNull ResName resName, String qualifiers) {
ResBundle bundle = getBundle(resName.type);
return bundle.getValue(resName, qualifiers);
}
public int size() {
int size = 0;
for (ResBundle bundle : types.values()) {
size += bundle.size();
}
return size;
}
public void makeImmutable() {
for (ResBundle bundle : types.values()) {
bundle.makeImmutable();
}
}
public void mergeLibraryStyle(ResBunch fromResBundle, String packageName) {
for (Map.Entry> entry : fromResBundle.types.entrySet()) {
getBundle(entry.getKey()).mergeLibraryStyle(entry.getValue(), packageName);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy