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:architecture.ee.web.spring.controller.MyCloudDataController.java

@RequestMapping(value = "/me/photo/album/list.json", method = { RequestMethod.POST, RequestMethod.GET })
@ResponseBody/*  www  .  j  a  v a2 s.c o  m*/
public ItemList getMyPhotoAlbumList(
        @RequestParam(value = "startIndex", defaultValue = "0", required = false) Integer startIndex,
        @RequestParam(value = "pageSize", defaultValue = "0", required = false) Integer pageSize,
        NativeWebRequest request) throws NotFoundException {

    User user = SecurityHelper.getUser();
    int count = albumManager.getTotalAlbumCount(user);
    List<Album> items;
    if (count > 0) {
        if (pageSize > 0) {
            items = albumManager.getAlbums(user, startIndex, pageSize);
        } else {
            items = albumManager.getAlbums(user);
        }
    } else {
        items = Collections.EMPTY_LIST;
    }
    ItemList list = new ItemList(items, count);
    return list;
}

From source file:com.ace.console.service.sys.impl.ResourceServiceImpl.java

/**
 * ??Menu?//w w  w .j  a va2  s . c o m
 *
 * @param resources
 * @return
 */
@ReadThroughMultiCache(namespace = Constants.DEFAULT_PROJECT_NAME + ":menu:convertToMenus", expiration = 600)
public List<Menu> convertToMenus(@ParameterValueKeyProvider List<Resources> resources) {

    if (resources.size() == 0) {
        return Collections.EMPTY_LIST;
    }

    //?,?
    Menu root = convertToMenu(resources.remove(resources.size() - 1));

    recursiveMenu(root, resources);
    List<Menu> menus = root.getChildren();
    removeNoLeafMenu(menus);

    return menus;
}

From source file:com.github.nethad.clustermeister.provisioning.ec2.AmazonConfigurationLoader.java

/**
 * Returns a set of configured {@link Credentials}.
 * //from  ww  w .  jav a 2 s . c  om
 * @return the configured credentials.
 */
public Set<Credentials> getConfiguredCredentials() {
    List<Object> keypairList = configuration.getList(KEYPAIRS, Collections.EMPTY_LIST);
    Map<String, Map<String, String>> keypairSpecifications = ConfigurationUtil.reduceObjectList(keypairList,
            "Keypairs must be specified as a list of objects.");
    Set<Credentials> credentials = Sets.newHashSetWithExpectedSize(keypairSpecifications.size());
    for (Map.Entry<String, Map<String, String>> entry : keypairSpecifications.entrySet()) {
        String keyPairName = entry.getKey();
        Map<String, String> keyPairValues = entry.getValue();
        String user = ConfigurationUtil.getCheckedConfigValue(USER, keyPairValues, "keypair", keyPairName);
        String privateKeyPath = ConfigurationUtil.getCheckedConfigValue(PRIVATE_KEY, keyPairValues, "keypair",
                keyPairName);
        File privateKey = ConfigurationUtil.getCheckedFile(privateKeyPath, PRIVATE_KEY, "keypair", keyPairName);

        String publicKeyPath = keyPairValues.get(PUBLIC_KEY);
        if (publicKeyPath != null) {
            File publicKey = ConfigurationUtil.getCheckedFile(publicKeyPath, PUBLIC_KEY, "keypair",
                    keyPairName);
            credentials.add(new KeyPairCredentials(keyPairName, user, privateKey, publicKey));
        } else {
            credentials.add(new AmazonConfiguredKeyPairCredentials(keyPairName, user, privateKey));
        }
    }

    return credentials;
}

From source file:org.apache.abdera2.common.protocol.ClientResponseImpl.java

@SuppressWarnings("unchecked")
public Iterable<Authentication> getAuthentication() {
    String cc = getHeader("WWW-Authenticate");
    return cc != null ? Authentication.parse(cc) : Collections.EMPTY_LIST;
}

From source file:com.streamsets.pipeline.stage.processor.xmlflattener.TestXMLFlatteningProcessor.java

@Test
public void testSingleRecordAttrsNSWithWhitespace() throws Exception {
    String xml = getXMLWithWhitespace("");
    Record expected = RecordCreator.create();
    expected.set(Field.create(createExpectedRecord("", "", "", "_", ".", "", true, true)));
    doTest(xml, "contact", "_", ".", "", ImmutableList.of(expected), Collections.EMPTY_LIST,
            OnRecordError.DISCARD, false, false, false, false);
}

From source file:pe.gob.mef.gescon.web.ui.RangoMB.java

