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:de.uni_potsdam.hpi.bpt.promnicat.persistenceApi.orientdbObj.index.IndexIntersection.java

/**
 * Find all dbIds within the IndexElements
 * /*from w  w w.  ja  va2  s.c  o  m*/
 * @return all dbIds
 */
public Collection<String> getDbIds() {
    HashSet<String> dbIds = new HashSet<String>();
    for (IndexElement e : resultSet) {
        dbIds.add(e.getDbId());
    }
    return dbIds;
}

From source file:edu.amc.sakai.user.RegexpBlacklistEidValidator.java

private Collection<String> eidBlacklistAsStrings() {
    if (eidBlacklist == null || eidBlacklist.isEmpty()) {
        return new HashSet<String>(0);
    }/*  w  w  w.j  a v a2s  . c  om*/
    HashSet<String> patternStrings = new HashSet<String>(eidBlacklist.size());
    for (Pattern pattern : eidBlacklist) {
        patternStrings.add(pattern.pattern());
    }
    return patternStrings;
}

From source file:com.handcraftedbits.bamboo.plugin.go.task.common.AbstractGoTaskConfigurator.java

@NotNull
@Override/*ww w . jav a  2  s .c o m*/
public Set<Requirement> calculateRequirements(@NotNull final TaskDefinition taskDefinition) {
    final HashSet<Requirement> requirements = new HashSet<>();

    for (final String requirement : this.requirements) {
        requirements.add(new RequirementImpl(requirement, true, ".*"));
    }

    return requirements;
}

From source file:com.parse.ParseRemoveOperation.java

@Override
public Object apply(Object oldValue, String key) {
    if (oldValue == null) {
        return new ArrayList<>();
    } else if (oldValue instanceof JSONArray) {
        ArrayList<Object> old = ParseFieldOperations.jsonArrayAsArrayList((JSONArray) oldValue);
        @SuppressWarnings("unchecked")
        ArrayList<Object> newValue = (ArrayList<Object>) this.apply(old, key);
        return new JSONArray(newValue);
    } else if (oldValue instanceof List) {
        ArrayList<Object> result = new ArrayList<>((List<?>) oldValue);
        result.removeAll(objects);// w w w  . java2 s . c o  m

        // Remove the removed objects from "objects" -- the items remaining
        // should be ones that weren't removed by object equality.
        ArrayList<Object> objectsToBeRemoved = new ArrayList<>(objects);
        objectsToBeRemoved.removeAll(result);

        // Build up set of object IDs for any ParseObjects in the remaining objects-to-be-removed
        HashSet<String> objectIds = new HashSet<>();
        for (Object obj : objectsToBeRemoved) {
            if (obj instanceof ParseObject) {
                objectIds.add(((ParseObject) obj).getObjectId());
            }
        }

        // And iterate over "result" to see if any other ParseObjects need to be removed
        Iterator<Object> resultIterator = result.iterator();
        while (resultIterator.hasNext()) {
            Object obj = resultIterator.next();
            if (obj instanceof ParseObject && objectIds.contains(((ParseObject) obj).getObjectId())) {
                resultIterator.remove();
            }
        }
        return result;
    } else {
        throw new IllegalArgumentException("Operation is invalid after previous operation.");
    }
}

From source file:com.epam.ta.reportportal.ws.controller.impl.LaunchControllerTest.java

@Test
public void mergeLaunchesPositive() throws Exception {
    MergeLaunchesRQ rq = new MergeLaunchesRQ();
    HashSet<String> set = new HashSet<>();
    set.add("88624678053de743b3e5aa3e");
    rq.setLaunches(set);//from w w w  .j  av  a2s .c o m
    rq.setName("Merged");
    rq.setStartTime(new Date());
    this.mvcMock
            .perform(post(PROJECT_BASE_URL + "/launch/merge").contentType(APPLICATION_JSON)
                    .principal(authentication()).content(objectMapper.writeValueAsBytes(rq)))
            .andExpect(status().is(200));
}

From source file:ca.uhn.fhir.context.RuntimeSearchParam.java

public RuntimeSearchParam(IIdType theId, String theUri, String theName, String theDescription, String thePath,
        RestSearchParameterTypeEnum theParamType, List<RuntimeSearchParam> theCompositeOf,
        Set<String> theProvidesMembershipInCompartments, Set<String> theTargets,
        RuntimeSearchParamStatusEnum theStatus) {
    super();//  w w  w . j a  v  a2  s  .  c  o  m
    myId = theId;
    myUri = theUri;
    myName = theName;
    myDescription = theDescription;
    myPath = thePath;
    myParamType = theParamType;
    myCompositeOf = theCompositeOf;
    myStatus = theStatus;
    if (theProvidesMembershipInCompartments != null && !theProvidesMembershipInCompartments.isEmpty()) {
        myProvidesMembershipInCompartments = Collections.unmodifiableSet(theProvidesMembershipInCompartments);
    } else {
        myProvidesMembershipInCompartments = null;
    }
    if (theTargets != null && theTargets.isEmpty() == false) {
        myTargets = Collections.unmodifiableSet(theTargets);
    } else {
        myTargets = null;
    }

    HashSet<String> base = new HashSet<String>();
    int indexOf = thePath.indexOf('.');
    if (indexOf != -1) {
        base.add(trim(thePath.substring(0, indexOf)));
    }
    myBase = Collections.unmodifiableSet(base);
}

From source file:nl.surfnet.coin.teams.control.AbstractControllerTest.java

protected Member getMember() {
    HashSet<Role> roles = new HashSet<Role>();
    roles.add(Role.Member);
    return new Member(roles, "Member 1", "member-1", "member@example.com");
}

From source file:net.doubledoordev.backend.util.Settings.java

public Collection<Server> getOnlineServers() {
    HashSet<Server> onlineServers = new HashSet<>();
    for (Server server : getServers())
        if (server.getOnline())
            onlineServers.add(server);
    return onlineServers;
}

From source file:org.opensaml.security.httpclient.impl.SecurityEnhancedTLSSocketFactoryTest.java

private BasicX509Credential getCredential(String entityCertFileName, String... chainMembers) {
    X509Certificate entityCert = getCertificate(entityCertFileName);

    BasicX509Credential cred = new BasicX509Credential(entityCert);

    HashSet<X509Certificate> certChain = new HashSet<>();
    certChain.add(entityCert);

    for (String member : chainMembers) {
        certChain.add(getCertificate(member));
    }/*ww  w . j  ava  2 s  . c om*/

    cred.setEntityCertificateChain(certChain);

    return cred;
}

From source file:nl.surfnet.coin.teams.control.AbstractControllerTest.java

protected Member getAdministrativeMember() {
    HashSet<Role> roles = new HashSet<Role>();
    roles.add(Role.Manager);
    roles.add(Role.Member);
    roles.add(Role.Admin);//from w  w  w. ja  va  2s .  com
    return new Member(roles, "Member 1", "member-1", "member@example.com");
}