Example usage for java.util Collections EMPTY_SET

List of usage examples for java.util Collections EMPTY_SET

Introduction

In this page you can find the example usage for java.util Collections EMPTY_SET.

Prototype

Set EMPTY_SET

To view the source code for java.util Collections EMPTY_SET.

Click Source Link

Document

The empty set (immutable).

Usage

From source file:WeakIdentityMap.java

private Iterator createHashIterator(int type) {
    if (this.count == 0) {
        return Collections.EMPTY_SET.iterator();
    } else {//  w  w w  .j av  a2 s.c om
        return new HashIterator(type);
    }
}

From source file:com.espertech.esper.core.StatementLifecycleSvcImpl.java

private Set<EventType> populateSubqueryTypes(List<ExprSubselectNode> subSelectExpressions) {
    Set<EventType> set = null;
    for (ExprSubselectNode subselect : subSelectExpressions) {
        for (StreamSpecCompiled streamSpec : subselect.getStatementSpecCompiled().getStreamSpecs()) {
            if (streamSpec instanceof FilterStreamSpecCompiled) {
                EventType type = ((FilterStreamSpecCompiled) streamSpec).getFilterSpec()
                        .getFilterForEventType();
                if (set == null) {
                    set = new HashSet<EventType>();
                }/*from   w ww .jav a  2 s. co m*/
                set.add(type);
            } else if (streamSpec instanceof PatternStreamSpecCompiled) {
                EvalNodeAnalysisResult evalNodeAnalysisResult = EvalNodeUtil
                        .recursiveAnalyzeChildNodes(((PatternStreamSpecCompiled) streamSpec).getEvalNode());
                List<EvalFilterNode> filterNodes = evalNodeAnalysisResult.getFilterNodes();
                for (EvalFilterNode filterNode : filterNodes) {
                    if (set == null) {
                        set = new HashSet<EventType>();
                    }
                    set.add(filterNode.getFilterSpec().getFilterForEventType());
                }
            }
        }
    }
    if (set == null) {
        return Collections.EMPTY_SET;
    }
    return set;
}

From source file:org.silverpeas.core.process.io.file.AbstractFileHandler.java

/**
 * Gets the dummy handled files from a given component instance id.
 * A component instance id can be see as a root handled directory.
 * @return/*from w  w w . j  av  a  2s  .c o m*/
 */
public Set<DummyHandledFile> getDummyHandledFiles(String componentInstanceId) {
    Set<DummyHandledFile> result = dummyHandledFiles.get(componentInstanceId);
    if (result == null) {
        //noinspection unchecked
        result = Collections.EMPTY_SET;
    }
    return result;
}

From source file:org.apache.bval.jsr.ConstraintValidation.java

/**
 * {@inheritDoc}//from   w  ww  . j a v a  2s  .c o m
 */
@SuppressWarnings("unchecked")
public Set<ConstraintDescriptor<?>> getComposingConstraints() {
    return composedConstraints == null ? Collections.EMPTY_SET : composedConstraints;
}

From source file:com.tesora.dve.tools.aitemplatebuilder.AiTemplateBuilder.java

public static MultiMap<RedistCause, Object> getRedistOperations(final TableStats table,
        final Set<JoinStats> joins, final Set<? extends TemplateRangeItem> availableRanges) {
    final MultiMap<RedistCause, Object> operations = new MultiMap<RedistCause, Object>();
    final TemplateModelItem model = table.getTableDistributionModel();
    if (!model.isBroadcast()) {
        final TemplateRangeItem range = findRangeForTable(availableRanges, table);
        final Set<TableColumn> dv = (range != null) ? range.getRangeColumnsFor(table) : Collections.EMPTY_SET;

        if (table.hasStatements(StatementType.ORDERBY)) {
            operations.put(RedistCause.ORDER_BY, table.getStatementCounts(StatementType.ORDERBY));
        }/*from  w  w  w  .  j a v  a2s. co m*/

        if (table.hasStatements(StatementType.UPDATE)) {
            final Map<TableColumn, Long> updateColumns = table.getUpdateColumns();
            for (final Entry<TableColumn, Long> entry : updateColumns.entrySet()) {
                final TableColumn column = entry.getKey();
                if (column.isPrimary() || column.isUnique()) {
                    operations.put(RedistCause.UNIQUE_UPDATE, entry);
                } else if (!dv.isEmpty() && dv.contains(column)) {
                    operations.put(RedistCause.DV_UPDATE, entry);
                }
            }
        }

        if (table.hasStatements(StatementType.JOIN)) {
            for (final JoinStats join : CorpusStats.findJoinsForTable(joins, table)) {
                if ((model instanceof Random)
                        || (isRangeToRangeRelationship(join) || isJoinToBroadcastAndRequiresRedist(join))) {
                    if (dv.isEmpty() || (table.equals(join.getLHS()) && !dv.equals(join.getLeftColumns()))
                            || (table.equals(join.getRHS()) && !dv.equals(join.getRightColumns()))) {
                        operations.put(RedistCause.NON_COLLOCATED_JOIN, join);
                    }
                }
            }
        }
    }

    return operations;
}