public void save(ActionEvent event) {
    try {// w ww.  ja  v  a2  s . com
        if (CollectionUtils.isEmpty(this.getListaRango())) {
            this.setListaRango(Collections.EMPTY_LIST);
        }
        Rango rango = new Rango();
        rango.setVnombre(this.getNombre());
        rango.setVdescripcion(this.getDescripcion());
        if (!errorValidation(rango)) {
            LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB");
            User user = loginMB.getUser();
            RangoService service = (RangoService) ServiceFinder.findBean("RangoService");
            rango.setNrangoid(service.getNextPK());
            rango.setVnombre(StringUtils.upperCase(this.getNombre().trim()));
            rango.setVdescripcion(StringUtils.capitalize(this.getDescripcion().trim()));
            rango.setNactivo(BigDecimal.ONE);
            rango.setNtiponormaid(this.getSelectedTipoNorma());
            rango.setDfechacreacion(new Date());
            rango.setVusuariocreacion(user.getVlogin());
            service.saveOrUpdate(rango);
            this.setListaRango(service.getRangos());
            this.cleanAttributes();
            RequestContext.getCurrentInstance().execute("PF('newDialog').hide();");
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.wizard.AddExperimentEnvironmentForm.java

private void addSoftware() {

    ChoiceRenderer<Software> renderer = new ChoiceRenderer<Software>("title", "softwareId");
    LoadableListModel<Software> choiceModel = new LoadableListModel<Software>() {

        private static final long serialVersionUID = 1L;

        @Override/*from   w w  w .  j a v a2s  .co m*/
        protected List<Software> load() {

            Experiment experiment2 = model.getObject();
            ResearchGroup researchGroup = experiment2.getResearchGroup();

            if (researchGroup != null)
                return softwareFacade.getRecordsByGroup(researchGroup.getResearchGroupId());
            else
                return Collections.EMPTY_LIST;
        }

    };
    ListMultipleChoice<Software> swChoice = new ListMultipleChoice<Software>("softwares",
            new PropertyModel<List<Software>>(model.getObject(), "softwares"), choiceModel, renderer);
    swChoice.setMaxRows(SELECT_ROWS);
    swChoice.setLabel(ResourceUtils.getModel("label.software"));
    swChoice.setRequired(true);

    final FeedbackPanel feedback = createFeedbackForComponent(swChoice, "softwareFeedback");
    add(swChoice);
    add(feedback);
}

From source file:de.hybris.platform.print.services.impl.DefaultPrintJobServiceTest.java

/**
 * creates a workflow based on the @printJobWorkflowName template, starts it and sets job, checks if it exists and if the
 * workflow is set up correctly and started
 *///from   w ww  .j av  a 2 s. c om
@Test
public void testGetCurrentActions() throws Exception {
    // admin user will be owner of Workflow template and standard assignee for WorkflowActions
    final UserModel admin = getUserService().getUserForUID("admin");
    getUserService().setCurrentUser(admin);

    final WorkflowTemplateModel workflowTemplate = createPrintJobWorkflowTemplate(admin, admin);

    final WorkflowModel workflow = newestWorkflowService.createWorkflow(getPrintJobWorkflowName(),
            workflowTemplate, Collections.EMPTY_LIST, admin);
    getModelService().refresh(workflow);

    // get current actions now uses job history entries
    final CommentModel comment = prepareComment("testComment1", "MyJob", 0, createUser("TestUser"));
    comment.setWorkflow(workflow);
    getModelService().save(comment);

    workflowProcessingService.startWorkflow(newestWorkflowService.getWorkflowForCode(workflow.getCode()));

    final WorkflowActionModel startAction = workflowActionService.getStartWorkflowActions(workflow).get(0);
    final WorkflowDecisionModel decision12 = (WorkflowDecisionModel) startAction.getDecisions().toArray()[0];

    workflowProcessingService.decideAction(startAction, decision12);

    // execute method to test from business logic
    final List<WorkflowActionModel> currentActions = printJobService.getCurrentActions(workflow);
    // verify getCurrentAction delivers WorkflowAction middle from our default template
    assertSame("current actions list does not have correct amount of actions",
            Integer.valueOf(currentActions.size()), Integer.valueOf(1));
    assertEquals("wrong action found", workflowActionService.getNormalWorkflowActions(workflow).get(0),
            currentActions.get(0));

}

From source file:io.fabric8.forge.camel.commands.project.AbstractCamelProjectCommand.java

protected List<NodeDto> configureXmlNodes(final UIContext context, final Project project, final String selected,
        final UISelectOne<String> xml, final UISelectOne<String> node) throws Exception {

    // because the UISelectOne must be unique we need to use a running number
    int index = 1;

    List<NodeDto> nodes;/*from w  w  w . ja v a  2 s. c om*/

    String xmlResourceName = xml.getValue();
    if (Strings.isNullOrBlank(xmlResourceName)) {
        xmlResourceName = selected;
    }
    if (Strings.isNotBlank(xmlResourceName)) {
        List<ContextDto> camelContexts = CamelXmlHelper.loadCamelContext(camelCatalog, context, project,
                xmlResourceName);
        nodes = NodeDtos.toNodeList(camelContexts);
        // if there is one CamelContext then pre-select the first node (which is the route)
        if (camelContexts.size() == 1 && nodes.size() > 1) {
            node.setDefaultValue("1 " + nodes.get(1).getLabel());
        }
    } else {
        nodes = Collections.EMPTY_LIST;
    }

    final List<NodeDto> answer = nodes;

    List<String> choices = new ArrayList<>();
    for (NodeDto dto : nodes) {
        choices.add(index + " " + dto.getLabel());
        index++;
    }
    node.setValueChoices(choices);
    // to convert from key to label (with number)
    // this converter is needed for the web console as it uses the key to select which node to edit
    // and we need to be able to convert from the key to the correct node in the list
    node.setValueConverter(s -> {
        for (int i = 0; i < answer.size(); i++) {
            NodeDto dto = answer.get(i);
            if (dto.getKey().equals(s)) {
                int number = i + 1;
                return number + " " + dto.getLabel();
            }
        }
        return s;
    });

    return answer;
}

From source file:lumbermill.api.JsonEvent.java

public List<String> getTags() {

    if (!jsonNode.has("tags")) {
        return Collections.EMPTY_LIST;
    }// w ww .  java2 s  .c  om
    ArrayNode node = (ArrayNode) jsonNode.get("tags");
    List<String> tags = new ArrayList<>();
    for (JsonNode jNode : node) {
        tags.add(jNode.asText());
    }
    return tags;
}