> Map<String,Object> scalingPolicyMap = Maps.newHashMap();
> scalingPoliciesList.add(scalingPolicyMap);
> scalingPolicyMap.put("cooldown", scalingPolicy.getCooldown());
> scalingPolicyMap.put("type", scalingPolicy.getType().toString());
> scalingPolicyMap.put("name", scalingPolicy.getName());
> // A couple of different scaling policies are supported, such as
> percent or number based, or targeting specific numbers of instances
> - scalingPolicyMap.put(scalingPolicy.getTargetType().toString(),
> scalingPolicy.getTarget());
> + String targetString = scalingPolicy.getTarget();
> + Integer targetInt = Ints.tryParse(targetString);
> + Float targetFloat;
> + if (targetInt != null) {
> + scalingPolicyMap.put(scalingPolicy.getTargetType().toString(),
> targetInt);
> + } else if ((targetFloat = Floats.tryParse(targetString)) != null) {
> + scalingPolicyMap.put(scalingPolicy.getTargetType().toString(),
> targetFloat);
> + } else {
> + scalingPolicyMap.put(scalingPolicy.getTargetType().toString(),
> targetString);
> + }
> I do like the simple enum type
Would this make the enum dramatically more complicated? But if, as you say,
this parsing thing is still "work in progress", then we can indeed wait until
that's settled down before making decisions.
In that case, add a code comment here to document this?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/39/files#r7294919