Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

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

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:architecture.ee.web.util.ParamUtils.java

public static <T> T getJsonParameter(HttpServletRequest request, String name, String key,
        Class<T> requiredType) {
    try {//from   ww  w.ja va 2  s . com
        Map map = getJsonParameter(request, name);
        return (T) map.get(key);
    } catch (Exception e) {
        log.error(e);
        if (requiredType == List.class)
            return (T) Collections.EMPTY_LIST;
        else if (requiredType == Map.class) {
            return (T) Collections.EMPTY_MAP;
        }
        return null;
    }
}

From source file:com.codecrate.shard.ui.event.commandbus.ApplicationWindowProgressMonitorActionCommandExecutor.java

public void execute() {
    execute(Collections.EMPTY_MAP);
}

From source file:com.tesora.dve.tools.aitemplatebuilder.FuzzyLinguisticVariable.java

public static List<FuzzyTableDistributionModel> evaluateDistributionModels(
        final FuzzyTableDistributionModel... distributionModels) {
    return evaluateDistributionModels(Collections.EMPTY_MAP, distributionModels);
}

From source file:com.espertech.esper.epl.core.eval.EvalSelectNoWildcard.java

public EventBean process(EventBean[] eventsPerStream, boolean isNewData, boolean isSynthesize) {
    ExprEvaluator[] expressionNodes = selectExprContext.getExpressionNodes();
    String[] columnNames = selectExprContext.getColumnNames();
    ExprEvaluatorContext exprEvaluatorContext = selectExprContext.getExprEvaluatorContext();
    EventAdapterService eventAdapterService = selectExprContext.getEventAdapterService();

    // Evaluate all expressions and build a map of name-value pairs
    Map<String, Object> props;

    if (expressionNodes.length == 0) {
        props = Collections.EMPTY_MAP;
    } else {//from w ww .  j ava 2  s .com
        props = new HashMap<String, Object>();
        for (int i = 0; i < expressionNodes.length; i++) {
            Object evalResult = expressionNodes[i].evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
            props.put(columnNames[i], evalResult);
        }
    }

    return eventAdapterService.adaptorForTypedMap(props, resultEventType);
}

From source file:com.impetus.kundera.ejb.EntityManagerFactoryBuilder.java

/**
* Builds up EntityManagerFactory for a given persistenceUnitName and
* overriding properties./*from   w ww . j  a v a  2s  .  c  o m*/
* 
* @param persistenceUnitName
*            the persistence unit name
* @param override
*            the override
* @return the entity manager factory
*/
public EntityManagerFactory buildEntityManagerFactory(String persistenceUnitName,
        Map<Object, Object> override) {
    PersistenceMetadata metadata = getPersistenceMetadata(persistenceUnitName);

    Properties props = new Properties();
    // Override properties
    Properties metadataProperties = metadata.getProps();
    // Make sure, it's empty or Unmodifiable
    override = override == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(override);

    // Take all from Metadata and override with supplied map 
    for (Map.Entry<Object, Object> entry : metadataProperties.entrySet()) {
        Object key = entry.getKey();
        Object value = entry.getValue();

        if (override.containsKey(key)) {
            value = override.get(key);
        }
        props.put(key, value);
    }

    // Now take all the remaining ones from override
    for (Map.Entry<Object, Object> entry : override.entrySet()) {
        Object key = entry.getKey();
        Object value = entry.getValue();

        if (!props.containsKey(key)) {
            props.put(key, value);
        }
    }

    log.info("Building EntityManagerFactory for name: " + metadata.getName() + ", and Properties:" + props);
    return new EntityManagerFactoryImpl(metadata, props);
}

From source file:org.geoserver.jdbcconfig.internal.JdbcConfigTestSupport.java

