*/
@Override
@SuppressWarnings("unchecked")
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
DataCenterInfo info = null;
while (reader.hasMoreChildren()) {
reader.moveDown();
if (ELEM_NAME.equals(reader.getNodeName())) {
final String dataCenterName = reader.getValue();
if (DataCenterInfo.Name.Amazon.name().equalsIgnoreCase(
dataCenterName)) {
info = new AmazonInfo();
} else {
final DataCenterInfo.Name name =
DataCenterInfo.Name.valueOf(dataCenterName);
info = new DataCenterInfo() {
@Override
public Name getName() {
return name;
}
};
}
} else if (NODE_METADATA.equals(reader.getNodeName())) {
if (info.getName() == Name.Amazon) {
((AmazonInfo) info)
.setMetadata((Map<String, String>) context
.convertAnother(info, Map.class));
}
}