Example usage for java.util Set remove

List of usage examples for java.util Set remove

Introduction

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

Prototype

boolean remove(Object o);

Source Link

Document

Removes the specified element from this set if it is present (optional operation).

Usage

From source file:org.biopax.validator.rules.EntityReferenceSamePhysicalEntitiesRule.java

public void check(final Validation validation, EntityReference eref) {

    Set<Set<SimplePhysicalEntity>> clasters = algorithm.cluster(eref.getEntityReferenceOf(), Integer.MAX_VALUE);

    // report the error case once per cluster
    for (Set<SimplePhysicalEntity> col : clasters) {
        if (col.size() > 1) {
            SimplePhysicalEntity u = col.iterator().next();
            col.remove(u);
            error(validation, eref, "same.state.entity", false, u, col);
        }/*from w w w.j  av a  2  s . com*/
    }

}

From source file:edu.scripps.fl.pubchem.app.AssayDownloader.java

public void process() throws Exception {
    if (notInDb) {
        SQLQuery query = PubChemDB.getSession().createSQLQuery("select assay_aid from pcassay");
        ScrollableResults scroll = query.scroll(ScrollMode.FORWARD_ONLY);
        Iterator<Long> iterator = new ScrollableResultsIterator<Long>(Long.class, scroll);
        Set<Long> aids = PubChemFactory.getInstance().getAIDs();
        while (iterator.hasNext())
            aids.remove(iterator.next());
        process(aids);//from w w  w.jav a  2  s.c o  m
    } else if (this.mlpcn) {
        Set<Long> aids = PubChemFactory.getInstance()
                .getAIDs("\"NIH Molecular Libraries Program\"[SourceCategory] OR \"hasonhold\"[Filter]");
        //         for(long id = 1; id < 1788; id++)
        //            aids.remove(id);
        process(aids);
    } else if (this.days != null)
        process(PubChemFactory.getInstance().getAIDs(this.days));
    else
        process(PubChemFactory.getInstance().getAIDs());
}

From source file:net.iaeste.iws.core.services.ExchangeCSVFetchService.java

private String findSharedOffers(final Authentication authentication, final FetchOffersRequest request) {
    final List<String> offerIds = request.getIdentifiers();
    final Page page = request.getPage();
    final Integer exchangeYear = request.getExchangeYear();
    final Set<OfferState> states = EnumSet.allOf(OfferState.class);
    states.remove(OfferState.DELETED);

    final List<SharedOfferView> found;
    if (offerIds.isEmpty()) {
        //paging could make a problem here if it returns only some offers
        found = viewsDao.findSharedOffers(authentication, exchangeYear, states, false, page);
    } else {/*from www . j av a  2s .co  m*/
        found = viewsDao.findSharedOffersByOfferIds(authentication, exchangeYear, offerIds);
    }

    return convertOffersToCsv(found, OfferFields.Type.FOREIGN);
}

From source file:PropertiesSet.java

/**
 * Removes a property from the bag.//from   www.j a v a2s.c  om
 *
 * @param prop the property to be removed
 *
 * @throws NullPointerException if the property is {@code null}
 * @throws IllegalStateException if the property is not present
 */
public void remove(T prop) {
    if (null == prop)
        throw new NullPointerException("Property cannot be null");

    Set<T> propsOfCurrType = properties.get(prop.getClass());
    if (null == propsOfCurrType || !propsOfCurrType.remove(prop))
        throw new IllegalStateException("Property not present");

    if (propsOfCurrType.isEmpty())
        properties.remove(prop.getClass());
}

From source file:com.qwarz.graph.model.GraphNode.java

@JsonIgnore
@XmlTransient/*from  w  w  w .ja v a 2s  .  co  m*/
public boolean removeEdge(String type, String value) {
    if (value == null || value.isEmpty())
        return false;
    if (edges == null)
        return false;
    if (type == null || type.isEmpty())
        return false;
    type = type.intern();
    Set<String> nodeIdSet = edges.get(type);
    if (nodeIdSet == null)
        return false;
    return nodeIdSet.remove(value);
}

From source file:org.biopax.validator.rules.DuplicateIdCaseInsensitiveRule.java