public void setUp() throws Exception {
    ConfigDatabase.LOGGER.setLevel(Level.FINER);
    // just to avoid hundreds of warnings in the logs about extension lookups with no app
    // context set
    WebApplicationContext applicationContext = Mockito.mock(WebApplicationContext.class);
    new GeoServerExtensions().setApplicationContext(applicationContext);
    when(applicationContext.getBeansOfType((Class) anyObject())).thenReturn(Collections.EMPTY_MAP);
    when(applicationContext.getBeanNamesForType((Class) anyObject())).thenReturn(new String[] {});
    ///*from w  ww .  j ava 2s.  c  o  m*/

    final File testDbDir = new File("target", "jdbcconfig");
    FileUtils.deleteDirectory(testDbDir);
    testDbDir.mkdirs();

    dataSource = new BasicDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl(connectionUrl);
    dataSource.setUsername("postgres");
    dataSource.setPassword("geo123");

    dataSource.setMinIdle(3);
    dataSource.setMaxActive(10);
    try {
        Connection connection = dataSource.getConnection();
        connection.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    try {
        dropDb(dataSource);
    } catch (Exception ignored) {
    }
    initDb(dataSource);

    XStreamInfoSerialBinding binding = new XStreamInfoSerialBinding(new XStreamPersisterFactory());

    catalog = new CatalogImpl();
    configDb = new ConfigDatabase(dataSource, binding);
    configDb.setCatalog(catalog);
    configDb.initDb(null);
}

From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java

/**
 * ?String ?:/*from  w  w  w.  j  av  a2  s .c o m*/
 * 
 * <pre>
 * short, int, long, float : 0
 * char, byte: 0
 * String: null
 * Map, List: null
 * Integer, Long, Float : null
 * Date: null
 * array: null
 * </pre>
 * 
 * @param strValue
 * @param clazz
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> T parseStringValue(String strValue, Class<T> clazz, boolean autoDefault) {

    if (DEF_NULL.equals(strValue)) {
        if (!clazz.isPrimitive()) {
            return null;
        }
        if (autoDefault) {
            return (T) getInternalDefaultValue(clazz);
        } else {
            return null;
        }
    }

    if (DEF_EMPTY.equals(strValue)) {
        if (clazz.isArray()) {
            return (T) Array.newInstance(clazz.getComponentType(), 0);
        }

        if (Map.class.isAssignableFrom(clazz)) {
            return (T) Collections.EMPTY_MAP;
        }

        if (List.class.isAssignableFrom(clazz)) {
            return (T) new ArrayList<Object>();
        }

        if (Set.class.isAssignableFrom(clazz)) {
            return (T) new HashSet<Object>();
        }

        if (String.class.equals(clazz)) {
            return (T) StringUtils.EMPTY;
        }

        if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) {
            return (T) Character.valueOf(' ');
        }

        if (autoDefault) {
            return (T) getInternalDefaultValue(clazz);
        } else {
            return null;
        }
    }

    if (StringUtils.isBlank(strValue)) {// ?
        if (autoDefault) {
            return (T) getInternalDefaultValue(clazz);
        } else {
            return null;
        }
    } else {

        if (String.class.equals(clazz)) {
            return (T) strValue;
        }

        if (Short.TYPE.equals(clazz) || Short.class.equals(clazz)) {
            return (T) Short.valueOf(strValue);
        }

        if (Integer.TYPE.equals(clazz) || Integer.class.equals(clazz)) {
            return (T) Integer.valueOf(strValue);
        }
        if (Long.TYPE.equals(clazz) || Long.class.equals(clazz)) {
            return (T) Long.valueOf(strValue);
        }
        if (Boolean.TYPE.equals(clazz) || Boolean.class.equals(clazz)) {
            return (T) Boolean.valueOf(strValue);
        }
        if (Float.TYPE.equals(clazz) || Float.class.equals(clazz)) {
            return (T) Float.valueOf(strValue);
        }
        if (Double.TYPE.equals(clazz) || Double.class.equals(clazz)) {
            return (T) Double.valueOf(strValue);
        }
        if (Byte.TYPE.equals(clazz) || Byte.class.equals(clazz)) {
            return (T) Byte.valueOf(strValue);
        }
        if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) {
            return (T) Character.valueOf(strValue.charAt(0));
        }

        if (clazz.isArray()) {
            final Class<?> componentType = clazz.getComponentType();
            // String[]
            if (String.class.equals(componentType)) {
                return (T) StringUtils.split(strValue, ',');
            }
            // ?char[]
            if (Character.TYPE.equals(componentType)) {
                return (T) strValue.toCharArray();
            }

            if (Character.class.equals(componentType)) {
                final char[] tmp = strValue.toCharArray();
                final Character[] result = new Character[tmp.length];
                for (int i = 0; i < result.length; i++) {
                    result[i] = tmp[i];
                }
                return (T) result;
            }

            if (Byte.TYPE.equals(componentType) || Byte.class.equals(componentType)) {
                return (T) (strValue == null ? null : strValue.getBytes());
            }
        }
    }

    return null;

}

From source file:org.codehaus.groovy.grails.web.mapping.DefaultUrlCreator.java

public String createURL(Map parameterValues, String encoding) {
    if (parameterValues == null)
        parameterValues = Collections.EMPTY_MAP;
    GrailsWebRequest webRequest = (GrailsWebRequest) RequestContextHolder.getRequestAttributes();
    return createURLWithWebRequest(parameterValues, webRequest, true);
}

From source file:org.hupo.psi.mi.psicquic.ws.config.PsicquicConfig.java

public Map<String, String> getProperties() {
    String propsAsString = getPropertiesAsStrings();

    if (propsAsString == null)
        return Collections.EMPTY_MAP;

    Map<String, String> propMap = new HashMap<String, String>();

    String[] props = propsAsString.split(",");

    for (String prop : props) {
        String[] propTokens = prop.trim().split("=");

        if (propTokens.length > 1) {
            propMap.put(propTokens[0], propTokens[1]);
        } else {/*from   w  w w .j  a  va  2s . c om*/
            propMap.put(prop, "");
        }
    }

    propMap.put("psicquic.rest.spec.version", getRestSpecVersion());
    propMap.put("psicquic.soap.spec.version", getSoapSpecVersion());
    propMap.put("psicquic.implementation.name", getImplementationName());
    propMap.put("psicquic.implementation.version", getVersion());

    return propMap;
}

From source file:com.feedzai.fos.impl.dummy.DummyScorer.java

@Override
public Map<UUID, double[]> score(Map<UUID, Object[]> modelIdsToScorables) {
    try {/* ww w .j a  v a2  s  .  c  om*/
        logger.trace("modelIdsToScorables='{}'", mapper.writeValueAsString(modelIdsToScorables));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return Collections.EMPTY_MAP;
}