@Singleton
public class SizeToHardware implements Function<Size, Hardware> {
@Override
public Hardware apply(Size input) {
HardwareBuilder builder = new HardwareBuilder();
builder.id(input.getSlug());
builder.providerId(String.valueOf(input.getId()));
builder.name(input.getName());
builder.ram(input.getMemory());
// DigitalOcean does not provide the processor speed. We configure it to
// make the bigger template the faster.
builder.processor(new Processor(input.getCpu(), input.getCpu()));
builder.volume(new VolumeBuilder()
.size(Float.valueOf(input.getDisk()))
.type(Type.LOCAL)
.build());
ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
metadata.put("costPerHour", input.getCostPerHour());
metadata.put("costPerMonth", input.getCostPerMonth());
builder.userMetadata(metadata.build());
return builder.build();
}