Author: [log in to unmask]
Date: Wed Dec 16 15:33:55 2015
New Revision: 3698
Log:
Print a warning instead of throwing an exception when duplicate materials or elements are added (they are just ignored).
Modified:
projects/lcsim/branches/jeremy-dev/detector-framework/src/main/java/org/lcsim/material/MaterialManager.java
Modified: projects/lcsim/branches/jeremy-dev/detector-framework/src/main/java/org/lcsim/material/MaterialManager.java
=============================================================================
--- projects/lcsim/branches/jeremy-dev/detector-framework/src/main/java/org/lcsim/material/MaterialManager.java (original)
+++ projects/lcsim/branches/jeremy-dev/detector-framework/src/main/java/org/lcsim/material/MaterialManager.java Wed Dec 16 15:33:55 2015
@@ -73,12 +73,14 @@
throw new IllegalArgumentException("Argument points to null.");
}
- if (getMaterial(material.getName()) != null)
+ if (getMaterial(material.getName()) == null)
{
- throw new RuntimeException("Material with name " + material.getName() + " already exists.");
+ _materials.put(material.getName(), material);
+ }
+ else
+ {
+ System.err.println("Material with name " + material.getName() + " already exists so addMaterial is ignored!");
}
-
- _materials.put(material.getName(), material);
}
/**
@@ -104,7 +106,8 @@
}
else
{
- throw new RuntimeException("MaterialElement already exists: " + me.getName());
+ // throw new RuntimeException("MaterialElement already exists: " + me.getName());
+ System.err.println("Element " + me.getName() + " already exists so addElement is ignored!");
}
}
@@ -151,4 +154,4 @@
// Set instance to null;
_instance = null;
}
-}
+}
########################################################################
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1
|