Reference Guide

Table Of Contents
SwitchManager.java (Sample Application Service Implementation):
package com.hp.hm.impl;
...
public class SwitchManager implements SwitchService {
@Override
public Switch create(String name) {
Switch s = new Switch(name);
if (isEmpty(s.name()) {
s.setname("Switch-" + s.getId().getValue().toString());
}
store.put(s.getId(), s);
return s;
}
@Override
public Collection<Switch> getAll() {
synchronized (store) {
return Collections.unmodifiableCollection(store.values());
}
}
@Override
public Switch get(Id<Switch, UUID> id) {
synchronized (store) {
Switch s = store.get(id);
if (s == null)
throw new NotFoundException("Switch with id " + id +
" not found");
return s;
}
}
@Override
public void delete(Id<Switch, UUID> id) {
synchronized (store) {
Switch s = store.remove(id);
if (s == null)
throw new NotFoundException("Switch with id " + id +
" not found");
}
}
}
158