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:org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass.java

/**
 * @return EMPTY_SET until the method is removed
 * @deprecated This method is deprecated and will be removed in a future version of Grails
 *//*from  w w w . j  av a  2 s.  c  om*/
@Deprecated
public Set getCommandObjectActions() {
    return Collections.EMPTY_SET;
}

From source file:org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass.java

/**
 * @return EMPTY_SET until the method is removed
 * @deprecated This method is deprecated and will be removed in a future version of Grails
 *//*w w  w . ja v a2 s.  co  m*/
@Deprecated
public Set getCommandObjectClasses() {
    return Collections.EMPTY_SET;
}

From source file:org.openmrs.module.emrapi.encounter.EmrEncounterServiceImpl.java

private Set<Provider> getProviders(Set<EncounterTransaction.Provider> encounteProviders) {

    if (encounteProviders == null) {
        return Collections.EMPTY_SET;
    }//  w  w w. j  av a2  s  .  c  o m

    Set<Provider> providers = new HashSet<Provider>();

    for (EncounterTransaction.Provider encounterProvider : encounteProviders) {
        Provider provider = providerService.getProviderByUuid(encounterProvider.getUuid());
        providers.add(provider);
    }
    return providers;
}

From source file:org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingsHolder.java

@SuppressWarnings("unchecked")
private UrlCreator resolveUrlCreator(final String controller, final String action, final String namespace,
        final String pluginName, String httpMethod, String version, Map params, boolean useDefault) {
    UrlMapping mapping = null;//from w ww .java 2s.  com

    if (httpMethod == null) {
        httpMethod = UrlMapping.ANY_HTTP_METHOD;
    }
    mapping = namedMappings.get(params.remove("mappingName"));
    if (mapping == null) {
        mapping = lookupMapping(controller, action, namespace, pluginName, httpMethod, version, params);
        if (mapping == null) {
            lookupMapping(controller, action, namespace, pluginName, UrlMapping.ANY_HTTP_METHOD, version,
                    params);
        }
    }
    if (mapping == null || (mapping instanceof ResponseCodeUrlMapping)) {
        UrlMappingKey lookupKey = new UrlMappingKey(controller, action, namespace, pluginName, httpMethod,
                version, Collections.EMPTY_SET);
        mapping = mappingsLookup.get(lookupKey);
        if (mapping == null) {
            lookupKey.httpMethod = UrlMapping.ANY_HTTP_METHOD;
            mapping = mappingsLookup.get(lookupKey);
        }
    }
    if (mapping == null || (mapping instanceof ResponseCodeUrlMapping)) {
        Set<String> lookupParams = new HashSet<String>(DEFAULT_ACTION_PARAMS);
        Set<String> paramKeys = new HashSet<String>(params.keySet());
        paramKeys.removeAll(lookupParams);
        lookupParams.addAll(paramKeys);
        UrlMappingKey lookupKey = new UrlMappingKey(controller, null, namespace, pluginName, httpMethod,
                version, lookupParams);
        mapping = mappingsLookup.get(lookupKey);
        if (mapping == null) {
            lookupKey.httpMethod = UrlMapping.ANY_HTTP_METHOD;
            mapping = mappingsLookup.get(lookupKey);
        }
        if (mapping == null) {
            lookupParams.removeAll(paramKeys);
            UrlMappingKey lookupKeyModifiedParams = new UrlMappingKey(controller, null, namespace, pluginName,
                    httpMethod, version, lookupParams);
            mapping = mappingsLookup.get(lookupKeyModifiedParams);
            if (mapping == null) {
                lookupKeyModifiedParams.httpMethod = UrlMapping.ANY_HTTP_METHOD;
                mapping = mappingsLookup.get(lookupKeyModifiedParams);
            }
        }
    }
    if (mapping == null || (mapping instanceof ResponseCodeUrlMapping)) {
        Set<String> lookupParams = new HashSet<String>(DEFAULT_CONTROLLER_PARAMS);
        Set<String> paramKeys = new HashSet<String>(params.keySet());
        paramKeys.removeAll(lookupParams);

        lookupParams.addAll(paramKeys);
        UrlMappingKey lookupKey = new UrlMappingKey(null, null, namespace, pluginName, httpMethod, version,
                lookupParams);
        mapping = mappingsLookup.get(lookupKey);
        if (mapping == null) {
            lookupKey.httpMethod = UrlMapping.ANY_HTTP_METHOD;
            mapping = mappingsLookup.get(lookupKey);
        }
        if (mapping == null) {
            lookupParams.removeAll(paramKeys);
            UrlMappingKey lookupKeyModifiedParams = new UrlMappingKey(null, null, namespace, pluginName,
                    httpMethod, version, lookupParams);
            mapping = mappingsLookup.get(lookupKeyModifiedParams);
            if (mapping == null) {
                lookupKeyModifiedParams.httpMethod = UrlMapping.ANY_HTTP_METHOD;
                mapping = mappingsLookup.get(lookupKeyModifiedParams);
            }
        }
    }
    UrlCreator creator = null;
    if (mapping == null || (mapping instanceof ResponseCodeUrlMapping)) {
        if (useDefault) {
            creator = new DefaultUrlCreator(controller, action);
        }
    } else {
        creator = mapping;
    }
    return creator;
}