From source file:org.webcurator.core.targets.TargetManagerImpl.java

public void save(TargetGroup aTargetGroup, List<GroupMemberDTO> parents) {

    // First check if the TargetGroup type has changed from many-sip
    // to one-sip or vice versa. If so, unschedule the group as the
    // scheduling mechanism is entirely different.
    boolean sipTypeChanged = false;
    if (!aTargetGroup.isNew()) {
        Integer sipType = targetDao.loadPersistedGroupSipType(aTargetGroup.getOid());
        if (sipType != null && sipType.intValue() != aTargetGroup.getSipType()) {
            sipTypeChanged = true;/*  ww  w  . j a  v a2s  .c  o m*/
        }
    }

    // Deal with removed schedules
    for (Schedule schedule : aTargetGroup.getRemovedSchedules()) {
        log.debug("Removing schedule: " + schedule.getCronPattern());
        targetInstanceDao.deleteScheduledInstances(schedule);
    }

    // Load the original target group so we can do auditing afterwards.
    AbstractTargetDTO originalTargetGroup = null;
    if (!aTargetGroup.isNew()) {
        originalTargetGroup = targetDao.loadAbstractTargetDTO(aTargetGroup.getOid());
    }

    List<GroupMemberDTO> newChildren = aTargetGroup.getNewChildren();
    Set<Long> removedChildren = aTargetGroup.getRemovedChildren();

    /* ---------------------------------------------------------------- */
    /* Deal with the scheduling state changes */
    /* ---------------------------------------------------------------- */

    // Get the original parents
    Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET;
    if (!aTargetGroup.isNew()) {
        origParents = targetDao.getAncestorDTOs(aTargetGroup.getOid());
    }

    // Save the TargetGroup to the database, along with all the
    // children.
    int originalState = aTargetGroup.getOriginalState();
    targetDao.save(aTargetGroup, true, parents);

    // Reload the target group to get all of its children.
    TargetGroup reloaded = targetDao.reloadTargetGroup(aTargetGroup.getOid());
    if (sipTypeChanged) {
        unschedule(reloaded);
    }
    updateTargetGroupStatus(reloaded);

    // We also need to handle the updating of any groups that we used to belong to.
    if (parents != null) {
        for (GroupMemberDTO dto : parents) {
            if (dto.getSaveState() == SAVE_STATE.DELETED) {
                updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid()));
            }
        }
    }

    /* ---------------------------------------------------------------- */
    /* Perform post-save auditing */
    /* ---------------------------------------------------------------- */
    if (originalState != aTargetGroup.getState()) {
        auditor.audit(TargetGroup.class.getName(), aTargetGroup.getOid(),
                Auditor.ACTION_TARGET_GROUP_STATE_CHANGE, "Target Group " + aTargetGroup.getName()
                        + " has changed into state '" + aTargetGroup.getState() + "'");
    }

    if (originalTargetGroup != null) {
        auditor.audit(TargetGroup.class.getName(), aTargetGroup.getOid(), Auditor.ACTION_UPDATE_TARGET_GROUP,
                "Target Group " + aTargetGroup.getName() + " has been updated");
        if (!originalTargetGroup.getOwnerOid().equals(aTargetGroup.getOwningUser().getOid())) {
            auditor.audit(TargetGroup.class.getName(), aTargetGroup.getOid(),
                    Auditor.ACTION_TARGET_GROUP_CHANGE_OWNER, "Target Group " + aTargetGroup.getName()
                            + " has been given to " + aTargetGroup.getOwningUser().getNiceName());
        }

        if (aTargetGroup.getProfile() != null
                && !originalTargetGroup.getProfileOid().equals(aTargetGroup.getProfile().getOid())) {
            auditor.audit(TargetGroup.class.getName(), aTargetGroup.getOid(),
                    Auditor.ACTION_TARGET_GROUP_CHANGE_PROFILE, "Target Group " + aTargetGroup.getName()
                            + " is now using profile " + aTargetGroup.getProfile().getName());
        }
    } else {
        auditor.audit(TargetGroup.class.getName(), aTargetGroup.getOid(), Auditor.ACTION_NEW_TARGET_GROUP,
                "Target Group " + aTargetGroup.getName() + " has been created");
    }

    // Adjust the new/removed lists to make ignore new members that were
    // also removed (since these were never persisted).
    List<AbstractTarget> newMembers = new LinkedList<AbstractTarget>();
    for (GroupMemberDTO dto : newChildren) {
        Long childOid = dto.getChildOid();
        if (removedChildren.contains(childOid)) {
            removedChildren.remove(childOid);
        } else {
            newMembers.add(loadAbstractTarget(childOid));
        }
    }

    // Create a list of the targets that have been removed.
    List<AbstractTarget> removedTargets = new LinkedList<AbstractTarget>();
    for (Long childOid : removedChildren) {
        removedTargets.add(loadAbstractTarget(childOid));
    }

    GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, reloaded, newMembers);
    gep.runEventChain();

    MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, reloaded,
            removedTargets);
    mrep.runEventChain();

    // Propagate the group events for parents.
    if (parents != null) {
        for (GroupMemberDTO dto : parents) {
            switch (dto.getSaveState()) {
            case NEW:
                TargetGroup grp = targetDao.loadGroup(dto.getParentOid());
                gep = new GroupEventPropagator(this, instanceManager, grp, reloaded);
                gep.runEventChain();
                break;
            case DELETED:
                TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid());
                mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, reloaded);
                mrep.runEventChain();
                break;
            default:
                break;
            }
        }
    }

    /* ---------------------------------------------------------------- */
    /* Save the annotations */
    /* ---------------------------------------------------------------- */

    // Update the OIDs for the target.
    for (Annotation anno : aTargetGroup.getAnnotations()) {
        anno.setObjectOid(aTargetGroup.getOid());
    }
    // Save the annotations
    annotationDAO.saveAnnotations(aTargetGroup.getAnnotations());
    annotationDAO.deleteAnnotations(aTargetGroup.getDeletedAnnotations());

    // Send emails for parent groups if necessary
    if (sendGroupUpdateNotifications) {
        if (AuthUtil.getRemoteUserObject() != null) {
            String userName = AuthUtil.getRemoteUserObject().getNiceName();

            // Get the new set of parents.
            Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(reloaded.getOid());

            // Determine the added parents and removed parents.
            Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents);
            addedParents.removeAll(origParents);
            Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents);
            removedParents.removeAll(newParents);

            HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents);
            generateChangeMessageNotifications(reloaded, userName, changes);
        }

        if ((removedChildren.size() > 0 || newChildren.size() > 0)) {
            generateChangeSummary(aTargetGroup, newMembers, removedTargets, gep);
        }
    }
}

