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:com.shigengyu.hyperion.core.WorkflowStateSet.java

public WorkflowStateSet remove(WorkflowState workflowState) {
    Set<WorkflowState> states = Sets.newHashSet(workflowStates);
    states.remove(workflowState);
    return new WorkflowStateSet(states);
}

From source file:com.smhdemo.common.report.service.ChartService.java

@Override
public void delChart(Long pk) {
    Chart chartReport = chartDao.get(pk);
    Assert.notNull(chartReport);//from w  w  w.  ja  v a2 s .  c o  m
    List<Category> categories = chartDao.findCategoryReportByChartReportId(pk);
    if (categories != null && !categories.isEmpty()) {
        for (Category category : categories) {
            Set<Chart> charts = category.getChartReports();
            if (charts.isEmpty())
                continue;
            charts.remove(chartReport);
            category.setChartReports(charts);
            categoryDao.merge(category);
        }
    }
    //      List<EwcmsJobReport> ewcmsJobReports = chartDao.findEwcmsJobReportByChartReportId(chartReportId);
    //      if (ewcmsJobReports != null && !ewcmsJobReports.isEmpty()){
    //         for (EwcmsJobReport ewcmsJobReport : ewcmsJobReports){
    //            if (ewcmsJobReport.getTextReport() == null) {
    //               ewcmsJobReportDAO.remove(ewcmsJobReport);
    //            }else{
    //               ewcmsJobReport.setChartReport(null);
    //               ewcmsJobReportDAO.merge(ewcmsJobReport);
    //            }
    //         }
    //      }
    chartDao.removeByPK(pk);
}

From source file:com.espertech.esper.core.service.StatementEventTypeRefImpl.java

private void removeReference(String statementName, String eventTypeName) {
    // remove from types
    Set<String> statements = typeToStmt.get(eventTypeName);
    if (statements != null) {
        if (!statements.remove(statementName)) {
            log.info("Failed to find statement name '" + statementName + "' in collection");
        }/*from   w w  w. j av  a2  s  .  co m*/

        if (statements.isEmpty()) {
            typeToStmt.remove(eventTypeName);
        }
    }

    // remove from statements
    String[] types = stmtToType.get(statementName);
    if (types != null) {
        int index = CollectionUtil.findItem(types, eventTypeName);
        if (index != -1) {
            if (types.length == 1) {
                stmtToType.remove(statementName);
            } else {
                types = (String[]) CollectionUtil.arrayShrinkRemoveSingle(types, index);
                stmtToType.put(statementName, types);
            }
        } else {
            log.info("Failed to find type name '" + eventTypeName + "' in collection");
        }
    }
}

From source file:com.dhenton9000.birt.jpa.service.impl.security.GroupsServiceImpl.java

@Override
@Transactional/*from  w w w  . j  av  a 2 s .co m*/
public Applications removeApplicationFromGroup(Integer appId, Integer groupId) {
    Groups g = this.findOne(groupId);
    if (g == null) {
        throw new ResourceNotFoundException("cannot find group " + groupId);
    }

    Applications a = applicationsRepository.findOne(appId);
    if (a == null) {
        throw new ResourceNotFoundException("cannot find app " + appId);
    }

    if (!g.getApplicationsSet().contains(a)) {
        throw new ResourceNotFoundException(
                String.format("app %d should be in group %d but isn't", appId, groupId));
    }

    Set<Applications> apps = g.getApplicationsSet();

    apps.remove(a);
    g.setApplicationsSet(apps);
    return a;
}

From source file:com.espertech.esper.core.service.StatementVariableRefImpl.java

private void removeReference(String statementName, String variableName) {
    // remove from variables
    Set<String> statements = variableToStmt.get(variableName);
    if (statements != null) {
        if (!statements.remove(statementName)) {
            log.info("Failed to find statement name '" + statementName + "' in collection");
        }/*from   www . j a v a  2  s. c om*/

        if (statements.isEmpty()) {
            variableToStmt.remove(variableName);

            if (!configuredVariables.contains(variableName)) {
                variableService.removeVariable(variableName);
            }
        }
    }

    // remove from statements
    Set<String> variables = stmtToVariable.get(statementName);
    if (variables != null) {
        if (!variables.remove(variableName)) {
            log.info("Failed to find variable '" + variableName + "' in collection");
        }

        if (variables.isEmpty()) {
            stmtToVariable.remove(statementName);
        }
    }
}

From source file:models.NotificationEvent.java

public static Set<User> getMentionedUsers(String body) {
    Matcher matcher = Pattern.compile("@" + User.LOGIN_ID_PATTERN_ALLOW_FORWARD_SLASH).matcher(body);
    Set<User> users = new HashSet<>();
    while (matcher.find()) {
        String mentionWord = matcher.group().substring(1);
        users.addAll(findOrganizationMembers(mentionWord));
        users.addAll(findProjectMembers(mentionWord));
        users.add(User.findByLoginId(mentionWord));
    }//from   w ww .  j  av  a2 s .c om
    users.remove(User.anonymous);
    return users;
}

