Example usage for java.util Map values

List of usage examples for java.util Map values

Introduction

In this page you can find the example usage for java.util Map values.

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:Main.java

/**
 *//*from  ww  w .j a  v a  2 s .  c  om*/
public static ArrayList<Element> mergeByAttrib(ArrayList<Element> master, ArrayList<Element> slave,
        String attrib) throws Exception {
    Map<String, Element> masterMap = mapFromArrayListByAttribute(master, attrib);
    Map<String, Element> slaveMap = mapFromArrayListByAttribute(slave, attrib);
    slaveMap.putAll(masterMap);

    ArrayList<Element> res = new ArrayList<Element>();
    Collection<Element> collection = slaveMap.values();
    for (Element e : collection) {
        res.add(e);
    }
    return res;
}

From source file:org.xmatthew.spy2servers.core.context.ComponentContextUtils.java

@SuppressWarnings("unchecked")
public static ComponentContext getComponentContext(ApplicationContext context) {
    Map beansMap = context.getBeansOfType(Component.class);
    if (beansMap != null) {

        List<Component> components = new ArrayList<Component>(beansMap.size());
        components.addAll(beansMap.values());
        ComponentContext componentContext = new ComponentContext();
        componentContext.setComponents(components);
        return componentContext;
    }//from w w w  . j  a  va  2s  .co  m
    return null;
}

From source file:com.brienwheeler.lib.spring.beans.AutowireUtils.java

public static <T> Collection<T> getAutowireBeans(ApplicationContext applicationContext, Class<T> clazz,
        Log log) {//ww w. j a v a 2s . c  o m
    ValidationUtils.assertNotNull(applicationContext, "applicationContext cannot be null");
    ValidationUtils.assertNotNull(clazz, "clazz cannot be null");
    ValidationUtils.assertNotNull(log, "log cannot be null");

    Map<String, T> beans = applicationContext.getBeansOfType(clazz);
    if (beans.size() > 0) {
        log.info("autowiring " + beans.size() + " " + clazz.getSimpleName());
    }
    return beans.values();
}

From source file:com.microsoft.azure.shortcuts.resources.samples.NetworkSecurityGroupsSample.java

public static void test(Subscription subscription) throws Exception {
    String newNetworkSecurityGroupName = "testNSG";

    // Listing all network security groups
    Map<String, NetworkSecurityGroup> nsgs = subscription.networkSecurityGroups().asMap();
    System.out.println("Network security groups:");
    for (NetworkSecurityGroup nsg : nsgs.values()) {
        printNSG(nsg);//from   w  ww  .jav a2s .c o m
    }

    // Create a NSG in a default new group
    NetworkSecurityGroup nsgMinimal = subscription.networkSecurityGroups().define(newNetworkSecurityGroupName)
            .withRegion(Region.US_WEST).withNewResourceGroup().create();

    // Get info about a specific NSG using its group and name
    nsgMinimal = subscription.networkSecurityGroups(nsgMinimal.id());
    nsgMinimal = subscription.networkSecurityGroups().get(nsgMinimal.id());
    String groupNameCreated = nsgMinimal.resourceGroup();
    printNSG(nsgMinimal);

    // More detailed NSG definition
    NetworkSecurityGroup nsg = subscription.networkSecurityGroups().define(newNetworkSecurityGroupName + "2")
            .withRegion(Region.US_WEST).withExistingResourceGroup(groupNameCreated).defineRule("rule1")
            .allowInbound().fromAnyAddress().fromPort(80).toAddress("10.0.0.0/29").toPort(80)
            .withProtocol(Protocol.TCP).attach().defineRule("rule2").denyOutbound().fromAnyAddress()
            .fromAnyPort().toAnyAddress().toAnyPort().withProtocol(Protocol.UDP).attach().create();

    // Listing NSGs in a specific resource group
    nsgs = subscription.networkSecurityGroups().asMap(groupNameCreated);
    System.out.println(String.format("NSG ids in group '%s': \n\t%s", groupNameCreated,
            StringUtils.join(nsgs.keySet(), ",\n\t")));

    // Get info about a specific PIP using its resource ID
    nsg = subscription.networkSecurityGroups(nsg.resourceGroup(), nsg.name());
    printNSG(nsg);

    // Delete the NSG
    nsgMinimal.delete();
    nsg.delete();

    // Delete the auto-created group
    subscription.resourceGroups(groupNameCreated).delete();
}

