> + builder.readers(Splitter.on(' ').split(from.get("readers")));
> + if (from.containsKey("size"))
> + builder.size(Long.valueOf(from.get("size")));
> + if (from.containsKey("rawsize"))
> + builder.rawSize(Long.valueOf(from.get("rawsize")));
> + if (from.containsKey("format"))
> + builder.format(ImageConversionType.fromValue(from.get("format")));
> + Map<String, String> metadata = Maps.newLinkedHashMap();
> + for (Entry<String, String> entry : from.entrySet()) {
> + if (entry.getKey().startsWith("user:"))
> +
> metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1),
> entry.getValue());
> + }
> + builder.userMetadata(metadata);
> + try {
> + return builder.build();
> + } catch (NullPointerException e) {
I really don't lie this. Again, it's legacy code I've kept from similar classes
parsing other objects.
What I really don't like is returning `null` instead of failing when some field
is missing (what does it mean to return null here?), but the code is quite
sensible: there are the different ElasticHosts providers, ServerLove,
OpenHosting, SkaliCloud and Go2Cloud depending on this API, and I really don't
want to change this behavior right now. Just want to fix the broken providers
and get them working!
That said, having the null checks in each if statement would lead to a lot of
boilerplate to return null if the value is null, otherwise add it to the map.
WDYT?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/362/files#r13038556