From source file:com.jaeksoft.searchlib.renderer.filter.RendererFilterQueries.java

private void removeTerm(String fieldName, String[] values) {
    if (values == null)
        return;//from w  ww  .j  av a  2  s.c  om
    Set<String> queries = getTermSet(fieldName);
    for (String value : values)
        queries.remove(value);
}

From source file:com.google.code.ssm.test.svc.AppUserServiceImpl.java

@Override
public void disableAppForUser(final int userId, final int applicationId) {
    AppUserPK pk = new AppUserPK(userId, applicationId);
    AppUser appUser = getApplicationUserFromDB(pk);
    if (appUser != null && appUser.isEnabled()) {
        appUser.setEnabled(false);//from   w  w  w  . j a v  a2 s.  c  om
        getDao().update(appUser);

        Set<Integer> appsIdsSet = new HashSet<Integer>(getDao().getAppIdList(userId, true));
        if (appsIdsSet.remove(applicationId)) {
            getDao().updateListInCache(userId, true, new ArrayList<Integer>(appsIdsSet));
        }

        appsIdsSet = new HashSet<Integer>(getDao().getAppIdList(userId, false));
        if (appsIdsSet.add(applicationId)) {
            getDao().updateListInCache(userId, false, new ArrayList<Integer>(appsIdsSet));
        }
    } else {
        LOGGER.info("Appuser with PK: " + pk
                + " won't be uninstalled because it is null or already not marked as authorized: " + appUser);
    }
}

From source file:com.puppycrawl.tools.checkstyle.XDocsPagesTest.java

private static void validatePropertySection(String fileName, String sectionName, Node subSection,
        Object instance) {/* w  w w .j a  v a  2  s . c  o  m*/
    final Set<String> properties = getProperties(instance.getClass());
    final Class<?> clss = instance.getClass();

    // remove global properties that don't need documentation
    if (hasParentModule(sectionName)) {
        properties.removeAll(CHECK_PROPERTIES);
    } else if (AbstractFileSetCheck.class.isAssignableFrom(clss)) {
        properties.removeAll(FILESET_PROPERTIES);

        // override
        properties.add("fileExtensions");
    }

    // remove undocumented properties
    for (String p : new HashSet<>(properties)) {
        if (UNDOCUMENTED_PROPERTIES.contains(clss.getSimpleName() + "." + p)) {
            properties.remove(p);
        }
    }

    final Check check;

    if (Check.class.isAssignableFrom(clss)) {
        check = (Check) instance;

        if (!Arrays.equals(check.getAcceptableTokens(), check.getDefaultTokens())
                || !Arrays.equals(check.getAcceptableTokens(), check.getRequiredTokens())) {
            properties.add("tokens");
        }
    } else {
        check = null;
    }

    if (subSection != null) {
        Assert.assertTrue(fileName + " section '" + sectionName + "' should have no properties to show",
                !properties.isEmpty());

        validatePropertySectionProperties(fileName, sectionName, subSection, check, properties);
    }

    Assert.assertTrue(fileName + " section '" + sectionName + "' should show properties: " + properties,
            properties.isEmpty());
}

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

public void check(final Validation validation, Model model) {
    Cluster<UtilityClass> algorithm = new Cluster<UtilityClass>() {
        @Override/*w ww  .  jav  a  2  s.c om*/
        public boolean match(UtilityClass a, UtilityClass b) {
            return !a.equals(b) && a.isEquivalent(b);
        }
    };

    Set<Set<UtilityClass>> clusters = algorithm.cluster(model.getObjects(UtilityClass.class),
            Integer.MAX_VALUE);

    Map<UtilityClass, UtilityClass> replacementMap = new HashMap<UtilityClass, UtilityClass>();

    // report the error once for each cluster
    for (Set<UtilityClass> clones : clusters) {
        if (clones.size() < 2)
            continue; //skip unique individuals

        UtilityClass first = clones.iterator().next();
        clones.remove(first); // pop the first element from the clones collection

        if (validation.isFix()) {
            // set "fixed" in advance... fix below
            error(validation, first, "cloned.utility.class", true, clones,
                    first.getModelInterface().getSimpleName());

            for (UtilityClass clone : clones)
                replacementMap.put(clone, first);

        } else {
            // report the problem (not fixed)
            error(validation, first, "cloned.utility.class", false, clones,
                    first.getModelInterface().getSimpleName());
        }
    }

    if (validation.isFix())
        ModelUtils.replace(model, replacementMap);

}