Example usage for java.util HashSet add

List of usage examples for java.util HashSet add

Introduction

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

Prototype

public boolean add(E e) 

Source Link

Document

Adds the specified element to this set if it is not already present.

Usage

From source file:com.osbitools.ws.shared.prj.utils.EntityUtils.java

public EntityUtils() {
    // Index supported extensions
    HashMap<String, String[]> sdirs = getSubDirExtList();

    for (String name : sdirs.keySet()) {
        String[] extl = sdirs.get(name);
        HashSet<String> sx = new HashSet<String>();

        for (String ext : extl) {
            sx.add(ext);
            if (!_exts.contains(ext))
                _exts.add(ext);//from  w  w w. java  2 s  . c  om
        }

        _ffilters.put(name, new ExtListFileFilter(extl));
        _extl.put(name, sx);
    }
}

From source file:de.kaiserpfalzEdv.office.ui.web.security.KPOfficeUserDetail.java

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    HashSet<GrantedAuthority> result = new HashSet<>(ticket.getEntitlements().size());

    ticket.getEntitlements().forEach(e -> result.add(new KPOfficeGrantedAuthority(e)));

    return result;
}

From source file:proto.GreetingControllerTest.java

private void createInitialData() {
    //create roles (not in DB)
    Role userRole = new Role("USER");
    Role adminRole = new Role("ADMIN");
    Role guestRole = new Role("GUEST");

    HashSet<Role> userAndAdmin = new HashSet<>();
    userAndAdmin.add(userRole);
    userAndAdmin.add(adminRole);/*from  w ww  . j a va2 s  .  c  om*/

    User roy = new User("Roy", "roy", "spring", userAndAdmin);
    userRepository.save(roy);

    User craig = new User("Craig", "craig", "spring", new HashSet<Role>() {
        {
            add(userRole);
        }
    });
    userRepository.save(craig);

    User greg = new User("Greg", "greg", "spring", new HashSet<Role>() {
        {
            add(guestRole);
        }
    });
    userRepository.save(greg);
}

From source file:gov.nih.nci.caarray.application.translation.magetab.AbstractTranslator.java

Collection<Term> getTerms(List<OntologyTerm> ontologyTerms) {
    HashSet<Term> terms = new HashSet<Term>(ontologyTerms.size());
    for (OntologyTerm ontologyTerm : ontologyTerms) {
        terms.add(getTerm(ontologyTerm));
    }//w  ww.j  a  va  2  s. c  om
    return terms;
}

From source file:com.sworddance.util.TestPredicatedTransformingIterator.java

public void testSetFlattening() {
    PredicatedTransformingIterator<Double> transformingIterator = new PredicatedTransformingIterator<Double>(
            ints);/*from ww  w . java 2s . com*/
    Transformer transformer = new Transformer() {

        public Object transform(Object input) {
            Integer i = (Integer) input;
            HashSet<Double> d = new HashSet<Double>();
            for (int k = 0; k < i; k++) {
                d.add(Double.valueOf(i * 10 + k));
            }
            return d;
        }

    };
    transformingIterator.setTransformer(transformer);
    transformingIterator.setPredicate(predicate);
    HashSet<Double> expected = new HashSet<Double>();
    for (Integer i : ints) {
        if (i % 2 == 0) {
            for (int k = 0; k < i; k++) {
                expected.add(Double.valueOf(i * 10 + k));
            }
        }
    }
    HashSet<Double> actual = new HashSet<Double>();
    CollectionUtils.addAll(actual, transformingIterator);

    assertTrue(CollectionUtils.disjunction(actual, expected).isEmpty());
}

From source file:dk.dma.ais.analysis.viewer.rest.VesselListFilter.java

public VesselListFilter(QueryParams request) {
    for (String filterName : filterNames) {
        if (request.containsKey(filterName)) {
            HashSet<String> values = new HashSet<String>();
            String[] arr = StringUtils.split(request.getFirst(filterName), ",");
            for (String value : arr) {
                values.add(value);
            }/*from w  w  w  . ja  v a2s.com*/
            if (values.size() > 0) {
                filterMap.put(filterName, values);
            }
        }
    }
}

From source file:com.liangc.hq.base.utils.BizappUtils.java

/**
 * Return a <code>List</code> of <code>AuthzSubjectValue</code>
 * objects from a list that do <strong>not</strong> appear in
 * a list of matches./* ww w .j  a  v  a  2 s .  c o  m*/
 *
 * @param all the list to operate on
 * @param matches the list to grep out
 */
public static List<AuthzSubjectValue> grepSubjects(List all, List matches) {
    if (all == null || matches == null) {
        return new ArrayList(0);
    }

    // build an index of role subjects
    HashSet index = new HashSet();
    Iterator mi = matches.iterator();
    while (mi.hasNext()) {
        Object m = mi.next();
        index.add(((AuthzSubject) m).getId());
    }

    // find available subjects (those not in the index)
    ArrayList objects = new ArrayList();
    Iterator ai = all.iterator();
    while (ai.hasNext()) {
        AuthzSubjectValue obj = (AuthzSubjectValue) ai.next();
        if (!index.contains(obj.getId())) {
            objects.add(obj);
        }
    }

    return objects;
}

From source file:com.thinkbiganalytics.util.PartitionSpec.java

public Set<String> getKeyNames() {
    HashSet<String> keySet = new HashSet<>();
    for (PartitionKey partitionKey : keys) {
        keySet.add(partitionKey.getKey());
    }//from w ww .j  av a2 s  .  c  o m
    return keySet;
}

From source file:net.sourceforge.safr.sample.permission.service.PermissionServiceImpl.java

/**
 * Returns sample role permissions.//from  ww w  .  j  a va  2  s . com
 * 
 * @return sample role permissions.
 */
public Map<RolePrincipal, Set<InstancePermission>> getRolePermissions() {
    HashMap<RolePrincipal, Set<InstancePermission>> result = new HashMap<RolePrincipal, Set<InstancePermission>>();

    // define permissions for customer role
    HashSet<InstancePermission> permissions = new HashSet<InstancePermission>();
    permissions.add(new InstancePermission(new Target(WILDCARD, NOTEBOOK, PUBLIC_ID), Action.WRITE));
    result.put(new RolePrincipal("customer"), permissions);

    return result;
}

From source file:com.vaadin.tests.server.LicenseInJavaFiles.java

private void checkForLicenseInFile(File f, HashSet<String> missing) throws IOException {
    String contents = IOUtils.toString(new FileInputStream(f));
    if (!contents.contains("@" + "VaadinApache2LicenseForJavaFiles" + "@")) {
        missing.add(f.getPath());
    }//ww  w. j  a  v a  2s  .c  o  m

}