Example usage for java.util Collections emptyMap

List of usage examples for java.util Collections emptyMap

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public static final <K, V> Map<K, V> emptyMap() 

Source Link

Document

Returns an empty map (immutable).

Usage

From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java

/**
 * ?map???map.//from  w  w w.  ja va2 s. com
 * 
 * <p style="color:green">
 *  {@link TreeMap},key?
 * </p>
 *
 * @param arrayValueMap
 *            the array value map
 * @return {@link TreeMap}
 * @since 1.4.0
 */
public static Map<String, String> toSingleValueMap(Map<String, String[]> arrayValueMap) {// TreeMap log 
    if (Validator.isNullOrEmpty(arrayValueMap)) {
        return Collections.emptyMap();
    }

    Map<String, String> singleValueMap = new TreeMap<String, String>();
    for (Map.Entry<String, String[]> entry : arrayValueMap.entrySet()) {
        String key = entry.getKey();
        String[] values = entry.getValue();
        String singleValue = Validator.isNotNullOrEmpty(values) ? values[0] : StringUtils.EMPTY;
        singleValueMap.put(key, singleValue);
    }
    return singleValueMap;
}

From source file:ddf.catalog.transformer.html.HtmlMetacardTransformerTest.java

@Test
public void testMetacardTransform() throws CatalogTransformerException, IOException {
    Metacard metacard = new MetacardImpl();
    HtmlMetacardTransformer htmlTransformer = new HtmlMetacardTransformer(EMPTY_CATEGORY_LIST);
    BinaryContent binaryContent = htmlTransformer.transform(metacard, Collections.emptyMap());

    Document doc = getHtmlDocument(binaryContent);

    assertThat(doc.select(METACARD_CLASS), hasSize(1));
}

From source file:com.streamsets.pipeline.stage.destination.TestMapReduceConfig.java

@Before
public void setUp() {
    config = new MapReduceConfig();
    config.mapReduceConfDir = confDir;//from   w w w.  j  a v a 2  s .  com
    config.mapreduceConfigs = Collections.emptyMap();
    config.mapreduceUser = "doctor-who";
    config.kerberos = false;

    com.streamsets.pipeline.api.Configuration configuration = mock(
            com.streamsets.pipeline.api.Configuration.class);
    context = mock(Stage.Context.class);
    when(context.getConfiguration()).thenReturn(configuration);

    FileUtils.deleteQuietly(new File(confDir, "yarn-site.xml"));
    FileUtils.deleteQuietly(new File(confDir, "core-site.xml"));
    FileUtils.deleteQuietly(new File(confDir, "mapred-site.xml"));
    FileUtils.deleteQuietly(new File(confDir, "hdfs-site.xml"));
}

From source file:com.threewks.thundr.http.URLEncoder.java

/**
 * Encodes the given query parameters into the query string such that it returns <code>?param1=value1&param2=value2&....</code>.
 * //from w  w  w.  j ava2s  . co m
 * Uses toString on parameters to determine their string representation.
 * Returns an empty string if no parameters are provided.
 * 
 * @param parameters
 * @return
 */
public static final String encodeQueryString(Map<String, Object> parameters) {
    if (parameters == null) {
        parameters = Collections.emptyMap();
    }
    List<String> fragments = new ArrayList<String>(parameters.size());
    for (Map.Entry<String, Object> entry : parameters.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue() == null ? "" : entry.getValue().toString();
        fragments.add(encodeQueryComponent(key) + "=" + encodeQueryComponent(value));
    }
    return fragments.isEmpty() ? "" : "?" + StringUtils.join(fragments, "&");
}

From source file:GenericsUtil.java

private static Map<TypeVariable<?>, Type> getTypeVariableMap(final Class<?> clazz) {
    if (clazz == null) {
        return Collections.emptyMap();
    }//w  ww. j  av a 2 s.co m
    final Map<TypeVariable<?>, Type> map = new LinkedHashMap<TypeVariable<?>, Type>();
    final Class<?> superClass = clazz.getSuperclass();
    final Type superClassType = clazz.getGenericSuperclass();
    if (superClass != null) {
        gatherTypeVariables(superClass, superClassType, map);
    }
    final Class<?>[] interfaces = clazz.getInterfaces();
    final Type[] interfaceTypes = clazz.getGenericInterfaces();
    for (int i = 0; i < interfaces.length; ++i) {
        gatherTypeVariables(interfaces[i], interfaceTypes[i], map);
    }
    return map;
}

