Reference Guide

Table Of Contents
devices = new HashMap<Id<Switch, UUID>, Switch>();
idCount = new AtomicLong(1);
}
public void setAlertService(AlertService alertService) {
this.alertService = alertService;
}
@Override
public Switch create(String name) {
Switch device = new Switch(name);
if (isEmpty(device.name())) {
device.setName("Switch-" + device.getId().getValue().toString());
}
devices.put(device.getId(), device);
return device;
}
@Override
public Collection<Switch> getAll() {
synchronized (devices) {
return Collections.unmodifiableCollection(devices.values());
}
}
@Override
public Switch get(Id<Switch, UUID> id) {
if (id == null) {
throw new NullPointerException("id cannot be null");
}
synchronized (devices) {
Switch s = devices.get(id);
if (s == null)
throw new NotFoundException("Switch with id " + id + "not
found");
return s;
}
}
@Override
public void delete(Id<Switch, UUID> id) {
if (id == null) {
209