Example usage for java.util Collections EMPTY_LIST

List of usage examples for java.util Collections EMPTY_LIST

Introduction

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

Prototype

List EMPTY_LIST

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

Click Source Link

Document

The empty list (immutable).

Usage

From source file:org.talend.components.api.service.internal.ComponentServiceImplDepsTestIT.java

@Test
@Ignore("This requires authentication credential in the settings.xml")
public void testLoadPomWithAuthentification() throws ModelBuildingException, URISyntaxException, IOException {
    ComponentServiceImpl componentServiceImpl = new ComponentServiceImpl(null);
    URL pomUrl = this.getClass().getResource("pom.xml"); //$NON-NLS-1$
    final File temporaryFolder = new File(new File(pomUrl.toURI()).getParentFile(), "tempFolder");
    System.setProperty(MavenBooter.TALEND_MAVEN_REMOTE_REPOSITORY_ID_SYS_PROP, "releases");
    System.setProperty(MavenBooter.TALEND_MAVEN_REMOTE_REPOSITORY_URL_SYS_PROP,
            "http://newbuild.talend.com:8081/nexus/content/repositories/releases/");

    try {/*ww w  .j  a v  a 2s  .c om*/
        Model pom = componentServiceImpl.loadPom(
                this.getClass().getResourceAsStream("pom_with_authentified_deps.xml"), new MavenBooter() {

                    @Override
                    File getDefaultLocalRepoDir() {
                        return temporaryFolder;
                    }

                }, Collections.EMPTY_LIST);
        List<Dependency> dependencies = pom.getDependencies();
        checkDependencies(dependencies, "runtime", DIRECT_DEPS.split(","));
    } finally {
        FileUtils.deleteDirectory(temporaryFolder);
    }
}

From source file:com.browseengine.bobo.api.BoboIndexReader.java

public static BoboIndexReader getInstance(IndexReader reader, Collection<FacetHandler<?>> facetHandlers)
        throws IOException {
    return BoboIndexReader.getInstance(reader, facetHandlers, Collections.EMPTY_LIST, new WorkArea());
}

From source file:cern.c2mon.client.core.jms.impl.RequestHandlerImplTest.java

/**
 * Checks JmsProxy method is not called for empty list request.
 * @throws JMSException/*from w ww .j a v a2  s. c  o  m*/
 * @throws InterruptedException 
 */
@Test
public void getNoTagValues() throws JMSException, InterruptedException {
    EasyMock.replay(jmsProxy);

    requestHandlerImpl.requestTagValues(Collections.EMPTY_LIST);

    EasyMock.verify(jmsProxy);
}

From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtil.java

/**
 * Resolves preload dependencies from a {@link Configuration} and resolves 
 * them using {@link MavenRepositorySystem}.
 * //  w w w .  j  a  v a2 s .co  m
 * @param configuration The configuration specifying preload dependencies.
 * @return All resolved dependencies as files.
 */
