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.hdiv.web.servlet.tags.form.SelectTagTests.java

public void testEmptyItems() throws Exception {
    this.tag.setPath("country");
    this.tag.setItems(Collections.EMPTY_LIST);

    this.tag.setItemValue("isoCode");
    this.tag.setItemLabel("name");
    int result = this.tag.doStartTag();
    assertEquals(Tag.SKIP_BODY, result);

    String output = getWriter().toString();
    assertEquals("<select id=\"country\" name=\"country\"></select>", output);
}

From source file:com.sonatype.security.ldap.api.DeepEqualsBuilder.java

private static void reflectionAppend(Object lhs, Object rhs, Class clazz, EqualsBuilder builder,
        boolean useTransients, String[] excludeFields) {
    while (clazz.getSuperclass() != null) {

        Field[] fields = clazz.getDeclaredFields();
        List excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields) : Collections.EMPTY_LIST;
        AccessibleObject.setAccessible(fields, true);
        for (int i = 0; i < fields.length && builder.isEquals(); i++) {
            Field f = fields[i];//from ww  w .  jav  a2 s .c  o  m
            if (!excludedFieldList.contains(f.getName()) && (f.getName().indexOf('$') == -1)
                    && (useTransients || !Modifier.isTransient(f.getModifiers()))
                    && (!Modifier.isStatic(f.getModifiers()))) {
                try {
                    Object lhsChild = f.get(lhs);
                    Object rhsChild = f.get(rhs);
                    Class testClass = getTestClass(lhsChild, rhsChild);
                    boolean hasEqualsMethod = classHasEqualsMethod(testClass);

                    if (testClass != null && !hasEqualsMethod) {
                        reflectionAppend(lhsChild, rhsChild, testClass, builder, useTransients, excludeFields);
                    } else {
                        builder.append(lhsChild, rhsChild);
                    }
                } catch (IllegalAccessException e) {
                    // this can't happen. Would get a Security exception instead
                    // throw a runtime exception in case the impossible happens.
                    throw new InternalError("Unexpected IllegalAccessException");
                }
            }
        }

        // now for the parent
        clazz = clazz.getSuperclass();
        reflectionAppend(lhs, rhs, clazz, builder, useTransients, excludeFields);
    }
}

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

@SuppressWarnings("unchecked")
@Override/*  w  w  w .  j  ava  2  s. com*/
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 = (GenericAggregateOperation) getOperation();
        aggregates = op.aggregates;
        initialized = true;
    }
    ExecRow r1 = locatedRows.next().getRow();
    for (SpliceGenericAggregator aggregator : aggregates) {
        if (!aggregator.isInitialized(r1)) {
            //                if (RDDUtils.LOG.isTraceEnabled()) {
            //                    RDDUtils.LOG.trace(String.format("Initializing and accumulating %s", r1));
            //                }
            aggregator.initializeAndAccumulateIfNeeded(r1, r1);
        }
    }
    while (locatedRows.hasNext()) {
        ExecRow r2 = locatedRows.next().getRow();
        for (SpliceGenericAggregator aggregator : aggregates) {
            if (!aggregator.isInitialized(r2)) {
                //                    if (RDDUtils.LOG.isTraceEnabled()) {
                //                        RDDUtils.LOG.trace(String.format("Accumulating %s to %s", r2, r1));
                //                    }
                aggregator.accumulate(r2, r1);
            } else {
                //                    if (RDDUtils.LOG.isTraceEnabled()) {
                //                        RDDUtils.LOG.trace(String.format("Merging %s to %s", r2, r1));
                //                    }
                aggregator.merge(r2, r1);
            }
        }
    }
    op.finishAggregation(r1); // calls setCurrentRow
    return new SingletonIterator(new LocatedRow(r1));
}

From source file:org.beanfuse.persist.hibernate.EntityDaoHibernate.java

public List load(Class entityClass, String keyName, Object[] values) {
    if (entityClass == null || StringUtils.isEmpty(keyName) || values == null || values.length == 0) {
        return Collections.EMPTY_LIST;
    }//from   w  w  w .j av  a 2 s.com

    String entityName = Model.getEntityType(entityClass).getEntityName();
    return load(entityName, keyName, values);
}

