Example usage for java.util Set iterator

List of usage examples for java.util Set iterator

Introduction

In this page you can find the example usage for java.util Set iterator.

Prototype

Iterator<E> iterator();

Source Link

Document

Returns an iterator over the elements in this set.

Usage

From source file:de.metas.ui.web.window.datatypes.json.JSONLookupValue.java

public static final StringLookupValue stringLookupValueFromJsonMap(final Map<String, String> map) {
    final Set<Map.Entry<String, String>> entrySet = map.entrySet();
    if (entrySet.size() != 1) {
        throw new IllegalArgumentException("Invalid JSON lookup value: map=" + map);
    }//from ww w  . jav a 2 s  .c  o  m
    final Map.Entry<String, String> e = entrySet.iterator().next();

    final String id = e.getKey();
    final String name = e.getValue();

    return StringLookupValue.of(id, name);
}

From source file:it.jnrpe.server.CJNRPEServer.java

private static void printPluginList() {
    Set vPlugins = CPluginFactory.getInstance().getPluginList();

    System.out.println("List of installed plugins : ");

    //for (String sPluginName : vPlugins)
    for (Iterator iter = vPlugins.iterator(); iter.hasNext();)
        System.out.println("  * " + iter.next());

    System.exit(0);/*from  w  w w.  j  a va2s .  co  m*/
}

From source file:com.facebook.infrastructure.db.RowMutation.java

public static RowMutation getRowMutation(batch_mutation_super_t batchMutationSuper) {
    RowMutation rm = new RowMutation(batchMutationSuper.table, batchMutationSuper.key.trim());
    Set keys = batchMutationSuper.cfmap.keySet();
    Iterator keyIter = keys.iterator();
    while (keyIter.hasNext()) {
        Object key = keyIter.next(); // Get the next key.
        List<superColumn_t> list = batchMutationSuper.cfmap.get(key);
        for (superColumn_t superColumnData : list) {
            if (superColumnData.columns.size() != 0) {
                for (column_t columnData : superColumnData.columns) {
                    rm.add(key.toString() + ":" + superColumnData.name + ":" + columnData.columnName,
                            columnData.value.getBytes(), columnData.timestamp);
                }//  ww w  .  j  a va 2  s .  com
            } else {
                rm.add(key.toString() + ":" + superColumnData.name, ArrayUtils.EMPTY_BYTE_ARRAY, 0);
            }
        }
    }
    return rm;
}

From source file:com.neusoft.mid.clwapi.tools.JacksonUtils.java

/**
 * @param obj// w w  w.j  av a 2 s  .  c om
 * @param f
 * @throws IllegalAccessException
 * @throws JacksonEncoderException
 */
private static Object jsonCoder(Object obj, Field f) throws IllegalAccessException, JacksonEncoderException {
    Object o = FieldUtils.readField(f, obj);
    if (o instanceof String) {
        FieldUtils.writeField(f, obj, jsonCoder((String) o, true));
    } else if (o instanceof Collection<?>) {
        logger.debug("Field [" + f.getName() + "] is " + o.getClass());
        Collection<?> c = (Collection<?>) o;
        Iterator<?> it = c.iterator();
        while (it.hasNext()) {
            jsonEncoder(it.next());
        }
    } else if (o instanceof Map<?, ?>) {
        logger.debug("Field [" + f.getName() + "] is " + o.getClass());
        Set<?> entries = ((Map<?, ?>) o).entrySet();
        Iterator<?> it = entries.iterator();
        while (it.hasNext()) {
            Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) it.next();
            logger.debug("Key is [" + entry.getKey() + "]");
            entry.setValue(jsonEncoder(entry.getValue()));
        }
    } else if (o instanceof Integer || o instanceof Byte || o instanceof Boolean || o instanceof Long
            || o instanceof Double || o instanceof Character || o instanceof Short || o instanceof Float
            || o instanceof Number) {
        return obj;
    } else {
        throw new JacksonEncoderException("??" + f.getClass());
    }
    return obj;
}

From source file:de.metas.ui.web.config.SwaggerConfig.java

@SuppressWarnings("unused")
private static final Predicate<RequestHandler> basePackages(final Class<?>... classes) {
    final Set<Predicate<RequestHandler>> predicates = new HashSet<>(classes.length);
    for (final Class<?> clazz : classes) {
        final String packageName = clazz.getPackage().getName();
        predicates.add(RequestHandlerSelectors.basePackage(packageName));
    }//from w w w . j a v  a2  s  . c  o  m

    if (predicates.size() == 1) {
        return predicates.iterator().next();
    }

    return Predicates.or(predicates);
}

From source file:de.metas.ui.web.window.datatypes.json.JSONLookupValue.java

