Example usage for java.util Collections singletonList

List of usage examples for java.util Collections singletonList

Introduction

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

Prototype

public static <T> List<T> singletonList(T o) 

Source Link

Document

Returns an immutable list containing only the specified object.

Usage

From source file:eionet.cr.harvest.scheduled.UrgentHarvestQueue.java

/**
 * Calls {@link #addPullHarvests(List, String)} with a singleton-list from the given URL and the given user name.
 *
 * @param url The URL.//from   ww w.ja  v a  2  s  .co  m
 * @param userName The user name.
 * @throws HarvestException HarvestException Wraps any sort of exception that happens.
 */
public static synchronized void addPullHarvest(String url, String userName) throws HarvestException {

    addPullHarvests(Collections.singletonList(url), userName);
}

From source file:de.hybris.platform.acceleratorservices.sitemap.populators.ProductModelToSiteMapUrlDataPopulator.java

@Override
public void populate(final ProductModel productModel, final SiteMapUrlData siteMapUrlData)
        throws ConversionException {
    final String relUrl = StringEscapeUtils.escapeXml(getUrlResolver().resolve(productModel));
    siteMapUrlData.setLoc(relUrl);//from  w ww .j  a v a  2s  .com
    if (productModel.getPicture() != null) {
        siteMapUrlData.setImages(Collections.singletonList(productModel.getPicture().getURL()));
    }
}

From source file:com.whizzosoftware.hobson.dto.data.DataStreamDataDTOTest.java

@Test
public void testToJSON() {
    DataStreamDataDTO dto = new DataStreamDataDTO.Builder(
            new ManagerDTOBuildContext.Builder().idProvider(new ContextPathIdProvider()).build(), "ds1", 2000,
            DataStreamInterval.HOURS_1)//  w w  w  .ja v a 2s .  c o m
                    .fields(Collections.singletonList(new DataStreamField("field1", "fieldName1",
                            VariableContext.createLocal("plugin1", "device1", "var1"))))
                    .data(Collections.singletonList(
                            new DataStreamValueSet(1000, Collections.singletonMap("field1", (Object) 100))))
                    .build();

    JSONObject json = dto.toJSON();
    assertEquals(2000, json.getInt("endTime"));
    JSONObject f = json.getJSONObject("fields");
    assertEquals("fieldName1", f.getString("field1"));
    JSONArray a = json.getJSONArray("data");
    assertEquals(1, a.length());
    assertEquals(1000, a.getJSONObject(0).getInt("timestamp"));
    assertEquals(100, a.getJSONObject(0).getInt("field1"));
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.controllers.util.GlobalMessages.java

public static void addMessage(final Model model, final String messageHolder, final String messageKey,
        final Object[] attributes) {
    final GlobalMessage message = new GlobalMessage();
    message.setCode(messageKey);/*  ww  w  . j  a va 2 s  . c  o  m*/
    message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList());

    final Map<String, Object> modelMap = model.asMap();
    if (modelMap.containsKey(messageHolder)) {
        final List<GlobalMessage> messages = new ArrayList<>((List<GlobalMessage>) modelMap.get(messageHolder));
        messages.add(message);
        model.addAttribute(messageHolder, messages);
    } else {
        model.addAttribute(messageHolder, Collections.singletonList(message));
    }
}

From source file:me.smoe.adar.zookeeper.zookeeper.Zookeeper.java

public static void auth(ZooKeeper zooKeeper)
        throws NoSuchAlgorithmException, KeeperException, InterruptedException {
    ACL acl = new ACL(Perms.READ, new Id("digest", DigestAuthenticationProvider.generateDigest("admin:admin")));

    zooKeeper.create("/auth", "auth".getBytes(), Collections.singletonList(acl), CreateMode.EPHEMERAL);
}

From source file:com.hp.autonomy.aci.content.identifier.reference.ReferencesBuilder.java

/**
 * Creates a {@code ReferencesBuilder} with the specified reference and section number as the only entry.
 *
 * @param reference The initial ids//from   www .  j av  a 2  s .c  o m
 * @param section The section number
 */
public ReferencesBuilder(final String reference, final int section) {
    doAppend(Collections.singletonList(new Reference(reference, section)));
}

From source file:com.hp.autonomy.aci.content.fieldtext.WILD.java

/**
 * Constructs a new single field WILD fieldtext
 * @param field The field name/*  w  w w . j ava2 s.co  m*/
 * @param values The field values
 */
public WILD(final String field, final Iterable<String> values) {
    this(Collections.singletonList(field), values);
}

From source file:com.exxonmobile.ace.hybris.storefront.controllers.util.GlobalMessages.java

public static void addMessage(final Model model, final String messageHolder, final String messageKey,
        final Object[] attributes) {
    final GlobalMessage message = new GlobalMessage();
    message.setCode(messageKey);/*from   w  w  w .  j a  v a 2  s. c  o  m*/
    message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList());

    final Map<String, Object> modelMap = model.asMap();
    if (modelMap.containsKey(messageHolder)) {
        final List<GlobalMessage> messages = new ArrayList<GlobalMessage>(
                (List<GlobalMessage>) modelMap.get(messageHolder));
        messages.add(message);
        model.addAttribute(messageHolder, messages);
    } else {
        model.addAttribute(messageHolder, Collections.singletonList(message));
    }
}

From source file:net.community.chest.gitcloud.facade.frontend.FacadeEnvironmentInitializer.java

@Override
protected void extractConfigFiles(File confDir) {
    // TODO use some automatic detection mechanism for "META-INF/conf"
    extractConfigFiles(confDir, Collections.singletonList(Pair.<String, Collection<String>>of(
            "META-INF/" + ConfigUtils.CONF_DIR_NAME,
            Collections.unmodifiableList(Arrays.asList(PROPS_FILE_NAME, "gitcloud-frontend-log4j.xml")))));
}

From source file:com.hp.autonomy.aci.content.fieldtext.STRING.java

/**
 * Constructs a new single field STRING fieldtext
 * @param field The field name// ww w .j  a  va 2s .  co m
 * @param values The field values
 */
public STRING(final String field, final Iterable<String> values) {
    this(Collections.singletonList(field), values);
}