Search in sources :

Example 1 with TagSpecificationsJson

use of com.sequenceiq.cloudbreak.api.model.TagSpecificationsJson in project cloudbreak by hortonworks.

the class TagSpecificationsToTagSpecificationsJsonConverter method convert.

@Override
public TagSpecificationsJson convert(Map<Platform, PlatformParameters> source) {
    TagSpecificationsJson json = new TagSpecificationsJson();
    Map<String, Map<String, Object>> specifications = new HashMap<>();
    json.setSpecifications(specifications);
    source.keySet().forEach(p -> {
        TagSpecification ts = source.get(p).tagSpecification();
        Map<String, Object> specification = Collections.emptyMap();
        if (ts != null) {
            specification = new HashMap<>();
            specification.put("maxAmount", ts.getMaxAmount());
            specification.put("keyLength", ts.getKeyLength());
            specification.put("keyValidator", ts.getKeyValidator());
            specification.put("valueLength", ts.getValueLength());
            specification.put("valueValidator", ts.getValueValidator());
        }
        specifications.put(p.value(), specification);
    });
    return json;
}
Also used : TagSpecificationsJson(com.sequenceiq.cloudbreak.api.model.TagSpecificationsJson) HashMap(java.util.HashMap) TagSpecification(com.sequenceiq.cloudbreak.cloud.model.TagSpecification) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

TagSpecificationsJson (com.sequenceiq.cloudbreak.api.model.TagSpecificationsJson)1 TagSpecification (com.sequenceiq.cloudbreak.cloud.model.TagSpecification)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1