public static Collection<File> getConfiguredDependencies(Configuration configuration) {
    if (repositorySystem == null) {
        repositorySystem = new MavenRepositorySystem();
    }

    List<File> artifactsToPreload = new LinkedList<File>();

    addDefaultGlobalExclusions();

    List<Object> excludePatterns = configuration.getList(PRELOAD_EXCLUDES, Collections.EMPTY_LIST);
    for (Object excludePattern : excludePatterns) {
        String excludePatternString = excludePattern.toString();
        if (excludePattern != null && !excludePatternString.isEmpty()) {
            logger.info("Excluding {} from dependency resolution.", excludePattern);
            repositorySystem.addGlobalExclusion(excludePatternString);
        }
    }

    processMavenRepositories(configuration, repositorySystem);

    List<Object> artifacts = configuration.getList(PRELOAD_ARTIFACTS, Collections.EMPTY_LIST);
    for (Object artifactSpecification : artifacts) {
        logger.info("Resolving artifact {}.", artifactSpecification);
        try {
            List<File> dependencies = repositorySystem.resolveDependencies(artifactSpecification.toString());
            addToListIfUnique(dependencies, artifactsToPreload);
            logger.debug("{} resolved to {}.", artifactSpecification, dependencies);
        } catch (DependencyResolutionException ex) {
            logger.warn("Could not resolve artifact {}.", artifactSpecification, ex);
        }
    }

    List<Object> poms = configuration.getList(PRELOAD_POMS, Collections.EMPTY_LIST);
    for (Object pomPath : poms) {
        logger.info("Resolving artifacts from POM file: {}.", pomPath);
        try {
            List<File> dependencies = repositorySystem.resolveDependenciesFromPom(new File(pomPath.toString()));
            addToListIfUnique(dependencies, artifactsToPreload);
            logger.debug("{} resolved to {}.", pomPath, dependencies);
        } catch (DependencyResolutionException ex) {
            logger.warn("Could not resolve artifacts from {}.", pomPath, ex);
        }
    }

    repositorySystem = null;

    return artifactsToPreload;
}

From source file:de.hybris.platform.media.storage.impl.MediaCacheRecreatorTest.java

@Test
public void shouldRecreateCacheFromExistingCachedFileEntriesUsingDefaultCacheFolder() {
    // given/*from  w  w w  . j  a  v  a  2s .  c o  m*/
    final List<MediaFolderConfig> configs = Collections.EMPTY_LIST;

    // when
    cacheRecreator.recreateCache(defaultCacheFolderName, configs);

    // then
    assertThat(getMediaCacheRegion().getMaxReachedSize()).isEqualTo(10);
}

From source file:com.haulmont.cuba.core.sys.serialization.KryoSerialization.java

protected Kryo newKryoInstance() {
    Kryo kryo = new Kryo();
    kryo.setInstantiatorStrategy(new CubaInstantiatorStrategy());
    if (onlySerializable) {
        kryo.setDefaultSerializer(CubaFieldSerializer.class);
    }/*from ww  w .j  ava2 s  . co m*/

    //To work properly must itself be loaded by the application classloader (i.e. by classloader capable of loading
    //all the other application classes). For web application it means placing this class inside webapp folder.
    kryo.setClassLoader(KryoSerialization.class.getClassLoader());

    kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
    kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
    kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
    kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());
    kryo.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer());
    kryo.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer());
    kryo.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer());
    kryo.register(BitSet.class, new BitSetSerializer());
    kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
    kryo.register(InvocationHandler.class, new JdkProxySerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);

    kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer());
    ImmutableListSerializer.registerSerializers(kryo);
    ImmutableSetSerializer.registerSerializers(kryo);
    ImmutableMapSerializer.registerSerializers(kryo);
    ImmutableMultimapSerializer.registerSerializers(kryo);
    kryo.register(IndirectList.class, new IndirectContainerSerializer());
    kryo.register(IndirectMap.class, new IndirectContainerSerializer());
    kryo.register(IndirectSet.class, new IndirectContainerSerializer());

    kryo.register(org.eclipse.persistence.indirection.IndirectList.class, new IndirectContainerSerializer());
    kryo.register(org.eclipse.persistence.indirection.IndirectMap.class, new IndirectContainerSerializer());
    kryo.register(org.eclipse.persistence.indirection.IndirectSet.class, new IndirectContainerSerializer());

    //classes with custom serialization methods
    kryo.register(HashMultimap.class, new CubaJavaSerializer());
    kryo.register(ArrayListMultimap.class, new CubaJavaSerializer());
    kryo.register(MetaClassImpl.class, new CubaJavaSerializer());
    kryo.register(MetaPropertyImpl.class, new CubaJavaSerializer());
    kryo.register(UnitOfWorkQueryValueHolder.class, new UnitOfWorkQueryValueHolderSerializer(kryo));

    return kryo;
}

From source file:es.caib.zkib.jxpath.util.ValueUtils.java