From source file:org.jactr.eclipse.runtime.launching.ACTRLaunchConfigurationUtils.java

@SuppressWarnings("unchecked")
static public void computeBundleDependencies(ILaunchConfigurationWorkingCopy configuration,
        Set<String> workspaceBundles, Set<String> targetBundles) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
    IProject sourceProject = null;/*from   w w  w . j ava2s  .  com*/

    if (projectName.length() != 0)
        sourceProject = root.getProject(projectName);

    // IProject project = root.getProject(configuration.getAttribute(
    // LaunchConfigurationConstants.ACTR_PROJECT, ""));

    Collection<String> appDependencies = null;

    if (configuration.getAttribute(ACTRLaunchConstants.ATTR_ITERATIONS, 0) == 0)
        appDependencies = BundleUtilities.getDependencies(ACTRLaunchConstants.DEFAULT_APPLICATION_BUNDLE);
    else
        appDependencies = BundleUtilities.getDependencies(ACTRLaunchConstants.ITERATIVE_APPLICATION_BUNDLE);

    Collection<String> currentDependencies = Collections.EMPTY_SET;

    if (sourceProject != null && sourceProject.exists())
        currentDependencies = BundleUtilities.getDependencies(sourceProject);

    Collection<String> uniqueDependencies = new TreeSet<String>();
    for (String bundleId : appDependencies)
        uniqueDependencies.add(bundleId);

    for (String bundleId : currentDependencies)
        uniqueDependencies.add(bundleId);

    /*
     * now for the sensors
     */
    for (SensorDescriptor sensor : getRequiredSensors(configuration))
        for (String bundleId : BundleUtilities.getDependencies(sensor.getContributor()))
            uniqueDependencies.add(bundleId);

    /*
     * and instruments
     */
    for (InstrumentDescriptor instrument : getRequiredInstruments(configuration))
        for (String bundleId : BundleUtilities.getDependencies(instrument.getContributor()))
            uniqueDependencies.add(bundleId);

    /*
     * now we determine where they are coming from, we preference workspace
     * plugins over installed ones so that you can self-host
     */
    for (IPluginModelBase modelBase : PluginRegistry.getWorkspaceModels()) {
        String pluginId = modelBase.getPluginBase(true).getId();

        // not entirely clear how to get the project from the model..
        // this matters because if the project is closed, we shouldn't use it
        // IProject requiredProject = root.getProject();
        // if (requiredProject.isAccessible())
        if (pluginId != null && uniqueDependencies.remove(pluginId))
            workspaceBundles.add(pluginId);
    }

    /*
     * and the rest we assume are targets
     */
    targetBundles.addAll(uniqueDependencies);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("workspace : " + workspaceBundles.toString());
        LOGGER.debug("target : " + targetBundles.toString());
    }
}

