use of exceptions.ExecutionException in project Lab5 by Arslanka.
the class AddIfMaxCommand method execute.
@Override
public boolean execute(Object... args) {
try {
Dragon dragon = (Dragon) args[0];
collection.addIfMax(dragon);
printer.println("The item was successfully added to the collection", HELP);
printer.println(SEPARATOR, ERROR);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ExecutionException("You have not entered an item to add to the collection.");
}
return true;
}
use of exceptions.ExecutionException in project Lab5 by Arslanka.
the class CountGreaterThanKillerCommand method execute.
@Override
public boolean execute(Object... args) {
try {
Person person = (Person) args[0];
collection.countGreaterThanKiller(person);
printer.println(SEPARATOR, ERROR);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ExecutionException("You have not entered an item to add to the collection.");
}
return true;
}
use of exceptions.ExecutionException in project Lab5 by Arslanka.
the class RemoveAllByWeight method execute.
@Override
public boolean execute(Object... args) {
try {
Float weight = (Float) args[0];
collection.removeByWeight(weight);
printer.println(String.format("%s %f %s", "Elements whose weight field value is equivalent to", weight, "the specified one have been successfully removed from the collection"), HELP);
printer.println(SEPARATOR, ERROR);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ExecutionException("You have not entered an item to add to the collection.");
}
return true;
}
use of exceptions.ExecutionException in project Lab5 by Arslanka.
the class RemoveGreaterCommand method execute.
@Override
public boolean execute(Object... args) {
try {
collection.removeGreater((Dragon) args[0]);
printer.println("Elements whose value is greater than the specified value have been successfully removed from the collection", HELP);
printer.println(SEPARATOR, ERROR);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ExecutionException("You have not entered an element for comparison.");
}
return true;
}
use of exceptions.ExecutionException in project Lab5 by Arslanka.
the class SaveCommand method execute.
@Override
public boolean execute(Object... args) {
try {
collection.save((JsonFile) args[0]);
printer.println("The collection is saved to " + args[0], HELP);
printer.println(SEPARATOR, ERROR);
} catch (InputOutputException | NullPointerException | ArrayIndexOutOfBoundsException e) {
throw new ExecutionException("You have not entered an JsonFile.");
}
return true;
}
Aggregations