/**
 * Returns an iterator for the supplied collection. If the argument
 * is null, returns an empty iterator. If the argument is not
 * a collection, returns an iterator that produces just that one object.
 * @param collection to iterate//  www .  j a  v  a2s  .  c o m
 * @return Iterator
 */
public static Iterator iterate(Object collection) {
    if (collection == null) {
        return Collections.EMPTY_LIST.iterator();
    }
    if (collection.getClass().isArray()) {
        int length = Array.getLength(collection);
        if (length == 0) {
            return Collections.EMPTY_LIST.iterator();
        }
        ArrayList list = new ArrayList();
        for (int i = 0; i < length; i++) {
            list.add(Array.get(collection, i));
        }
        return list.iterator();
    }
    if (collection instanceof Collection) {
        return ((Collection) collection).iterator();
    }
    return Collections.singletonList(collection).iterator();
}

From source file:de.hybris.platform.cms2.servicelayer.services.impl.DefaultCMSNavigationServiceTest.java

private List<CMSNavigationNodeModel> createNavigationNodes(final CatalogVersionModel catalogVersionModel) {

    final List<CMSNavigationNodeModel> navigationNodesChildren = new ArrayList<CMSNavigationNodeModel>();

    firstNavigationModel = new CMSNavigationNodeModel();
    firstNavigationModel.setChildren(Collections.EMPTY_LIST);
    firstNavigationModel.setUid("level_1_0");
    firstNavigationModel.setName("level_1_0");
    firstNavigationModel.setCatalogVersion(catalogVersionModel);
    firstNavigationModel.setParent(rootNavigationModel);
    firstNavigationModel.setChildren(Collections.EMPTY_LIST);
    firstNavigationModel.setEntries(Collections.EMPTY_LIST);
    navigationNodesChildren.add(firstNavigationModel);

    secondNavigationModel = new CMSNavigationNodeModel();
    secondNavigationModel.setUid("level_1_1");
    secondNavigationModel.setName("level_1_1");
    secondNavigationModel.setCatalogVersion(catalogVersionModel);
    secondNavigationModel.setParent(rootNavigationModel);
    secondNavigationModel.setChildren(Collections.EMPTY_LIST);
    secondNavigationModel.setEntries(wrapItemModel(createContentPages(), catalogVersionModel));
    navigationNodesChildren.add(secondNavigationModel);

    thirdNavigationModel = new CMSNavigationNodeModel();
    thirdNavigationModel.setUid("level_1_2");
    thirdNavigationModel.setName("level_1_2");
    thirdNavigationModel.setCatalogVersion(catalogVersionModel);
    thirdNavigationModel.setParent(rootNavigationModel);
    thirdNavigationModel.setChildren(Collections.EMPTY_LIST);
    thirdNavigationModel.setEntries(Collections.EMPTY_LIST);
    navigationNodesChildren.add(thirdNavigationModel);

    return navigationNodesChildren;
}

From source file:io.seldon.recommendation.RecentCategoryItemsRecommender.java