public static final IntegerLookupValue integerLookupValueFromJsonMap(final Map<String, String> map) {
    final Set<Map.Entry<String, String>> entrySet = map.entrySet();
    if (entrySet.size() != 1) {
        throw new IllegalArgumentException("Invalid JSON lookup value: map=" + map);
    }//from   w ww  . ja  va  2  s  .co  m
    final Map.Entry<String, String> e = entrySet.iterator().next();

    String idStr = e.getKey();
    if (idStr == null) {
        return null;
    }
    idStr = idStr.trim();
    if (idStr.isEmpty()) {
        return null;
    }

    final int id = Integer.parseInt(idStr);
    final String name = e.getValue();

    return IntegerLookupValue.of(id, name);
}

From source file:kr.co.aim.nanoframe.nanoFrameServiceProxy.java

@Deprecated
public static Map<String, Map<String, String>> getObjectAttributeDef() {
    Map<String, Map<String, String>> returns = new HashMap<String, Map<String, String>>();
    ObjectAttributeMap attributeMap = getObjectAttributeMap();
    Map<String, List<ObjectAttributeDef>> map = attributeMap.getMap();
    Set<String> set = map.keySet();
    for (Iterator<String> iterator = set.iterator(); iterator.hasNext();) {
        String string = (String) iterator.next();
        String key = string.substring(string.lastIndexOf(".") + 1, string.length());

        if (ObjectAttributeMap.ExtendedC_Type.equals(key)) {
            List<ObjectAttributeDef> list = map.get(string);
            for (Iterator<ObjectAttributeDef> iter = list.iterator(); iter.hasNext();) {
                ObjectAttributeDef object = iter.next();
                if (returns.containsKey(object.getTypeName())) {
                    returns.get(object.getTypeName()).put(object.getAttributeName(), "");
                } else {
                    Map<String, String> objDefs = new HashMap<String, String>();
                    objDefs.put(object.getAttributeName(), "");
                    returns.put(object.getTypeName(), objDefs);
                }//from   w ww .j a v  a  2  s.c o m
            }
        }
    }
    return returns;
}

From source file:com.neusoft.mid.clwapi.tools.JacksonUtils.java

/**
 * String?//from w w  w .  j a va  2s. com
 * 
 * @param obj
 *            ?(?JavaBean,String,Collection,Map)
 * @return ??
 * @throws JacksonEncoderException
 *             jackson?
 */
public static Object jsonEncoder(Object obj) throws JacksonEncoderException {
    logger.debug("obj class is:" + obj.getClass());
    if (obj instanceof String) {
        return jsonCoder((String) obj, true);
    } else if (obj instanceof Map<?, ?>) {
        logger.debug("Object is " + obj.getClass());
        Set<?> entries = ((Map<?, ?>) obj).entrySet();
        Iterator<?> it = entries.iterator();
        while (it.hasNext()) {
            Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>) it.next();
            logger.debug("Key is [" + entry.getKey() + "]");
            entry.setValue(jsonEncoder(entry.getValue()));
        }
    } else if (obj instanceof Collection<?>) {
        logger.debug("Object is " + obj.getClass());
        Collection<?> c = (Collection<?>) obj;
        Iterator<?> it = c.iterator();
        while (it.hasNext()) {
            jsonEncoder(it.next());
        }
    } else {
        try {
            Field[] fields = obj.getClass().getFields();
            for (Field f : fields) {
                jsonCoder(obj, f);
            }
        } catch (IllegalAccessException e) {
            logger.error("json??" + e.getMessage());
            throw new JacksonEncoderException(e);
        }
    }
    return obj;
}

From source file:autocorrelator.apps.SDFGroovy.java

private static void setOutputFields(OEMolBase mol, Binding binding, Set<String> outFields) {
    Iterator<String> it = outFields.iterator();
    while (it.hasNext()) {
        String tag = it.next();//from  w  w w .j a  v a2s.co  m
        Object d = binding.getVariable(tag);
        if ("mol".equals(tag)) { // ignore as OEMolBase can be changed inplace
        } else if ("TITLE".equals(tag)) {
            if (d == null)
                d = "";
            mol.SetTitle(d.toString());
        } else {
            if (d == null)
                d = "";

            oechem.OEDeleteSDData(mol, tag);
            oechem.OESetSDData(mol, tag, d.toString());
        }
    }
}

From source file:com.infovity.iep.loader.util.SupplierLoaderUtil.java

public static int getUniqueNumber(Set<Integer> set) {
    Integer n = null;//from  w  w  w  . j a  va  2  s .  co  m
    Iterator itr = set.iterator();
    while (itr.hasNext()) {
        n = (Integer) itr.next();
    }
    set.remove(n);
    return n;
}