All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.plugin.framework.util.MetadataUtil Maven / Gradle / Ivy

package com.nepxion.discovery.plugin.framework.util;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import com.nepxion.discovery.common.constant.DiscoveryConstant; public class MetadataUtil { public static void filter(Map metadata) { Properties properties = System.getProperties(); Set propertyNames = properties.stringPropertyNames(); for (String propertyName : propertyNames) { if (propertyName.startsWith(DiscoveryConstant.METADATA + ".")) { String key = propertyName.substring((DiscoveryConstant.METADATA + ".").length()); String value = properties.get(propertyName).toString(); metadata.put(key, value); } } } public static void filter(List metadata) { Properties properties = System.getProperties(); Set propertyNames = properties.stringPropertyNames(); for (String propertyName : propertyNames) { if (propertyName.startsWith(DiscoveryConstant.METADATA + ".")) { String key = propertyName.substring((DiscoveryConstant.METADATA + ".").length()); String value = properties.get(propertyName).toString(); int index = getIndex(metadata, key); if (index > -1) { metadata.set(index, key + "=" + value); } else { metadata.add(key + "=" + value); } } } } public static int getIndex(List metadata, String key) { for (int i = 0; i < metadata.size(); i++) { String value = metadata.get(i); if (value.startsWith(key + "=")) { return i; } } return -1; } public static boolean containsKey(List metadata, String key) { for (String value : metadata) { if (value.startsWith(key + "=")) { return true; } } return false; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy