Example usage for java.util Set add

List of usage examples for java.util Set add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:at.ac.univie.isc.asio.insight.VndError.java

/**
 * Circular reference safe root finder./*from  ww  w  .j  av  a  2s .co m*/
 *
 * @param throwable any non-null exception
 * @return root exception or an AssertionError if a circular reference is detected
 */
private static Throwable findRoot(Throwable throwable) {
    final Set<Throwable> seen = Sets.newIdentityHashSet();
    seen.add(throwable);
    Throwable cause;
    while ((cause = throwable.getCause()) != null) {
        throwable = cause;
        if (!seen.add(throwable)) {
            return circularPlaceholder(throwable);
        }
    }
    return throwable;
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.util.MetaSanitizerUtil.java

/**
 * Takes a List of KeywordModels and returns a comma separated list of keywords as String.
 *
 * @param keywords//w w w .  jav a  2s .  c  om
 *           List of KeywordModel objects
 * @deprecated use {@link MetaSanitizerUtil#sanitizeKeywords(Collection)} instead
 * @return String of comma separated keywords
 */
@Deprecated
public static String sanitizeKeywords(final List<KeywordModel> keywords) {
    if (keywords != null && !keywords.isEmpty()) {
        // Remove duplicates
        final Set<String> keywordSet = new HashSet<String>(keywords.size());
        for (final KeywordModel keyword : keywords) {
            keywordSet.add(keyword.getKeyword());
        }

        return sanitizeKeywords(keywordSet);
    }
    return "";
}

From source file:cop.raml.processor.AbstractProcessorTest.java

protected static boolean runAnnotationProcessor(File dir) throws URISyntaxException {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    Set<JavaFileObject> compilationUnits = new LinkedHashSet<>();

    for (File file : (List<File>) FileUtils.listFiles(dir, JAVA_FILE_FILTER, DirectoryFileFilter.INSTANCE))
        compilationUnits.add(new SimpleJavaFileObjectImpl(file, JavaFileObject.Kind.SOURCE));

    List<String> options = new ArrayList<>();
    //        options.put("-Apackages=com.bosch");
    //        options.put("-AfilterRegex=AnalysisController");
    //        options.put("-Aversion=0.8");
    options.add("-d");
    options.add("target");

    JavaCompiler.CompilationTask task = compiler.getTask(null, null, null, options, null, compilationUnits);
    task.setProcessors(Collections.singleton(new RestProcessor()));

    return task.call();
}

From source file:Main.java

@SafeVarargs
public static boolean equalsSize(List<? extends Object>... lists) {
    Set<Integer> sizes = new HashSet<Integer>(lists.length);
    for (List<? extends Object> list : lists) {
        if (list == null) {
            return false;
        }//from w  w  w  .j a v a  2 s .  c  o m
        if (sizes.isEmpty()) {
            sizes.add(list.size());
        } else {
            if (sizes.add(list.size())) {
                return false;
            }
        }
    }
    return true;
}

From source file:com.mothsoft.alexis.domain.UserAuthenticationDetails.java

private static Collection<GrantedAuthority> getAuthorities(final User user) {
    if (user.isAdmin()) {
        return ADMIN_AUTHORITIES;
    }//ww  w  . j a  v a2s . co m

    final Set<GrantedAuthority> userAuthorities = new HashSet<GrantedAuthority>(DEFAULT_AUTHORITIES);

    if (user.isAnalysisRole()) {
        userAuthorities.add(new GrantedAuthorityImpl("ROLE_ANALYSIS"));
    }

    return userAuthorities;
}

From source file:com.github.rvesse.airline.utils.AirlineUtils.java

public static <T> Set<T> singletonSet(T item) {
    Set<T> set = new HashSet<T>();
    set.add(item);
    return set;/*from   w w  w  .java  2s  .  co m*/
}

From source file:es.emergya.ui.base.plugins.PluginEventHandler.java

/**
 * Registra a observer para avisarle cuando observable se modifique
 * //from w w  w .  j ava  2 s  .  c om
 * @param observer
 * @param observable
 */
public static synchronized void register(PluginListener observer, PluginListener observable) {
    Set<PluginListener> observers = getObservables(observable);
    if (observers == null)
        observers = new HashSet<PluginListener>();
    observers.add(observer);
    observables.put(observable, observers);
}

From source file:io.wcm.wcm.parsys.componentinfo.impl.AllowedComponentsProviderImpl.java

/**
 * Ensures that all resource types in the set are resolved to absolute resource types.
 * @param resourceTypes Resource types//from w w w  . j  a v  a 2 s .  c o m
 * @param resourceResolver Resource resolver
 * @return Absolute resource types
 */
private static Set<String> makeAbsolute(Set<String> resourceTypes, ResourceResolver resourceResolver) {
    Set<String> absoluteResourceTypes = new HashSet<>();
    for (String resourceType : resourceTypes) {
        absoluteResourceTypes.add(ResourceType.makeAbsolute(resourceType, resourceResolver));
    }
    return absoluteResourceTypes;
}

From source file:Main.java

/**
 * Convert a String to a set of characters.
 *
 * @param str The string to convert/*  w  ww.j  a v  a 2s . c  o m*/
 * @return A set containing the characters in str. A empty set is returned if str is null.
 */
public static Set<Character> strToSet(String str) {
    Set<Character> set;

    if (str == null) {
        return new HashSet<Character>();
    }
    set = new HashSet<Character>(str.length());
    for (int i = 0; i < str.length(); i++) {
        set.add(str.charAt(i));
    }
    return set;
}