From source file:org.dita.dost.platform.Integrator.java

/**
 * Generate and process plugin files./*from   w  w w  .  j a  v  a 2  s  .  co  m*/
 */
private void integrate() throws Exception {
    writePlugins();

    // Collect information for each feature id and generate a feature table.
    final FileGenerator fileGen = new FileGenerator(featureTable, pluginTable);
    fileGen.setLogger(logger);
    for (final String currentPlugin : orderPlugins(pluginTable.keySet())) {
        loadPlugin(currentPlugin);
    }

    // generate the files from template
    for (final String template : templateSet) {
        final File templateFile = new File(ditaDir, template);
        logger.debug("Process template " + templateFile.getPath());
        fileGen.generate(templateFile);
    }

    // generate configuration properties
    final Properties configuration = new Properties();
    // image extensions, support legacy property file extension
    final Set<String> imgExts = new HashSet<>();
    for (final String ext : properties.getProperty(CONF_SUPPORTED_IMAGE_EXTENSIONS, "")
            .split(CONF_LIST_SEPARATOR)) {
        final String e = ext.trim();
        if (e.length() != 0) {
            imgExts.add(e);
        }
    }
    if (featureTable.containsKey(FEAT_IMAGE_EXTENSIONS)) {
        for (final String ext : featureTable.get(FEAT_IMAGE_EXTENSIONS)) {
            final String e = ext.trim();
            if (e.length() != 0) {
                imgExts.add(e);
            }
        }
    }
    configuration.put(CONF_SUPPORTED_IMAGE_EXTENSIONS, StringUtils.join(imgExts, CONF_LIST_SEPARATOR));
    // extensions
    configuration.put(CONF_SUPPORTED_HTML_EXTENSIONS, readExtensions(FEAT_HTML_EXTENSIONS));
    configuration.put(CONF_SUPPORTED_RESOURCE_EXTENSIONS, readExtensions(FEAT_RESOURCE_EXTENSIONS));

    // print transtypes
    final Set<String> printTranstypes = new HashSet<>();
    if (featureTable.containsKey(FEAT_PRINT_TRANSTYPES)) {
        for (final String ext : featureTable.get(FEAT_PRINT_TRANSTYPES)) {
            final String e = ext.trim();
            if (e.length() != 0) {
                printTranstypes.add(e);
            }
        }
    }
    // support legacy property
    final String printTranstypeValue = properties.getProperty(CONF_PRINT_TRANSTYPES);
    if (printTranstypeValue != null) {
        printTranstypes.addAll(Arrays.asList(printTranstypeValue.split(PARAM_VALUE_SEPARATOR)));
    }
    configuration.put(CONF_PRINT_TRANSTYPES, StringUtils.join(printTranstypes, CONF_LIST_SEPARATOR));

    for (final Entry<String, Features> e : pluginTable.entrySet()) {
        final Features f = e.getValue();
        final String name = "plugin." + e.getKey() + ".dir";
        final List<String> baseDirValues = f.getFeature("dita.basedir-resource-directory");
        if (Boolean
                .parseBoolean(baseDirValues == null || baseDirValues.isEmpty() ? null : baseDirValues.get(0))) {
            //configuration.put(name, ditaDir.getAbsolutePath());
            configuration.put(name, ".");
        } else {
            configuration.put(name,
                    FileUtils.getRelativePath(new File(ditaDir, "dummy"), f.getPluginDir()).getPath());
        }
    }
    configuration.putAll(getParserConfiguration());

    OutputStream out = null;
    try {
        final File outFile = new File(ditaDir, "lib" + File.separator + getClass().getPackage().getName()
                + File.separator + GEN_CONF_PROPERTIES);
        if (!(outFile.getParentFile().exists()) && !outFile.getParentFile().mkdirs()) {
            throw new RuntimeException("Failed to make directory " + outFile.getParentFile().getAbsolutePath());
        }
        logger.debug("Generate configuration properties " + outFile.getPath());
        out = new BufferedOutputStream(new FileOutputStream(outFile));
        configuration.store(out, "DITA-OT runtime configuration, do not edit manually");
    } catch (final Exception e) {
        if (strict) {
            throw new RuntimeException("Failed to write configuration properties: " + e.getMessage(), e);
        } else {
            logger.error(e.getMessage(), e);
        }
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (final IOException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    final Collection<File> jars = featureTable.containsKey(FEAT_LIB_EXTENSIONS)
            ? relativize(new LinkedHashSet<>(featureTable.get(FEAT_LIB_EXTENSIONS)))
            : Collections.EMPTY_SET;
    writeEnvShell(jars);
    writeEnvBatch(jars);
}

From source file:org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.java

public static Set getSubmittedOrSelectedValuesAsSet(boolean selectMany, UIComponent uiComponent,
        FacesContext facesContext, Converter converter) {
    Set lookupSet;/*w w  w  . jav a 2  s .  c o m*/

    if (selectMany) {
        UISelectMany uiSelectMany = (UISelectMany) uiComponent;
        lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
        if (lookupSet == null) {
            lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter,
                    uiSelectMany);
        }
    } else {
        UISelectOne uiSelectOne = (UISelectOne) uiComponent;
        Object lookup = uiSelectOne.getSubmittedValue();
        if (lookup == null) {
            lookup = uiSelectOne.getValue();
            String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter,
                    lookup);
            lookupSet = Collections.singleton(lookupString);
        } else if (org.apache.myfaces.shared_impl.renderkit.RendererUtils.NOTHING.equals(lookup)) {
            lookupSet = Collections.EMPTY_SET;
        } else {
            lookupSet = Collections.singleton(lookup);
        }
    }
    return lookupSet;
}

