use of exceptions.ExistingIdException in project Lab5 by Arslanka.
the class Collection method add.
public void add(Dragon dragon) throws ExistingIdException, ExecutionException {
Integer dragonId = dragon.getId();
try {
if (dragon.validated() != null)
if (idMap.containsKey(dragonId))
if (idMap.containsKey(dragonId))
throw new ExistingIdException(String.format("%s %d %s", "There is already an object with id ", dragonId, "in the collection"));
idMap.put(dragonId, dragon);
dragonHashSet.add(dragon);
} catch (InvalidObjectFieldException e) {
throw new ExecutionException("You have entered incorrect fields for the dragon object\n" + e.getMessage(), e);
}
}
Aggregations