Example usage for java.util LinkedHashSet LinkedHashSet

List of usage examples for java.util LinkedHashSet LinkedHashSet

Introduction

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

Prototype

public LinkedHashSet() 

Source Link

Document

Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).

Usage

From source file:Main.java

public static <T> Set<T> toSet(Iterable<? extends T> things) {
    if (things == null) {
        return new HashSet<T>(0);
    }/*  w w  w.j  a v  a  2  s .co  m*/
    if (things instanceof Set) {
        @SuppressWarnings("unchecked")
        Set<T> castThings = (Set<T>) things;
        return castThings;
    }

    Set<T> set = new LinkedHashSet<T>();
    for (T thing : things) {
        set.add(thing);
    }
    return set;
}

From source file:Main.java

static void appendProp(Map<String, Object> properties, String key, Object valueToAppend) {
    properties.putIfAbsent(key, new LinkedHashSet<String>());
    ((Collection<String>) properties.get(key)).add(valueToAppend.toString());
}

From source file:Main.java

static void appendProps(Map<String, Object> properties, String key, Iterable<?> valuesToAppend) {
    properties.putIfAbsent(key, new LinkedHashSet<String>());
    StreamSupport.stream(valuesToAppend.spliterator(), false)
            .forEach(v -> ((Collection<String>) properties.get(key)).add(v.toString()));
}

From source file:com.ro.ssc.app.client.utils.AccessReader.java

public static List<Set<String>> updateUserMap(File file) {

    Set<String> excludedGates = new LinkedHashSet<>();
    Set<String> excludedUsers = new LinkedHashSet<>();
    Set<String> idMapping = new LinkedHashSet<>();
    List<Set<String>> result = new LinkedList<>();

    Table table;/*from  w  ww.  ja v  a2 s .  co  m*/
    try {

        table = DatabaseBuilder.open(file).getTable("t_b_Reader");
        Cursor cursor = CursorBuilder.createCursor(table);
        for (Row row : cursor.newIterable().addMatchPattern("f_Attend", 0)) {

            excludedGates.add(String.format("%s", row.get("f_ReaderName")));
        }
        table = DatabaseBuilder.open(file).getTable("t_b_Consumer");
        cursor = CursorBuilder.createCursor(table);
        for (Row row : cursor.newIterable()) {
            idMapping.add(String.format("%s", row.get("f_ConsumerID")).trim() + "-"
                    + WordUtils.capitalizeFully(String.format("%s", row.get("f_ConsumerName")).trim()));

            if (!String.format("%s", row.get("f_AttendEnabled")).contains("1")) {
                excludedUsers.add(WordUtils.capitalizeFully(String.format("%s", row.get("f_ConsumerName"))));
            }
        }

    } catch (IOException ex) {
        log.error("Exceptie", ex);
    }

    result.add(idMapping);
    result.add(excludedGates);
    result.add(excludedUsers);

    return result;
}

From source file:com.examples.with.different.packagename.ClassWithPrivateInterfaces.java

public static List<Class<?>> getAllInterfaces(final Class<?> cls) {
    if (cls == null) {
        return null;
    }//  w ww . j  av a 2s .c om

    final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>();
    getAllInterfaces(cls, interfacesFound);

    return new ArrayList<Class<?>>(interfacesFound);
}

From source file:io.cortical.retina.model.TestDataHarness.java

/**
 * Create dummy  {@link Fingerprint}.//from ww w .  j  av a2  s .  c o m
 * 
 * @return dummy fingerprint.
 */
public static Fingerprint createFingerprint() {
    Random random = new Random(SEED);
    Set<Integer> positionSet = new LinkedHashSet<>();
    while (positionSet.size() <= FINGERPRINT_LENGTH) {
        positionSet.add(random.nextInt(MAX_POSITION));
    }

    Integer[] positionsInteger = new Integer[FINGERPRINT_LENGTH];
    positionsInteger = positionSet.toArray(positionsInteger);
    sort(positionsInteger);
    return new Fingerprint(ArrayUtils.toPrimitive(positionsInteger));
}

From source file:org.eclipse.gemini.blueprint.test.internal.util.jar.ManifestUtils.java

/**
 * Determine the Import-Package value based on the Export-Package entries in
 * the jars given as Resources.//w w  w. j  a  va2  s .c o  m
 * @param resources
 * @return
 */
public static String[] determineImportPackages(Resource[] resources) {
    Set collection = new LinkedHashSet();
    // for each resource
    for (int i = 0; i < resources.length; i++) {
        Resource resource = resources[i];
        Manifest man = JarUtils.getManifest(resource);
        if (man != null) {
            // read the manifest
            // get the Export-Package
            Attributes attrs = man.getMainAttributes();
            String exportedPackages = attrs.getValue(Constants.EXPORT_PACKAGE);
            // add it to the StringBuilder
            if (StringUtils.hasText(exportedPackages)) {
                collection.addAll(StringUtils.commaDelimitedListToSet(exportedPackages));
            }
        }
    }
    // return the result as string
    String[] array = (String[]) collection.toArray(new String[collection.size()]);

    // clean whitespace just in case
    for (int i = 0; i < array.length; i++) {
        array[i] = StringUtils.trimWhitespace(array[i]);
    }
    return array;
}

From source file:ca.uhn.fhir.util.ReflectionUtil.java

public static LinkedHashSet<Method> getDeclaredMethods(Class<?> theClazz) {
    LinkedHashSet<Method> retVal = new LinkedHashSet<Method>();
    for (Method next : theClazz.getDeclaredMethods()) {
        try {// ww w . j ava  2s  . co  m
            Method method = theClazz.getMethod(next.getName(), next.getParameterTypes());
            retVal.add(method);
        } catch (NoSuchMethodException e) {
            retVal.add(next);
        } catch (SecurityException e) {
            retVal.add(next);
        }
    }
    return retVal;
}

From source file:Main.java

/**
 * Makes an union between both of the given lists.<br/>
 * The result contains unique values.//from ww  w . j a  v a 2s .  c  om
 * @param list1 the first list.
 * @param list2 the second list.
 * @param <T>
 * @return the union between the two lists.
 */
public static <T> List<T> union(List<T> list1, List<T> list2) {
    Set<T> set = new LinkedHashSet<T>();
    set.addAll(list1);
    set.addAll(list2);
    return new ArrayList<T>(set);
}

From source file:Main.java

/**
 * Creates a {@link Set} with the given elements.
 *
 * @param elements the elements.//from  www  .  ja  va  2s . c  om
 * @param <T>      the element type.
 * @return a new {@link Set} instance containing the given elements.
 * @throws NullPointerException if parameter elements is {@code null}.
 */
public static <T> Set<T> asSet(T... elements) {
    final Set<T> resultSet = new LinkedHashSet<T>();
    addAll(resultSet, elements);

    return resultSet;
}