From source file:com.kenshoo.freemarker.util.DataModelParser.java

public static Map<String, Object> parse(String src, TimeZone timeZone) throws DataModelParsingException {
    if (!StringUtils.hasText(src)) {
        return Collections.emptyMap();
    }//ww  w.j  av a2  s.co  m

    Map<String, Object> dataModel = new LinkedHashMap<>();

    String lastName = null;
    int lastAssignmentStartEnd = 0;
    final Matcher assignmentStart = ASSIGNMENT_START.matcher(src);
    findAssignments: while (true) {
        boolean hasNextAssignment = assignmentStart.find(lastAssignmentStartEnd);

        if (lastName != null) {
            String value = src.substring(lastAssignmentStartEnd,
                    hasNextAssignment ? assignmentStart.start() : src.length()).trim();
            final Object parsedValue;
            try {
                parsedValue = parseValue(value, timeZone);
            } catch (DataModelParsingException e) {
                throw new DataModelParsingException(
                        "Failed to parse the value of \"" + lastName + "\":\n" + e.getMessage(), e.getCause());
            }
            dataModel.put(lastName, parsedValue);
        }

        if (lastName == null && (!hasNextAssignment || assignmentStart.start() != 0)) {
            throw new DataModelParsingException(
                    "The data model specification must start with an assignment (name=value).");
        }

        if (!hasNextAssignment) {
            break findAssignments;
        }

        lastName = assignmentStart.group(1).trim();
        lastAssignmentStartEnd = assignmentStart.end();
    }

    return dataModel;
}

From source file:io.spring.initializr.web.test.ResponseFieldSnippet.java

public ResponseFieldSnippet(String path) {
    super("response-fields", Collections.emptyMap());
    String file = path;// w  w w.jav  a  2 s  . c o  m
    if (path.endsWith("]")) {
        // In this project we actually only need snippets whose last segment is an
        // array index, so we can deal with it as a special case here. Ideally the
        // restdocs implementation of JsonField would support this use case as well.
        String index = path.substring(path.lastIndexOf("[") + 1);
        index = index.substring(0, index.length() - 1);
        this.index = Integer.valueOf(index);
        path = path.substring(0, path.lastIndexOf("["));
        file = file.replace("]", "").replace("[", ".");
    } else {
        this.index = null;
    }
    this.file = file;
    this.path = path;
    objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
}

From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionDataGetter.java

@Override
public Map<String, Object> getData(Map<String, Object> valueMap) {
    List<Locale> selectables = SelectedLocale.getSelectableLocales(vreq);
    if (selectables.isEmpty()) {
        return Collections.emptyMap();
    }//from w  w  w  . j  av a  2 s  .  c o  m

    Map<String, Object> result = new HashMap<>();
    result.put("selectLocaleUrl", UrlBuilder.getUrl("/selectLocale"));
    result.put("locales", buildLocalesList(selectables));

    Map<String, Object> bodyMap = new HashMap<>();
    bodyMap.put("selectLocale", result);
    log.debug("Sending these values: " + bodyMap);
    return bodyMap;
}

From source file:io.wcm.caravan.pipeline.extensions.hal.client.action.AbstractActionContext.java

@Before
public void setUp() {

    context = new JsonPipelineContextImpl(pipelineCtx.getJsonPipelineFactory(), pipelineCtx.getCacheAdapter(),
            pipelineCtx.getMetricRegistry(), Collections.emptyMap());
    pipelineCtx.getCaravanHttpClient().mockRequest().urlStartsWith("/resource1")
            .response(new HalResource("/resource1").getModel().toString());
    pipelineCtx.getCaravanHttpClient().mockRequest().urlStartsWith("/resource2")
            .response(new HalResource("/resource2").getModel().toString());

    Mockito.when(cacheStrategy.getCachePersistencyOptions(Matchers.any()))
            .thenReturn(CachePersistencyOptions.createTransient(0));

}

From source file:com.epam.ta.reportportal.info.AnalyticsInfoContributor.java

@Override
public Map<String, ?> contribute() {
    Optional<Map<String, AnalyticsDetails>> analytics = Optional
            .ofNullable(settingsRepository.findOne("default"))
            .flatMap(settings -> Optional.ofNullable(settings.getAnalyticsDetails()));
    return analytics.isPresent()
            ? ImmutableMap.<String, Object>builder().put(ANALYTICS_KEY, analytics.get()).build()
            : Collections.emptyMap();
}