From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.templates.GenerationUnitFactory.java

private Set<TemplateDescriptorEntity> createGenerationUnitForConsumedResource(GenerationPackage mainWorkSet,
        GenerationOptions options, AMWTemplateExceptionHandler templateExceptionHandler,
        ResourceEntity resource, int walkingPathIndex, AppServerRelationProperties properties,
        GenerationSubPackage resourceWorkSet, ConsumedResourceRelationEntity resourceRelation,
        List<Integer> excludedApplicationGroupIds, ResourceEntity slave, boolean generateTemplates,
        GenerationSubPackage parentResourceWorkSet) {

    Set<TemplateDescriptorEntity> resourceTemplates = templatesForResource(options, slave);
    // recursive call getGenerationUnitForResource does traverse the tree
    GenerationSubPackage generationUnitForResource = getGenerationUnitForResource(mainWorkSet, options,
            templateExceptionHandler, slave, excludedApplicationGroupIds, resourceTemplates, ++walkingPathIndex,
            generateTemplates, resourceWorkSet);
    //There is no generation sub package - this means, that we ignore this consumed resource and therefore don't need to continue.
    if (generationUnitForResource == null) {
        return Collections.EMPTY_SET;
    }/*w w w.j  a  v  a 2 s. c  o m*/

    // do not add if the slave resource has no relations
    if (slave.getConsumedMasterRelations() != null && !slave.getConsumedMasterRelations().isEmpty()
            || slave.getProvidedMasterRelations() != null && !slave.getProvidedMasterRelations().isEmpty()
            || slave.getVirtualConsumedResources() != null && !slave.getVirtualConsumedResources().isEmpty()) {
        mainWorkSet.addGenerationSubPackage(generationUnitForResource);
    }

    log.info(" (consumes) level(" + walkingPathIndex + "): " + slave.getName());

    String identifier = resourceRelation.buildIdentifer();
    AppServerRelationProperties slaveProperties = properties.addConsumedRelation(identifier, slave,
            resourceRelation);

    // set the SoftlinkPPI Generation Package to AppServerRelationProperies
    if (generationUnitForResource.getPackageGenerationUnit() != null
            && generationUnitForResource.getPackageGenerationUnit().getAppServerRelationProperties() != null
            && generationUnitForResource.getPackageGenerationUnit().getAppServerRelationProperties()
                    .getSoftlinkPPIGenerationPackage() != null) {
        slaveProperties.setSoftlinkPPIGenerationPackage(generationUnitForResource.getPackageGenerationUnit()
                .getAppServerRelationProperties().getSoftlinkPPIGenerationPackage());
    }

    Set<TemplateDescriptorEntity> relationTemplates = templatesForRelation(options, resourceRelation);

    ApplicationResolver applicationResolver = new ApplicationResolver(options, slave, dependencyResolver);
    if (applicationResolver.resolve()) {
        slaveProperties.addResolver(applicationResolver);
    }

    merge(options, mainWorkSet, slaveProperties);

    slaveProperties.setFunctions(functionService.getAllFunctionsForResource(slave));
    slaveProperties.setResourceTemplates(resourceTemplates);

    GenerationUnit generationUnit = new GenerationUnit(slave, resource, slaveProperties, resourceTemplates,
            relationTemplates);
    generationUnit.setGlobalFunctionTemplates(options.getContext().getGlobalFunctions());
    if (!generateTemplates) {
        generationUnit.setTemplateGenerationDisabled(true);
    }

    addUnit(resourceWorkSet, generationUnit);

    return relationTemplates;
}

From source file:org.red5.server.Scope.java

/**
 * Return set of service handler names. Removing entries from the
 * set unregisters the corresponding service handler.
 * @return            Set of service handler names
 *///www .  ja  v  a  2  s .  c o  m
public Set<String> getServiceHandlerNames() {
    Map<String, Object> serviceHandlers = getServiceHandlers(false);
    if (serviceHandlers == null) {
        return Collections.EMPTY_SET;
    }
    return serviceHandlers.keySet();
}