ResConfig, ResResSpec: added possibility to overwrite stored ResResource.

This commit is contained in:
Ryszard Wiśniewski 2010-09-01 22:30:24 +02:00
parent 6c98d60922
commit 4899344817
2 changed files with 12 additions and 2 deletions

View File

@ -56,8 +56,13 @@ public class ResConfig {
public void addResource(ResResource res)
throws AndrolibException {
addResource(res, false);
}
public void addResource(ResResource res, boolean overwrite)
throws AndrolibException {
ResResSpec spec = res.getResSpec();
if (mResources.put(spec, res) != null) {
if (mResources.put(spec, res) != null && ! overwrite) {
throw new AndrolibException(String.format(
"Multiple resources: spec=%s, config=%s", spec, this));
}

View File

@ -107,8 +107,13 @@ public class ResResSpec {
public void addResource(ResResource res)
throws AndrolibException {
addResource(res, false);
}
public void addResource(ResResource res, boolean overwrite)
throws AndrolibException {
ResConfigFlags flags = res.getConfig().getFlags();
if (mResources.put(flags, res) != null) {
if (mResources.put(flags, res) != null && ! overwrite) {
throw new AndrolibException(String.format(
"Multiple resources: spec=%s, config=%s", this, flags));
}