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:io.kahu.hawaii.util.spring.ApplicationContextProvider.java

public static <T> Collection<T> getBeans(Class<T> beanClass) {
    Map<String, T> beansOfType = context.getBeansOfType(beanClass);
    return beansOfType.values();
}

From source file:Main.java

public static <K, V> boolean isDistinctValues(Map<K, V> in) {
    if (in == null) {
        return true;
    }//from  w  w w  .  j  a  v a 2  s.  c  om
    return isDistinct(in.values());
}

From source file:Main.java

/**
 * Returns the string that represents the content of a given style map.
 * @param styleMap Map with the styles values
 * @return string that represents the style.
 *//*w w w. j  a  v  a 2 s  .  co  m*/
public static String getStyleString(Map<String, Object> styleMap, String asig) {
    String style = "";
    Iterator<Object> it = styleMap.values().iterator();
    Iterator<String> kit = styleMap.keySet().iterator();

    while (kit.hasNext()) {
        String key = kit.next();
        Object value = it.next();
        style = style + key + asig + value + ";";
    }
    return style;
}

From source file:Main.java

License:asdf

@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> sort(Map<K, V> in, Comparator<? super V> compare) {
    Map<K, V> result = new LinkedHashMap<K, V>();
    V[] array = (V[]) in.values().toArray();
    for (int i = 0; i < array.length; i++) {

    }//from   ww w .j a  v  a2s  . c  o  m
    Arrays.sort(array, compare);
    for (V item : array) {
        K key = (K) getKey(in, item);
        result.put(key, item);
    }
    return result;
}

From source file:Main.java

public static <K, V> List<V> valueToList(Map<K, V> map) {
    if (isNotNull(map)) {
        return new ArrayList<V>(map.values());
    }/*from www .ja  va  2 s  . c  om*/
    return null;
}

From source file:Main.java

public static Activity getCurrentTopActivity()
        throws ClassNotFoundException, IllegalArgumentException, SecurityException, IllegalAccessException,
        InvocationTargetException, NoSuchMethodException, NoSuchFieldException {
    Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
    Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
    Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
    activitiesField.setAccessible(true);
    Map<?, ?> activities = (Map<?, ?>) activitiesField.get(activityThread);
    for (Object activityRecord : activities.values()) {
        Class<?> activityRecordClass = activityRecord.getClass();
        Field pausedField = activityRecordClass.getDeclaredField("paused");
        pausedField.setAccessible(true);
        if (!pausedField.getBoolean(activityRecord)) {
            Field activityField = activityRecordClass.getDeclaredField("activity");
            activityField.setAccessible(true);
            Activity activity = (Activity) activityField.get(activityRecord);
            return activity;
        }/*from   w ww.  j av  a 2  s.c  o  m*/
    }
    return null;
}

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

public static void test(Subscription subscription) throws Exception {
    // List resource groups
    Set<String> groupNames = subscription.resourceGroups().asMap().keySet();
    System.out.println("Group names: \n\t" + StringUtils.join(groupNames, ",\n\t"));

    Map<String, ResourceGroup> groups = subscription.resourceGroups().asMap();
    for (ResourceGroup group : groups.values()) {
        printGroup(group);/* w  w  w.j av a2s. co  m*/
    }

    // Create a resource group
    String groupName = "group" + String.valueOf(System.currentTimeMillis());
    System.out.println("Creating group " + groupName);
    subscription.resourceGroups().define(groupName).withRegion(Region.US_WEST).withTag("hello", "world")
            .create();

    // Read a specific resource group
    ResourceGroup resourceGroup = subscription.resourceGroups(groupName);
    printGroup(resourceGroup);

    // Update a resource group
    subscription.resourceGroups().update(groupName).withTag("foo", "bar").withoutTag("hello").apply();

    // Delete a specific resource group
    System.out.println("Deleting group " + groupName);
    subscription.resourceGroups(groupName).delete();
}

From source file:Main.java

public static <K, V> Set<V> valueToTreeSet(Map<K, V> map) {
    if (isNotNull(map)) {
        Set<V> set = new TreeSet<>();
        for (V v : map.values()) {
            System.out.println(v.hashCode());
            System.out.println(set.contains(v));
            set.add(v);/*from  w  w  w .j a  v a 2 s.c  om*/
        }
        return set;
    }
    return null;
}

From source file:com.asual.summer.core.util.BeanUtils.java

public static <T> T getBeanOfType(ConfigurableListableBeanFactory beanFactory, Class<T> clazz) {
    Map<String, T> beans = beanFactory.getBeansOfType(clazz);
    ArrayList<T> values = new ArrayList<T>(beans.values());
    if (values.size() != 0) {
        OrderComparator.sort(values);/*from  ww  w .  jav a  2 s.c  o m*/
        return values.get(0);
    }
    return null;
}

From source file:tomekkup.helenos.context.PostConfiguringClusterListener.java

public static void propagadeConfigChanges(ApplicationContext applicationContext, Cluster cluster) {
    Map<String, ClusterConfigAware> beans = applicationContext.getBeansOfType(ClusterConfigAware.class);
    for (ClusterConfigAware bean : beans.values()) {
        bean.setNewCluster(cluster);/*w  w  w  .  ja v  a 2 s .  c  om*/
    }
}