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:com.streamsets.pipeline.stage.processor.fieldhasher.TestFieldHasherProcessorSpecific.java

@Test
public void testMultipleFieldsDifferentHashTypes() throws StageException {
    FieldHasherConfig sha1HasherConfig = new FieldHasherConfig();
    sha1HasherConfig.sourceFieldsToHash = ImmutableList.of("/age", "/name");
    sha1HasherConfig.hashType = HashType.SHA1;

    FieldHasherConfig sha2HasherConfig = new FieldHasherConfig();
    sha2HasherConfig.sourceFieldsToHash = ImmutableList.of("/sex");
    sha2HasherConfig.hashType = HashType.SHA256;

    FieldHasherConfig sha512HasherConfig = new FieldHasherConfig();
    sha512HasherConfig.sourceFieldsToHash = ImmutableList.of("/nickName");
    sha512HasherConfig.hashType = HashType.SHA512;

    FieldHasherConfig md5HasherConfig = new FieldHasherConfig();
    md5HasherConfig.sourceFieldsToHash = ImmutableList.of("/streetAddress");
    md5HasherConfig.hashType = HashType.MD5;

    FieldHasherConfig murmur3HasherConfig = new FieldHasherConfig();
    murmur3HasherConfig.sourceFieldsToHash = ImmutableList.of("/birthYear");
    murmur3HasherConfig.hashType = HashType.MURMUR3_128;

    HasherConfig hasherConfig = new HasherConfig();
    TestFieldHasherProcessor.populateEmptyRecordHasherConfig(hasherConfig, HashType.MD5);

    hasherConfig.inPlaceFieldHasherConfigs = ImmutableList.of(sha1HasherConfig, sha2HasherConfig,
            sha512HasherConfig, md5HasherConfig, murmur3HasherConfig);
    hasherConfig.targetFieldHasherConfigs = Collections.EMPTY_LIST;
    hasherConfig.useSeparator = true; //old way.  pre SDC-6540.

    FieldHasherProcessor processor = new FieldHasherProcessor(hasherConfig,
            OnStagePreConditionFailure.CONTINUE);

    ProcessorRunner runner = new ProcessorRunner.Builder(FieldHasherDProcessor.class, processor)
            .addOutputLane("a").build();
    runner.runInit();/*from   w  w  w. java 2 s .c  o  m*/

    try {
        Map<String, Field> map = new LinkedHashMap<>();
        map.put("name", Field.create("a"));
        map.put("age", Field.create(21));
        map.put("sex", Field.create(Field.Type.STRING, "male"));
        map.put("nickName", Field.create(Field.Type.STRING, "b"));
        map.put("streetAddress", Field.create("sansome street"));
        map.put("birthYear", Field.create(1988));
        Record record = RecordCreator.create("s", "s:1");
        record.set(Field.create(map));

        StageRunner.Output output = runner.runProcess(ImmutableList.of(record));
        Assert.assertEquals(1, output.getRecords().get("a").size());
        Field field = output.getRecords().get("a").get(0).get();
        Assert.assertTrue(field.getValue() instanceof Map);
        Map<String, Field> result = field.getValueAsMap();
        Assert.assertEquals(6, result.size());
        Assert.assertTrue(result.containsKey("name"));
        Assert.assertEquals(TestFieldHasherProcessor.computeHash(Field.Type.STRING, "a", HashType.SHA1),
                result.get("name").getValue());
        Assert.assertTrue(result.containsKey("age"));
        Assert.assertEquals(TestFieldHasherProcessor.computeHash(Field.Type.INTEGER, 21, HashType.SHA1),
                result.get("age").getValue());
        Assert.assertTrue(result.containsKey("sex"));
        Assert.assertEquals(TestFieldHasherProcessor.computeHash(Field.Type.STRING, "male", HashType.SHA256),
                result.get("sex").getValue());
        Assert.assertTrue(result.containsKey("nickName"));
        Assert.assertEquals(TestFieldHasherProcessor.computeHash(Field.Type.STRING, "b", HashType.SHA512),
                result.get("nickName").getValue());
        Assert.assertTrue(result.containsKey("streetAddress"));
        Assert.assertEquals(
                TestFieldHasherProcessor.computeHash(Field.Type.STRING, "sansome street", HashType.MD5),
                result.get("streetAddress").getValue());
        Assert.assertTrue(result.containsKey("birthYear"));
        Assert.assertEquals(
                TestFieldHasherProcessor.computeHash(Field.Type.INTEGER, 1988, HashType.MURMUR3_128),
                result.get("birthYear").getValue());
    } finally {
        runner.runDestroy();
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.SearchInquiriesResultPageDA.java

public ActionForward prepare(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) {//  w  w  w . j  a  v  a 2  s  .c o  m

    SearchInquiriesResultPageDTO searchPageDTO = (SearchInquiriesResultPageDTO) actionForm;
    if (searchPageDTO.isEmptyExecutionSemesterID()) {
        final ExecutionSemester executionSemester = ExecutionSemester.readActualExecutionSemester();
        if (executionSemester != null) {
            final ExecutionSemester previous = executionSemester.getPreviousExecutionPeriod();
            if (previous != null) {
                searchPageDTO.setExecutionSemesterID(previous.getExternalId());
            }
        }
    }

    if (!searchPageDTO.isEmptyExecutionSemesterID()) {
        return selectExecutionSemester(actionMapping, actionForm, request, response);
    }

    request.setAttribute("executionCourses", Collections.EMPTY_LIST);
    request.setAttribute("executionDegrees", Collections.EMPTY_LIST);
    request.setAttribute("executionSemesters", getExecutionSemesters());

    return actionMapping.findForward("searchPage");
}

From source file:io.gravitee.management.repository.plugins.RepositoryPluginHandler.java

@Override
public void handle(Plugin plugin) {
    try {/*from  w w  w .j a va2s  .c om*/
        ClassLoader classloader = pluginClassLoaderFactory.getOrCreateClassLoader(plugin,
                this.getClass().getClassLoader());

        final Class<?> repositoryClass = classloader.loadClass(plugin.clazz());
        LOGGER.info("Register a new repository: {} [{}]", plugin.id(), plugin.clazz());

        Assert.isAssignable(Repository.class, repositoryClass);

        Repository repository = createInstance((Class<Repository>) repositoryClass);
        Collection<Scope> scopes = scopeByRepositoryType.getOrDefault(repository.type(),
                Collections.EMPTY_LIST);

        for (Scope scope : scopes) {
            if (!repositories.containsKey(scope)) {
                // Not yet loaded, let's mount the repository in application context
                try {
                    ApplicationContext applicationContext = pluginContextFactory
                            .create(new AnnotationBasedPluginContextConfigurer(plugin) {
                                @Override
                                public Set<Class<?>> configurations() {
                                    return Collections.singleton(repository.configuration(scope));
                                }
                            });

                    registerRepositoryDefinitions(repository, applicationContext);
                    repositories.put(scope, repository);
                } catch (Exception iae) {
                    LOGGER.error("Unexpected error while creating context for repository instance", iae);
                    pluginContextFactory.remove(plugin);
                }

            } else {
                LOGGER.warn("Repository scope {} already loaded by {}", scope, repositories.get(scope));
            }
        }
    } catch (Exception iae) {
        LOGGER.error("Unexpected error while create repository instance", iae);
    }
}

From source file:com.example.data.PetData.java

public List<Map<String, Object>> findPetByTags(String tags) throws SQLException {
    QueryRunner run = new QueryRunner(H2DB.getDataSource());
    List<String> tagList = Arrays.asList(tags.split(","));

    if (tagList.isEmpty())
        return Collections.EMPTY_LIST;
    else {//from   w  w  w. jav  a 2 s.  c  o  m
        return run
                .query("select * from pet",
                        H2DB.mkResultSetHandler("id", "name", "categoryId", "photoUrls", "tags", "status"))
                .stream().map(m -> {
                    m.put("photoUrls", H2DB.strToList((String) m.get("photoUrls")));
                    m.put("tags", H2DB.strToList((String) m.get("tags")));
                    m.put("category", getCategory(run, (Long) m.get("categoryId")));
                    m.remove("categoryId");
                    return m;
                }).filter(m -> {
                    if (m.get("tags") == null)
                        return false;
                    else {
                        List<String> its = (List<String>) m.get("tags");
                        List<String> tmp = new ArrayList<>(its);
                        tmp.removeAll(tagList);
                        return tmp.size() != its.size();
                    }
                }).collect(Collectors.toList());
    }
}

From source file:com.kelveden.karma.AbstractStartMojo.java

protected List<String> valueToKarmaArgument(final Boolean value, final String trueSwitch,
        final String falseSwitch) {
    if (value == null) {
        return Collections.EMPTY_LIST;
    }/* ww  w .  j a  v  a 2  s. c  o  m*/

    if (value.booleanValue()) {
        return Arrays.asList(trueSwitch);
    } else {
        return Arrays.asList(falseSwitch);
    }
}

From source file:com.splicemachine.derby.stream.function.ScalarAggregateFlatMapFunction.java

@SuppressWarnings("unchecked")
@Override/* w  w w .  j a v  a  2  s  .c o m*/
public Iterator<LocatedRow> call(Iterator<LocatedRow> locatedRows) throws Exception {
    if (!locatedRows.hasNext()) {
        return returnDefault ? new SingletonIterator(new LocatedRow(getOperation().getExecRowDefinition()))
                : Collections.EMPTY_LIST.iterator();
    }
    if (!initialized) {
        op = getOperation();
        initialized = true;
    }
    ExecRow r1 = locatedRows.next().getRow();
    if (!op.isInitialized(r1)) {
        //            if (RDDUtils.LOG.isTraceEnabled()) {
        //                RDDUtils.LOG.trace(String.format("Initializing and accumulating %s", r1));
        //            }
        op.initializeVectorAggregation(r1);
    }
    while (locatedRows.hasNext()) {
        ExecRow r2 = locatedRows.next().getRow();
        if (!op.isInitialized(r2)) {
            accumulate(r2, r1);
        } else {
            merge(r2, r1);
        }
    }
    op.finishAggregation(r1); // calls setCurrentRow
    return new SingletonIterator(new LocatedRow(r1));
}

From source file:com.creditcloud.ump.model.ump.utils.MessageUtils.java

public static List<UmpAgreementResult> parseAgreementList(String agreementList) {
    if (StringUtils.isEmpty(agreementList)) {
        return Collections.EMPTY_LIST;
    }/*from  w  w w.  j a  v a 2s  .  c o  m*/

    String[] agreementStrList = StringUtils.split(agreementList, '|');
    List<UmpAgreementResult> results = new ArrayList<>(agreementStrList.length);
    for (String agreement : agreementStrList) {
        String[] args = StringUtils.split(agreement, ',');
        if (args.length < 2) {
            String errMsg = String.format("wrong format in ump agreement list:%s, ignore", agreement);
            logger.log(Level.SEVERE, errMsg);
            continue;
        }
        UmpAgreementType type = UmpAgreementType.valueOf(args[0]);
        String code = args[1];
        String msg = null;
        if (args.length > 2) {
            msg = args[2];
        }
        results.add(new UmpAgreementResult(type, code, msg));
    }

    return results;
}

From source file:de.hybris.platform.order.interceptors.DefaultAbstractOrderEntryPreparer.java

@Override
public void onPrepare(final Object model, final InterceptorContext ctx) throws InterceptorException {
    if (model instanceof AbstractOrderEntryModel && !ctx.isRemoved(model)) {
        final AbstractOrderEntryModel entryModel = (AbstractOrderEntryModel) model;

        //change calculated flag if any of the subjected attributed has changed, but not if calculated flag is dirty.
        if (isOneOfAttributesModified(entryModel, getAttributesForOrderRecalculation(), ctx)
                && !ctx.isModified(entryModel, AbstractOrderEntryModel.CALCULATED)) {
            entryModel.setCalculated(Boolean.FALSE);
            final AbstractOrderModel ownerOrder = entryModel.getOrder();
            if (ownerOrder != null && Boolean.TRUE.equals(ownerOrder.getCalculated())) {
                ownerOrder.setCalculated(Boolean.FALSE);
                ctx.registerElement(ownerOrder, getModelSource(ctx, ownerOrder));
            }//  w  w w  . j  a v a  2s .  c  o  m
        }
        if (isAttributeModified(entryModel, AbstractOrderEntryModel.PRODUCT, ctx)) {
            //automatically generate info
            entryModel.setInfo(createEntryInformation(entryModel, ctx));
        }

        if (ctx.isNew(entryModel)) {
            if (entryModel.getTaxValues() == null) {
                entryModel.setTaxValues(Collections.EMPTY_LIST);
            }
            if (entryModel.getDiscountValues() == null) {
                entryModel.setDiscountValues(Collections.EMPTY_LIST);
            }

        }

        if (isAttributeModified(entryModel, AbstractOrderEntryModel.ENTRYNUMBER, ctx)) {
            final Integer entryNumber = entryModel.getEntryNumber();
            final AbstractOrderModel order = entryModel.getOrder();
            final List<AbstractOrderEntryModel> currentOrderEntries = order.getEntries();
            if (entryNumber == null || APPEND_AS_LAST >= entryNumber.intValue()) {
                setEntryNumberAslast(entryModel, currentOrderEntries);
            }
            final List<AbstractOrderEntryModel> newEntries = currentOrderEntries == null
                    ? new ArrayList<AbstractOrderEntryModel>()
                    : new ArrayList<AbstractOrderEntryModel>(currentOrderEntries);
            if (!newEntries.contains(entryModel)) {
                newEntries.add(entryModel);
                order.setEntries(newEntries);
            }
        }
    }
}

From source file:it.unibas.spicy.model.mapping.rewriting.sourcenulls.FindNullablePathsInSource.java

@SuppressWarnings("unchecked")
private PathClassification classifyPathsInDataSource(IDataSourceProxy sourceProxy) {
    List<PathExpression> nullablePaths = new ArrayList<PathExpression>();
    List<PathExpression> notNullablePaths = new ArrayList<PathExpression>();
    List<PathExpression> allAttributes = findAllAttributes(sourceProxy);
    for (PathExpression pathExpression : allAttributes) {
        INode attributeNode = nodeFinder.findNodeInSchema(pathExpression, sourceProxy);
        if (attributeNode.isNotNull()) {
            notNullablePaths.add(pathExpression);
        } else {//from  ww  w .  jav  a2  s.c  om
            nullablePaths.add(pathExpression);
        }
    }
    return new PathClassification(sourceProxy, nullablePaths, notNullablePaths, Collections.EMPTY_LIST);
}

From source file:de.hybris.platform.test.InvalidationSetTest.java

@Test
public void testSimpleRecording() {
    final TestInvalidationTarget target = new TestInvalidationTarget();
    final PassThroughTestInvalidationProcessor processor = new PassThroughTestInvalidationProcessor(target);
    final InvalidationSet set = new InvalidationSet(processor);

    assertTrue(set.isEmpty());/* w  w w .jav  a 2 s.  c  om*/

    final Object[] key = asKey("a", "b", "c");
    // invalidate [a,b,c] -> *
    set.delayInvalidation(key, 2, AbstractCacheUnit.INVALIDATIONTYPE_MODIFIED);
    assertEquals(Collections.EMPTY_LIST, target.recordeInvalidations);

    assertFalse(set.isEmpty());
    assertInvalidated(set, "a", "b", "c");
    assertInvalidated(set, "a", "b", "c", "d");

    assertNotInvalidated(set, "a", "b", "x");
    assertNotInvalidated(set, "a", "b");
    assertNotInvalidated(set, "a");

    set.executeDelayedInvalidationsGlobally();
    assertEquals(
            Arrays.asList(
                    InvalidationSet.createInvalidation(key, -1, AbstractCacheUnit.INVALIDATIONTYPE_MODIFIED)),
            target.recordeInvalidations);
}