@Override
public ItemRecommendationResultSet recommend(String client, Long user, Set<Integer> dimensions,
        int maxRecsCount, RecommendationContext ctxt, List<Long> recentItemInteractions) {
    HashMap<Long, Double> recommendations = new HashMap<>();
    Set<Long> exclusions;

    if (ctxt.getMode() == RecommendationContext.MODE.INCLUSION) {
        logger.warn("Can't run RecentICategorytemsRecommender in inclusion context mode");
        return new ItemRecommendationResultSet(name);
    } else {/*from www .  java2  s  . com*/
        exclusions = ctxt.getContextItems();
    }
    Integer dimId = getDimensionForAttrName(ctxt.getCurrentItem(), client, ctxt);
    if (dimId != null) {
        Collection<Long> recList = itemStorage.retrieveRecentlyAddedItemsTwoDimensions(client,
                maxRecsCount + exclusions.size(), dimensions, dimId).getItems();
        if (recList.size() > 0) {
            double scoreIncr = 1.0 / (double) recList.size();
            int count = 0;
            for (Long item : recList) {
                if (count >= maxRecsCount)
                    break;
                else if (!exclusions.contains(item))
                    recommendations.put(item, 1.0 - (count++ * scoreIncr));
            }
            List<ItemRecommendationResultSet.ItemRecommendationResult> results = new ArrayList<>();
            for (Map.Entry<Long, Double> entry : recommendations.entrySet()) {
                results.add(new ItemRecommendationResultSet.ItemRecommendationResult(entry.getKey(),
                        entry.getValue().floatValue()));
            }
            if (logger.isDebugEnabled())
                logger.debug("Recent items algorithm returned " + recommendations.size() + " items");
            return new ItemRecommendationResultSet(results, name);
        } else {
            logger.warn("No items returned for recent items of dimension " + StringUtils.join(dimensions, ",")
                    + " for " + client);
        }
    } else
        logger.info("Can't get dimension for item " + ctxt.getCurrentItem());

    return new ItemRecommendationResultSet(Collections.EMPTY_LIST, name);
}

From source file:edu.cornell.kfs.coa.businessobject.lookup.AccountGlobalSearchLookupableHelperServiceImpl.java

/**
 * @see org.kuali.kfs.coa.businessobject.lookup.KualiAccountLookupableHelperServiceImpl#getSearchResults(java.util.Map)
 */// w w  w  . ja v  a2  s .  co m
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> parameters) {
    setBackLocation(parameters.get(KRADConstants.BACK_LOCATION));
    setDocFormKey(parameters.get(KRADConstants.DOC_FORM_KEY));
    setReferencesToRefresh(parameters.get(KRADConstants.REFERENCES_TO_REFRESH));

    if (parameters.containsKey("useOrgHierarchy")) {
        String includeOrgHierarchyStr = parameters.get("useOrgHierarchy");
        Boolean includeOrgHierarchy = (Boolean) new BooleanFormatter()
                .convertFromPresentationFormat(includeOrgHierarchyStr);
        if (includeOrgHierarchy == null)
            //Both was selected
            includeOrgHierarchy = true;
        if (includeOrgHierarchy) {
            String chartOfAccountsCode = null;
            if (parameters.containsKey(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE)) {
                chartOfAccountsCode = parameters.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
            }

            String organizationCode = null;
            if (parameters.containsKey(KFSPropertyConstants.ORGANIZATION_CODE)) {
                organizationCode = parameters.get(KFSPropertyConstants.ORGANIZATION_CODE);
            }

            if (parameters.containsKey(KFSPropertyConstants.CLOSED)) {
                final String closedValue = parameters.get(KFSPropertyConstants.CLOSED);

                if (closedValue != null && closedValue.length() != 0) {
                    if ("Y1T".indexOf(closedValue) > -1) {
                        parameters.put(KFSPropertyConstants.ACTIVE, "N");
                    } else if ("N0F".indexOf(closedValue) > -1) {
                        parameters.put(KFSPropertyConstants.ACTIVE, "Y");
                    }
                }

                parameters.remove(KFSPropertyConstants.CLOSED);
            }
            parameters.remove("useOrgHierarchy");

            List<? extends BusinessObject> searchResults;

            if (fixPrincipalNameParameters(parameters)) {
                searchResults = (List<? extends BusinessObject>) accountGlobalSearchDao
                        .getAccountsByOrgHierarchy(chartOfAccountsCode, organizationCode, parameters);

                List defaultSortColumns = getDefaultSortColumns();
                if (defaultSortColumns.size() > 0) {
                    Collections.sort(searchResults, new BeanPropertyComparator(defaultSortColumns, true));
                }
            } else {
                searchResults = Collections.EMPTY_LIST;
            }

            return searchResults;
        }
    }
    parameters.remove("useOrgHierarchy");

    return super.getSearchResults(parameters);
}