From source file:cognition.pipeline.Main.java

/**
 * @return The available commands that can be processed.
 *///  www. j a  v  a  2s  . com
public static Options getOptions() {
    Map<String, CommandProcessor> commands = context.getBeansOfType(CommandProcessor.class);
    Options options = new Options();

    for (CommandProcessor commandProcessor : commands.values()) {
        commandProcessor.addOption(options);
    }

    return options;
}

From source file:com.google.api.server.spi.ObjectMapperUtil.java

private static boolean isEmpty(Object value) {
    Class<?> clazz = value.getClass();
    if (clazz.isArray()) {
        int len = Array.getLength(value);
        for (int i = 0; i < len; i++) {
            Object element = Array.get(value, i);
            if (element != null && !isEmpty(element)) {
                return false;
            }/*  w  ww .java 2s. c o  m*/
        }
        return true;
    } else if (Collection.class.isAssignableFrom(clazz)) {
        Collection<?> c = (Collection<?>) value;
        for (Object element : c) {
            if (element != null && !isEmpty(element)) {
                return false;
            }
        }
        return true;
    } else if (Map.class.isAssignableFrom(clazz)) {
        Map<?, ?> m = (Map<?, ?>) value;
        for (Object entryValue : m.values()) {
            if (entryValue != null && !isEmpty(entryValue)) {
                return false;
            }
        }
        return true;
    }
    return false;
}

From source file:com.alibaba.dragoon.patrol.kv.PassiveSender.java

/**
 * @param kvMap/*from ww w. ja v  a2 s . c o  m*/
 */
private static boolean isVaildClassType(Map<String, Object> kvMap) {
    for (Object value : kvMap.values()) {
        if (value != null && !KVItem.isVaildClassType(value.getClass())) {
            throw new DragoonException("not be supported, class type:" + value.getClass());
        }
    }
    return true;
}

From source file:Main.java

public static <K, V> List<V> getValueListByIndexes(Map<K, V> map, int[] indexes) {
    if ((indexes == null) || (indexes.length == 0)) {
        return null;
    }//from  w  w w .jav  a 2s.c o  m
    List<V> valueList = new ArrayList<V>(indexes.length);
    int i = 0;
    for (V value : map.values()) {
        for (int index : indexes) {
            if (i == index) {
                valueList.add(value);
            }
        }
        i++;
    }
    return valueList;
}

From source file:com.phoenixnap.oss.ramlapisync.naming.RamlHelper.java

/**
 * Adjusts Relative and base uris in the resource objects
 * /*from w w w  . ja v a  2s .  c  om*/
 * @param resources resources to check
 * @param urlPrefixToIgnore uri to remove
 */
private static void removeUri(Map<String, RamlResource> resources, String urlPrefixToIgnore) {
    for (RamlResource resource : resources.values()) {
        resource.setParentUri(resource.getParentUri().replace(urlPrefixToIgnore, ""));
        resource.setRelativeUri(resource.getRelativeUri().replace(urlPrefixToIgnore, ""));
        removeUri(resource.getResources(), urlPrefixToIgnore);
    }
}

From source file:com.microsoft.azure.shortcuts.resources.samples.NetworkInterfacesSample.java

public static void testProvisionMinimal(Subscription subscription) throws Exception {
    String suffix = String.valueOf(System.currentTimeMillis());
    String newNICName = "nic" + suffix;
    NetworkInterface nic = subscription.networkInterfaces().define(newNICName).withRegion(Region.US_WEST)
            .withNewResourceGroup().withNewNetwork("10.0.0.0/28").withPrivateIpAddressDynamic()
            .withoutPublicIpAddress().create();

    String newGroupName = nic.resourceGroup();
    nic = subscription.networkInterfaces().get(nic.id());
    printNetworkInterface(nic);/*from   w w  w .  j a v a  2 s . co m*/

    // Listing all network interfaces
    Map<String, NetworkInterface> nics = subscription.networkInterfaces().asMap();
    System.out.println("Network interfaces:");
    for (NetworkInterface n : nics.values()) {
        printNetworkInterface(n);
    }

    // Listing network interfaces in a specific resource group
    nics = subscription.networkInterfaces().asMap(newGroupName);
    System.out.println(String.format("Network interface ids in group '%s': \n\t%s", newGroupName,
            StringUtils.join(nics.keySet(), ",\n\t")));

    nic.delete();
}