Search in sources :

Example 1 with Experimental

use of io.micronaut.core.annotation.Experimental in project micronaut-core by micronaut-projects.

the class ComputeInstanceMetadataResolverUtils method populateMetadata.

/**
 * Populates the instance instance metadata's {@link AbstractComputeInstanceMetadata#setMetadata(Map)} property.
 *
 * @param instanceMetadata The instance metadata
 * @param metadata         A json object of metadata
 */
@Experimental
public static void populateMetadata(AbstractComputeInstanceMetadata instanceMetadata, JsonNode metadata) {
    if (metadata != null) {
        Map<String, String> finalMetadata = new HashMap<>(metadata.size());
        for (Map.Entry<String, JsonNode> entry : metadata.entries()) {
            JsonNode value = entry.getValue();
            if (value.isString()) {
                finalMetadata.put(entry.getKey(), value.getStringValue());
            }
        }
        instanceMetadata.setMetadata(finalMetadata);
    }
}
Also used : HashMap(java.util.HashMap) JsonNode(io.micronaut.json.tree.JsonNode) HashMap(java.util.HashMap) Map(java.util.Map) Experimental(io.micronaut.core.annotation.Experimental)

Aggregations

Experimental (io.micronaut.core.annotation.Experimental)1 JsonNode (io.micronaut.json.tree.JsonNode)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1