From source file:org.jbuilt.common.renderkit.html.HtmlRendererUtils.java

public static Set getSubmittedOrSelectedValuesAsSet(boolean selectMany, UIComponent uiComponent,
        FacesContext facesContext, Converter converter) {
    Set lookupSet;/*from w w  w  .jav  a2  s . co m*/

    if (selectMany) {
        UISelectMany uiSelectMany = (UISelectMany) uiComponent;
        lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
        if (lookupSet == null) {
            lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter,
                    uiSelectMany);
        }
    } else {
        UISelectOne uiSelectOne = (UISelectOne) uiComponent;
        Object lookup = uiSelectOne.getSubmittedValue();
        if (lookup == null) {
            lookup = uiSelectOne.getValue();
            String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter,
                    lookup);
            lookupSet = Collections.singleton(lookupString);
        } else if (org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.NOTHING.equals(lookup)) {
            lookupSet = Collections.EMPTY_SET;
        } else {
            lookupSet = Collections.singleton(lookup);
        }
    }
    return lookupSet;
}

From source file:ei.ne.ke.cassandra.cql3.EntitySpecificationUtils.java

/**
 *
 *
 * @param field//from   w  ww . j av  a  2 s .c  om
 * @param entity
 * @return
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> ByteBuffer serializeAttribute(AttributeAccessor accessor, T entity) {
    Preconditions.checkNotNull(accessor);
    Preconditions.checkNotNull(entity);
    Serializer serializer = SerializerFactory.inferSerializer(accessor);
    Object value = accessor.get(entity);
    if (value == null) {
        /*
         * While the column value of a collection type column is null, the
         * column representation isn't necessarily the empty byte buffer. If
         * we have a null value for collection type on the Java side, we
         * must marshal the corresponding empty collection type to a
         * ByteBuffer representation to set the column value.
         */
        if (List.class.isAssignableFrom(accessor.getClazz())) {
            return serializer.toByteBuffer(Collections.EMPTY_LIST);
        } else if (Map.class.isAssignableFrom(accessor.getClazz())) {
            return serializer.toByteBuffer(Collections.EMPTY_MAP);
        } else if (Set.class.isAssignableFrom(accessor.getClazz())) {
            return serializer.toByteBuffer(Collections.EMPTY_SET);
        } else {
            return EMPTY_BYTE_BUFFER;
        }
    }
    ByteBuffer buf = serializer.toByteBuffer(value);
    return buf;
}