From source file:gov.nih.nci.caarray.util.CaArrayUtils.java

/**
 * Returns an empty collection or map of the appropriate type for a given collection class. By default, returns an
 * empty list, but will return an empty set, empty sorted set, or empty map if the passed in type is a subclass of
 * Set, SortedSet, or Map respectively.//from w  w w .j av a  2s . com
 * 
 * @param collectionType the class of whose type to return an empty collection or map
 * @return the empty collection or map
 */
public static Object emptyCollectionOrMapFor(Class<?> collectionType) {
    Object val = Collections.EMPTY_LIST;
    if (SortedSet.class.isAssignableFrom(collectionType)) {
        val = EMPTY_SORTED_SET;
    } else if (Set.class.isAssignableFrom(collectionType)) {
        val = Collections.EMPTY_SET;
    } else if (List.class.isAssignableFrom(collectionType)) {
        val = Collections.EMPTY_LIST;
    } else if (Map.class.isAssignableFrom(collectionType)) {
        val = Collections.EMPTY_MAP;
    }
    return val;
}

From source file:com.sshdemo.common.security.manage.web.user.DetailAction.java

/**
 * ???/*from w  w w  .j  a v a 2 s.com*/
 */
public void query() {
    User user = fac.getUser(username);

    if (user == null) {
        logger.warn("Username is {} but get is null", username);
        DataGrid datagrid = new DataGrid(0, Collections.EMPTY_LIST);
        Struts2Util.renderJson(JSONUtil.toJSON(datagrid));
        return;
    }

    List<PropertyGridItem> items = new ArrayList<PropertyGridItem>();
    items.addAll(getItems(user.getAuthorities(), new ConvertToPropertyGridItem() {
        @Override
        public PropertyGridItem convert(Object value) {
            Authority authority = (Authority) value;
            return new PropertyGridItem(authority.getName(), authority.getRemark(), Authority_User_Title);
        }
    }));
    items.addAll(getItems(user.getGroups(), new ConvertToPropertyGridItem() {
        @Override
        public PropertyGridItem convert(Object value) {
            Group group = (Group) value;
            return new PropertyGridItem(group.getName(), group.getRemark(), Group_User_Title);
        }
    }));

    JsonBaseAction json = new JsonBaseAction();
    json.renderObject(new DataGrid(items.size(), items));
}

From source file:com.docd.purefm.tasks.SearchJavaTask.java

@NonNull
@Override
@SuppressWarnings("unchecked")
public List<String> getDeniedLocations() {
    return Collections.EMPTY_LIST;
}

From source file:de.bsd.hawkularFxReports.Generator.java

private List<ResourceType> getResourceTypesForCurrentTenant() {

    Request request = getRequestForUrl("hawkular/inventory/resourceTypes", null);

    List<ResourceType> typesMap = Collections.EMPTY_LIST;
    try {/*from www . j a v  a2 s.  c  o  m*/
        Response response = httpClient.newCall(request).execute();
        String payload = response.body().string();

        typesMap = mapfromString(payload, new TypeReference<List<ResourceType>>() {
        });

    } catch (Exception e) {
        e.printStackTrace(); // TODO: Customise this generated block
        main.msgField.setText(e.getMessage());
    }

    return typesMap;

}

From source file:io.fabric8.forge.rest.main.ForgeInitialiser.java

public void preloadCommands(CommandsResource commandsResource) {
    StopWatch watch = new StopWatch();

    LOG.info("Preloading commands");
    List<CommandInfoDTO> commands = Collections.EMPTY_LIST;
    try {//from  w  w  w  . j  a  v a 2 s . c  o  m
        commands = commandsResource.getCommands();
        LOG.info("Loaded " + commands.size() + " commands");
    } catch (Exception e) {
        LOG.error("Failed to preload commands! " + e, e);
    }

    LOG.info("preloadCommands took " + watch.taken());
}

From source file:org.springframework.data.rest.webmvc.jpa.Person.java

public Person addSibling(Person p) {

    if (siblings == Collections.EMPTY_LIST) {
        siblings = new ArrayList<Person>();
    }//from   w ww .  ja  v  a2 s .  co  m

    siblings.add(p);
    return this;
}