public void check(final Validation validation, Model model) {
    Cluster<BioPAXElement> algorithm = new Cluster<BioPAXElement>() {
        @Override//from   www . jav  a 2s  .c o  m
        public boolean match(BioPAXElement a, BioPAXElement b) {
            return !a.equals(b) && a.getUri().equalsIgnoreCase(b.getUri());
        }
    };

    Set<Set<BioPAXElement>> clasters = algorithm.cluster(model.getObjects(), Integer.MAX_VALUE);

    // report the error once for each cluster
    for (Set<BioPAXElement> duplicates : clasters) {
        if (duplicates.size() > 1) {
            BioPAXElement u = duplicates.iterator().next();
            duplicates.remove(u); // keep the first element
            error(validation, u, "duplicate.id.ignoringcase", false, duplicates,
                    u.getModelInterface().getSimpleName());
        }
    }
}

From source file:net.iaeste.iws.core.services.ExchangeCSVFetchService.java

private String findDomesticOffers(final Authentication authentication, final FetchOffersRequest request) {
    final List<String> offerIds = request.getIdentifiers();
    final Page page = request.getPage();
    final Integer exchangeYear = request.getExchangeYear();

    final List<OfferView> found;
    if (offerIds.isEmpty()) {
        //paging could make a problem here if it returns only some offers
        final Set<OfferState> states = EnumSet.allOf(OfferState.class);
        states.remove(OfferState.DELETED);
        found = viewsDao.findDomesticOffers(authentication, exchangeYear, states, false, page);
    } else {/*from  w  ww . j  a va 2s .c  o  m*/
        found = viewsDao.findDomesticOffersByOfferIds(authentication, exchangeYear, offerIds);
    }

    return convertOffersToCsv(found, OfferFields.Type.DOMESTIC);
}

From source file:fslib.scheduler.FSScheduleController.java

public synchronized void cancel(ScheduledTask task) {
    Set<ScheduledTask> tasks = task.sync ? this.sync : this.async;
    if (tasks.contains(task))
        tasks.remove(task);
}

From source file:com.cimpoint.mes.server.repositories.WorkCenterRepository.java

@Transactional
public void remove(Long id, TrxInfo trxInfo) {
    EWorkCenter wc = entityManager.find(entityClass, id);

    Set<EEquipment> equipments = wc.getEquipments();
    if (equipments != null) {
        for (EEquipment eq : equipments) {
            eq.setWorkCenter(null);//from  ww  w .  jav  a2s .co  m
        }
    }
    wc.setEquipments(null);

    Set<EStep> steps = wc.getSteps();
    if (steps != null) {
        for (EStep s : steps) {
            Set<EWorkCenter> wcs = s.getWorkCenters();
            if (wcs != null) {
                wcs.remove(this);
            }
        }
    }
    wc.setSteps(null);

    super.remove(wc, trxInfo);
}

From source file:grails.plugin.searchable.internal.util.GrailsDomainClassUtils.java

/**
 * Get the parent GrailsDomainClass for the given GrailsDomainClass, if it
 * exists in the given collection otherwise null
 *
 * @param grailsDomainClass the class whose parent to find
 * @param grailsDomainClasses the collection of possible parents
 * @return null if the given class has no parent or the parent is not in the collection
 *///from w w  w  .  j  a v  a 2s.  c om
public static GrailsDomainClass getSuperClass(GrailsDomainClass grailsDomainClass,
        Collection grailsDomainClasses) {
    Set candidates = new HashSet();
    for (Iterator iter = grailsDomainClasses.iterator(); iter.hasNext();) {
        GrailsDomainClass gdc = (GrailsDomainClass) iter.next();
        if (gdc.getSubClasses().contains(grailsDomainClass)) {
            candidates.add(gdc);
        }
    }
    if (candidates.isEmpty()) {
        return null;
    }
    while (candidates.size() > 1) {
        Set copy = new HashSet(candidates);
        for (Iterator iter = copy.iterator(); iter.hasNext();) {
            GrailsDomainClass supsup = (GrailsDomainClass) iter.next();
            boolean remove = false;
            for (Iterator iter2 = candidates.iterator(); iter2.hasNext();) {
                GrailsDomainClass sup = (GrailsDomainClass) iter2.next();
                if (supsup.getSubClasses().contains(sup)) {
                    remove = true;
                    break;
                }
            }
            if (remove) {
                candidates.remove(supsup);
                break;
            }
        }
    }
    return (GrailsDomainClass) candidates.iterator().next();
}