From source file:terrastore.server.impl.JsonHttpServerTest.java

@Test
public void testRemoveByRangeWithNoComparator() throws Exception {
    UpdateService updateService = createMock(UpdateService.class);
    QueryService queryService = createMock(QueryService.class);
    BackupService backupService = createMock(BackupService.class);
    StatsService statsService = createMock(StatsService.class);

    Range range = new Range(new Key("aaaa"), new Key("ffff"), 0, "", 0);

    updateService.removeByRange("bucket", range, new Predicate(null));
    expectLastCall().andReturn(new Keys(Collections.EMPTY_SET)).once();

    replay(updateService, queryService, backupService, statsService);

    JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService);

    HttpClient client = new HttpClient();
    DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket/range?startKey=aaaa&endKey=ffff");
    client.executeMethod(method);/*from   www.  ja  va2s  .com*/

    assertEquals(HttpStatus.SC_OK, method.getStatusCode());

    method.releaseConnection();

    stopServer(server);

    verify(updateService, queryService, backupService, statsService);
}

From source file:org.openmrs.module.auditlog.api.db.hibernate.interceptor.HibernateAuditLogInterceptor.java

@Override
public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
    //We need to get all collection elements and link their childlogs to the parent's
    if (collection != null) {
        PersistentCollection persistentColl = (PersistentCollection) collection;
        if (InterceptorUtil.isAudited(persistentColl.getOwner().getClass())) {
            Object owningObject = persistentColl.getOwner();
            String role = persistentColl.getRole();
            String propertyName = role.substring(role.lastIndexOf('.') + 1);
            ClassMetadata cmd = AuditLogUtil.getClassMetadata(AuditLogUtil.getActualType(owningObject));
            Object currentCollection = cmd.getPropertyValue(owningObject, propertyName, EntityMode.POJO);

            //Hibernate calls onCollectionRemove whenever the underlying collection is replaced with a
            //new instance i.e one calls the collection's setter and passes in a new instance even if the
            //new collection contains some elements, we want to treat this as regular collection update,
            //Except if onCollectionRemove is called because the owner got purged from the DB.
            //I believe hibernate calls onDelete for the owner before onCollectionRemove for all its
            //collections so we can guarantee that the owner is already in the 'deletes' thread local
            boolean isOwnerDeleted = OpenmrsUtil.collectionContains(deletes.get().peek(), owningObject);
            if (Collection.class.isAssignableFrom(collection.getClass())) {
                Collection coll = (Collection) collection;
                if (!coll.isEmpty()) {
                    if (isOwnerDeleted) {
                        if (entityRemovedChildrenMap.get().peek().get(owningObject) == null) {
                            entityRemovedChildrenMap.get().peek().put(owningObject, new HashSet<Object>());
                        }//ww w  .  jav a 2  s  .  c  o m
                        for (Object removedItem : coll) {
                            entityRemovedChildrenMap.get().peek().get(owningObject).add(removedItem);
                        }
                    } else if (!isOwnerDeleted && currentCollection == null) {
                        Class<?> propertyClass = cmd.getPropertyType(propertyName).getReturnedClass();
                        if (Set.class.isAssignableFrom(propertyClass)) {
                            currentCollection = Collections.EMPTY_SET;
                        } else if (List.class.isAssignableFrom(propertyClass)) {
                            currentCollection = Collections.EMPTY_LIST;
                        }
                    }
                }
            } else if (Map.class.isAssignableFrom(collection.getClass())) {
                if (!isOwnerDeleted && currentCollection == null) {
                    currentCollection = Collections.EMPTY_MAP;
                }
            } else {
                //TODO: Handle other persistent collections types e.g bags
            }

            if (!isOwnerDeleted) {
                handleUpdatedCollection(currentCollection, collection, owningObject, role);
            }
        }
    }
}