List of usage examples for java.util Collections EMPTY_LIST
List EMPTY_LIST
To view the source code for java.util Collections EMPTY_LIST.
Click Source Link
From source file:com.streamsets.pipeline.stage.processor.xmlflattener.TestXMLFlatteningProcessor.java
@Test public void testSingleRecordNoAttrsNoNSWithWhiteSpace() throws Exception { String xml = getXMLWithWhitespace(""); Record expected = RecordCreator.create(); expected.set(Field.create(createExpectedRecord("", "", "", ".", "#", "", false, false))); doTest(xml, "contact", ImmutableList.of(expected), Collections.EMPTY_LIST, OnRecordError.DISCARD, true, true, false, false);/*from w w w. java 2s . co m*/ }
From source file:ch.admin.suis.msghandler.signer.Signer.java
/** * Signs the PDF files in one single signing outbox. * * @param signingOutbox The signing outbox where the PDF files to sign a located. * @return A list of names of those files which had to be signed. Only the name of the files, which could be * successfully signed are returned. The list may be empty. * @throws SignerException Signer went head in the wall. * @throws ConfigurationException Configuration is doomed ! *//*from w w w .j a v a 2s . com*/ private List<File> sign(SigningOutbox signingOutbox) throws SignerException, ConfigurationException { final List<File> pdfsToSign = signingOutbox.getAllPDFsToSign(); LOG.debug("Number of PDF files to sign for " + signingOutbox.getName() + " = " + pdfsToSign.size()); if (pdfsToSign.isEmpty()) { return Collections.EMPTY_LIST; } /** * Do a refresh. Required for the SigningOutboxSedexCfg. */ signingOutbox.refresh(); final List<File> results = new ArrayList<>(pdfsToSign.size()); final BatchRunnerBuilder builder = makeBatchRunnerBuilder(signingOutbox); // we use the BatchSigner to signed a batch of a single file. By this means we prevent, that a file, that cannot // be signed, prevents to following files in the list to be signed (cf. MSGHANDLER-64) for (File pdfToSign : pdfsToSign) { try { BatchRunner batchRunner = builder.buildMinimal(); File signedPdf = determineDestinationFile(signedDir, pdfToSign); batchRunner.addFile(pdfToSign, signedPdf); batchRunner.go(); // a batch of one file results.add(pdfToSign); LOG.info(String.format("Signed file %s, the result is %s", pdfToSign.getName(), signedPdf.getAbsolutePath())); } catch (BatchException ex) { moveToCorruptedAndLog(pdfToSign, ex); } } LOG.info("Number of PDF file successfully signed in " + signingOutbox.getName() + ": " + results.size()); return results; }
From source file:de.javakaffee.kryoserializers.KryoTest.java
@BeforeTest protected void beforeTest() { _kryo = new KryoReflectionFactorySupport() { @Override//from ww w .ja v a 2 s . c o m @SuppressWarnings({ "rawtypes", "unchecked" }) public Serializer<?> getDefaultSerializer(final Class type) { if (EnumSet.class.isAssignableFrom(type)) { return new EnumSetSerializer(); } if (EnumMap.class.isAssignableFrom(type)) { return new EnumMapSerializer(); } if (Collection.class.isAssignableFrom(type)) { return new CopyForIterateCollectionSerializer(); } if (Map.class.isAssignableFrom(type)) { return new CopyForIterateMapSerializer(); } if (Date.class.isAssignableFrom(type)) { return new DateSerializer(type); } return super.getDefaultSerializer(type); } }; _kryo.setRegistrationRequired(false); _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(BigDecimal.class, new BigDecimalSerializer()); _kryo.register(BigInteger.class, new BigIntegerSerializer()); _kryo.register(Pattern.class, new RegexSerializer()); _kryo.register(BitSet.class, new BitSetSerializer()); _kryo.register(URI.class, new URISerializer()); _kryo.register(UUID.class, new UUIDSerializer()); _kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer()); _kryo.register(InvocationHandler.class, new JdkProxySerializer()); UnmodifiableCollectionsSerializer.registerSerializers(_kryo); SynchronizedCollectionsSerializer.registerSerializers(_kryo); }
From source file:architecture.ee.web.community.streams.DefaultPhotoStreamsManager.java
protected List<Photo> toPhotoList(List<String> ids) { if (ids.size() == 0) return Collections.EMPTY_LIST; List<Photo> photos = new ArrayList<Photo>(ids.size()); for (String id : ids) { Photo p;//from w w w . j ava2 s . com try { p = getPhotoById(id); photos.add(p); } catch (NotFoundException e) { } } return photos; }
From source file:TreeNode.java
/** * Return an Iterator of all children of this node. If there are no * children, an empty Iterator is returned. *///w w w . ja v a 2 s . co m public Iterator findChildren() { if (children == null) return (Collections.EMPTY_LIST.iterator()); else return (children.iterator()); }
From source file:de.bsd.hawkularFxReports.Generator.java
private List<HawkResource> getResourcesForType(String tenantId, ResourceType type) { Request request = getRequestForUrl("hawkular/inventory/resourceTypes/" + type.getId() + "/resources", null); Response response = null;/*from ww w . jav a 2 s. c o m*/ try { response = httpClient.newCall(request).execute(); } catch (IOException e) { e.printStackTrace(); // TODO: Customise this generated block main.msgField.setText(e.getMessage()); return Collections.EMPTY_LIST; } System.out.println(response.toString()); String payload = null; try { payload = response.body().string(); System.out.println(payload); } catch (IOException e) { e.printStackTrace(); // TODO: Customise this generated block return null; } List<HawkResource> resources = mapfromString(payload, new TypeReference<List<HawkResource>>() { }); return resources; }
From source file:net.ontopia.topicmaps.nav2.utils.FrameworkUtils.java
/** * INTERNAL: Evaluates a string of space-separated variable names as a list * of collections, and returns it./*w ww. jav a 2 s.co m*/ */ public static List evaluateParameterList(PageContext pageContext, String params) throws JspTagException { if (params != null && !params.equals("")) return getMultipleValuesAsList(params, pageContext); else return Collections.EMPTY_LIST; }
From source file:com.oembedler.moon.graphql.engine.dfs.MethodParameters.java
public List<MethodParameterInfo> getParameters() { return methodParameterInfos == null ? Collections.EMPTY_LIST : Lists.newArrayList(methodParameterInfos); }
From source file:de.hybris.platform.test.InvalidationSetTest.java
@Test public void testHJMPInvalidation() { final TestInvalidationTarget target = new TestInvalidationTarget(); final TestInvalidationProcessor processor = new TestInvalidationProcessor(// target, // new DummyHJMPInvalidationListener(), new DummyFlexibleSearchInvalidationListener()// );/*from ww w .j a v a 2 s .c o m*/ final InvalidationSet set = new InvalidationSet(processor) { @Override protected InvalidationTarget getRealInvalidationTarget() { return target; } }; final Object[] entityKey = asKey(Cache.CACHEKEY_HJMP, Cache.CACHEKEY_ENTITY, "1", PK.createFixedPK(1, 1)); final Object[] queryKey = asKey(Cache.CACHEKEY_FLEXSEARCH, "1", new Object() /* some object - doesn't matter */); final Object[] otherQueryKey = asKey(Cache.CACHEKEY_FLEXSEARCH, "5", new Object() /* some object - doesn't matter */); set.delayInvalidation(entityKey, 3, AbstractCacheUnit.INVALIDATIONTYPE_MODIFIED); assertEquals("invalidations have not been delayed", Collections.EMPTY_LIST, target.recordeInvalidations); assertInvalidated(set, entityKey); assertInvalidated(set, queryKey); assertNotInvalidated(set, otherQueryKey); final Object[] entityKey2 = asKey(Cache.CACHEKEY_HJMP, Cache.CACHEKEY_ENTITY, "1", PK.createFixedPK(1, 2)); final Object[] queryKey2 = asKey(Cache.CACHEKEY_FLEXSEARCH, "1", new Object() /* some object - doesn't matter */); final Object[] otherQueryKey2 = asKey(Cache.CACHEKEY_FLEXSEARCH, "123", new Object() /* * some object - doesn't * matter */); set.delayInvalidation(entityKey2, 3, AbstractCacheUnit.INVALIDATIONTYPE_REMOVED); assertEquals("invalidations have not been delayed", Collections.EMPTY_LIST, target.recordeInvalidations); assertInvalidated(set, entityKey); assertInvalidated(set, queryKey); assertNotInvalidated(set, otherQueryKey); assertInvalidated(set, entityKey2); assertInvalidated(set, queryKey2); assertNotInvalidated(set, otherQueryKey2); set.executeDelayedInvalidationsGlobally(); final List<Invalidation> expected = Arrays.asList(// InvalidationSet.createInvalidation(entityKey, -1, AbstractCacheUnit.INVALIDATIONTYPE_MODIFIED), // InvalidationSet.createInvalidation(Arrays.copyOf(queryKey, queryKey.length - 1), -1, AbstractCacheUnit.INVALIDATIONTYPE_MODIFIED), // InvalidationSet.createInvalidation(entityKey2, -1, AbstractCacheUnit.INVALIDATIONTYPE_REMOVED), // InvalidationSet.createInvalidation(Arrays.copyOf(queryKey2, queryKey.length - 1), -1, AbstractCacheUnit.INVALIDATIONTYPE_REMOVED) // ); assertEquals(expected, target.recordeInvalidations); }
From source file:com.redhat.rhn.frontend.action.help.DocSearchSetupAction.java
private List performSearch(Long sessionId, String searchString, String mode, HttpServletRequest request) throws XmlRpcFault, MalformedURLException { log.debug("Performing doc search"); // call search server XmlRpcClient client = new XmlRpcClient(ConfigDefaults.get().getSearchServerUrl(), true); List args = new ArrayList(); args.add(sessionId);/*ww w .j a va 2 s.c om*/ args.add("docs"); args.add(preprocessSearchString(searchString, mode)); // get lang we are searching in Locale l = Context.getCurrentContext().getLocale(); args.add(l.toString()); Boolean searchFreeForm = false; if (OPT_FREE_FORM.equals(mode)) { // adding a boolean of true to signify we want the results to be // constrained to closer matches, this will force the Lucene Queries // to use a "MUST" instead of the default "SHOULD". It will not // allow fuzzy matches as in spelling errors, but it will allow // free form searches to do more advanced options //args.add(true); searchFreeForm = true; } args.add(searchFreeForm); List results = Collections.emptyList(); try { results = (List) client.invoke("index.search", args); } catch (XmlRpcFault e) { if (e.getErrorCode() == 200) { //This is most likely a language error //so lets try the search the default language //removing the 'lang' from the args args.remove(args.size() - 2); results = (List) client.invoke("index.search", args); List<ValidatorWarning> warnings = new LinkedList<ValidatorWarning>(); warnings.add(new ValidatorWarning("packages.search.index_files_missing_for_docs")); getStrutsDelegate().saveMessages(request, Collections.EMPTY_LIST, warnings); } else { throw e; } } if (log.isDebugEnabled()) { log.debug("results = [" + results + "]"); } if (results.isEmpty()) { return Collections.emptyList(); } List<HelpDocumentOverview> docs = new ArrayList<HelpDocumentOverview>(); for (int x = 0; x < results.size(); x++) { HelpDocumentOverview doc = new HelpDocumentOverview(); Map item = (Map) results.get(x); log.debug("SearchServer sent us item [" + item.get("rank") + "], score = " + item.get("score") + ", summary = " + item.get("summary") + ", title = " + item.get("title") + ", url = " + item.get("url")); doc.setUrl((String) item.get("url")); doc.setTitle((String) item.get("title")); doc.setSummary((String) item.get("summary")); docs.add(doc); } return docs; }