Example usage for java.util Collections newSetFromMap

List of usage examples for java.util Collections newSetFromMap

Introduction

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

Prototype

public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) 

Source Link

Document

Returns a set backed by the specified map.

Usage

From source file:org.jahia.services.render.filter.cache.AggregateCacheFilter.java

private void storeDependency(RenderContext renderContext, String finalKey, final Cache dependenciesCache,
        String path) {//from   w ww.  ja va  2s  .c o  m
    Element element1 = dependenciesCache.get(path);
    @SuppressWarnings("unchecked")
    Set<String> dependencies = element1 != null ? (Set<String>) element1.getObjectValue()
            : Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
    if (!dependencies.contains(ALL)) {
        if ((dependencies.size() + 1) > dependenciesLimit) {
            Element element = new Element(path, ALL_SET);
            element.setEternal(true);
            dependenciesCache.put(element);
        } else {
            addDependencies(renderContext, finalKey, dependenciesCache, path, dependencies);
        }
    }
}

From source file:com.buaa.cfs.conf.Configuration.java

/**
 * A new configuration with the same settings cloned from another.
 *
 * @param other the configuration from which to clone settings.
 *///ww w.  j a va2s .  c om
@SuppressWarnings("unchecked")
public Configuration(Configuration other) {
    this.resources = (ArrayList<Resource>) other.resources.clone();
    synchronized (other) {
        if (other.properties != null) {
            this.properties = (Properties) other.properties.clone();
        }

        if (other.overlay != null) {
            this.overlay = (Properties) other.overlay.clone();
        }

        this.updatingResource = new ConcurrentHashMap<String, String[]>(other.updatingResource);
        this.finalParameters = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
        this.finalParameters.addAll(other.finalParameters);
    }

    synchronized (Configuration.class) {
        REGISTRY.put(this, null);
    }
    this.classLoader = other.classLoader;
    this.loadDefaults = other.loadDefaults;
    setQuietMode(other.getQuietMode());
}

From source file:org.rhq.core.pc.inventory.InventoryManager.java

static Resource createNewResource(DiscoveredResourceDetails details) {
    // Use a ConcurrentHashMap-based Set for childResources to allow the field to be concurrently accessed safely
    // (i.e. to avoid ConcurrentModificationExceptions).
    Set<Resource> childResources = Collections.newSetFromMap(new ConcurrentHashMap<Resource, Boolean>());
    Resource resource = new Resource(childResources);

    resource.setUuid(UUID.randomUUID().toString());
    resource.setResourceKey(details.getResourceKey());
    resource.setName(details.getResourceName());
    resource.setVersion(details.getResourceVersion());
    resource.setDescription(details.getResourceDescription());
    resource.setResourceType(details.getResourceType());

    Configuration pluginConfiguration = details.getPluginConfiguration();
    ConfigurationUtility.normalizeConfiguration(details.getPluginConfiguration(),
            details.getResourceType().getPluginConfigurationDefinition());
    resource.setPluginConfiguration(pluginConfiguration);

    return resource;
}

From source file:org.rhq.core.pc.inventory.InventoryManager.java

private Resource cloneResourceWithoutChildren(Resource resourceFromServer) {
    // Use a ConcurrentHashMap-based Set for childResources to allow the field to be concurrently accessed safely
    // (i.e. to avoid ConcurrentModificationExceptions).
    Set<Resource> childResources = Collections.newSetFromMap(new ConcurrentHashMap<Resource, Boolean>());
    Resource resource = new Resource(childResources);

    resource.setId(resourceFromServer.getId());
    resource.setUuid(resourceFromServer.getUuid());
    resource.setResourceKey(resourceFromServer.getResourceKey());
    resource.setResourceType(resourceFromServer.getResourceType());
    resource.setMtime(resourceFromServer.getMtime());
    resource.setInventoryStatus(resourceFromServer.getInventoryStatus());
    resource.setPluginConfiguration(resourceFromServer.getPluginConfiguration());
    resource.setVersion(resourceFromServer.getVersion());

    resource.setName(resourceFromServer.getName());
    resource.setDescription(resourceFromServer.getDescription());
    resource.setLocation(resourceFromServer.getLocation());

    return resource;
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterDelegate.java

/**
 * Reads the {@link net.opengis.filter.v_1_1_0.FilterCapabilities} in order to determine what types of queries the server
 * can handle.//from   w  w w. j  a v  a2  s .  c  o  m
 *
 * @param filterCapabilities The {@link net.opengis.filter.v_1_1_0.FilterCapabilities} understood by the Csw service
 */
private final void updateAllowedOperations(FilterCapabilities filterCapabilities) {
    comparisonOps = Collections.newSetFromMap(new ConcurrentHashMap<ComparisonOperatorType, Boolean>(
            new EnumMap<ComparisonOperatorType, Boolean>(ComparisonOperatorType.class)));

    spatialOps = new ConcurrentHashMap<SpatialOperatorNameType, SpatialOperatorType>(
            new EnumMap<SpatialOperatorNameType, SpatialOperatorType>(SpatialOperatorNameType.class));
    logicalOps = true;
    if (null == filterCapabilities) {
        LOGGER.error("CSW Service doesn't support any filters");
        return;
    }

    ScalarCapabilitiesType scalarCapabilities = filterCapabilities.getScalarCapabilities();

    if (null != scalarCapabilities) {
        ComparisonOperatorsType comparisonOperators = scalarCapabilities.getComparisonOperators();
        if (null != comparisonOperators) { // filter out nulls
            for (ComparisonOperatorType comp : comparisonOperators.getComparisonOperator()) {
                if (null != comp) {
                    comparisonOps.add(comp);
                }
            }
        }
        logicalOps = (null != scalarCapabilities.getLogicalOperators());
    }

    SpatialCapabilitiesType spatialCapabilities = filterCapabilities.getSpatialCapabilities();
    if (null != spatialCapabilities && null != spatialCapabilities.getSpatialOperators()) {
        setSpatialOps(spatialCapabilities.getSpatialOperators());
    }

    GeometryOperandsType geometryOperandsType = null;

    if (spatialCapabilities != null) {
        geometryOperandsType = spatialCapabilities.getGeometryOperands();
    }
    if (geometryOperandsType != null) {
        globalGeometryOperands = geometryOperandsType.getGeometryOperand();
        LOGGER.debug("globalGeometryOperands: {}", globalGeometryOperands);
    }
}

From source file:com.buaa.cfs.conf.Configuration.java

/**
 * Get the set of parameters marked final.
 *
 * @return final parameter set./*from  www . j a  va  2s  .  c o  m*/
 */
public Set<String> getFinalParameters() {
    Set<String> setFinalParams = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
    setFinalParams.addAll(finalParameters);
    return setFinalParams;
}