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:com.adobe.ags.curly.test.ErrorBehaviorTest.java

@Test
public void testActionIgnore() throws IOException, ParseException {
    ApplicationState.getInstance().errorBehaviorProperty().set(ErrorBehavior.HALT);
    Action fail1 = failureAction();
    Action fail2 = failureAction();
    fail1.setErrorBehavior(ErrorBehavior.IGNORE);
    fail2.setErrorBehavior(ErrorBehavior.IGNORE);
    List<Action> actions = Arrays.asList(fail1, fail2);
    ActionGroupRunner runner = new ActionGroupRunner("Action Ignore Test", ignore -> client, actions,
            Collections.EMPTY_MAP, Collections.EMPTY_SET);
    runner.run();/*w  w  w .  j ava2  s  .  c  om*/
    assertResults(runner.getResult(), false, true);
}

From source file:net.mlw.vlh.adapter.jdbc.util.ConfigurableStatementBuilder.java

/**
 * @see net.mlw.vlh.adapter.jdbc.util.StatementBuilder#generate(java.sql.Connection, java.lang.StringBuffer, java.util.Map, boolean)
 *//*from   w w w .ja v  a  2  s .  c  o m*/
public PreparedStatement generate(Connection conn, StringBuffer query, Map whereClause, boolean scrollable)
        throws SQLException, ParseException {
    if (!init) {
        init();
    }

    if (whereClause == null) {
        whereClause = Collections.EMPTY_MAP;
    }

    for (Iterator iter = textManipulators.iterator(); iter.hasNext();) {
        TextManipulator manipulator = (TextManipulator) iter.next();
        manipulator.manipulate(query, whereClause);
    }

    LinkedList arguments = new LinkedList();

    // Replace any "{key}" with the value in the whereClause Map,
    // then placing the value in the partameters list.
    for (int i = 0, end = 0, start; ((start = query.toString().indexOf('{', end)) >= 0); i++) {
        end = query.toString().indexOf('}', start);

        String key = query.substring(start + 1, end);

        Object value = whereClause.get(key);
        if (value == null) {
            throw new NullPointerException("Property '" + key + "' was not provided.");
        }
        arguments.add(new NamedPair(key, value));
        Setter setter = getSetter(key);
        query.replace(start, end + 1, setter.getReplacementString(value));
        end -= (key.length() + 2);
    }

    PreparedStatement statement = null;
    if (scrollable) {
        statement = conn.prepareStatement(query.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
    } else {
        statement = conn.prepareStatement(query.toString());
    }

    int index = 1;
    // Now set all the patameters on the statement.
    for (Iterator iter = arguments.iterator(); iter.hasNext();) {
        NamedPair namedPair = (NamedPair) iter.next();
        Setter setter = getSetter(namedPair.getName());
        try {
            index = setter.set(statement, index, namedPair.getValue());
        } catch (RuntimeException e) {
            String message = "Cannot set value of " + namedPair.getName() + " (setter = " + setter + ")";
            LOGGER.error(message, e);
            throw new RuntimeException(message, e);
        }
    }

    return statement;
}

From source file:com.netflix.metacat.connector.hive.converters.HiveConnectorInfoConverter.java

/**
 * Converts from DatabaseDto to the connector database.
 *
 * @param databaseInfo Metacat database Info
 * @return connector database/*from  w w w  . j a v a  2s . c om*/
 */
@Override
public Database fromDatabaseInfo(final DatabaseInfo databaseInfo) {
    final QualifiedName databaseName = databaseInfo.getName();
    final String name = (databaseName == null) ? "" : databaseName.getDatabaseName();
    //this is a temp hack to resolve the uri = null issue
    // final String dbUri = Strings.isNullOrEmpty(databaseInfo.getUri()) ? "file://temp/" : databaseInfo.getUri();
    final Map<String, String> metadata = (databaseInfo.getMetadata() != null) ? databaseInfo.getMetadata()
            : Collections.EMPTY_MAP;
    return new Database(name, name, databaseInfo.getUri(), metadata);
}

From source file:grails.plugins.ooog.OpenObjectErpClass.java

@Override
public Map getAssociationMap() {
    return Collections.EMPTY_MAP;
}

From source file:com.jaspersoft.ji.jaxrs.ps.testservice.TestServiceImpl.java

/**
 *
 * @param domainUri/*from   www . j  a  va 2  s  .  c o  m*/
 * @param locale
 * @return MetaData object, guaranteed to be non-null (not found or not supported resource indicated by exception)
 * @throws ResourceNotFoundException if no resource found at domainUri
 * @throws RemoteException in case of unclassified error
 * @throws LicenseException
 */
public MetaData getTestMetaData(String domainUri, Locale locale) throws RemoteException, LicenseException {
    /* Checking if license is valid and domains feature supported */
    checkLicense();

    LocaleContextHolder.setLocale(locale);

    Resource resource = repository.getResource(null, domainUri);
    if (resource == null) {
        throw new ResourceNotFoundException("Domain not found", domainUri);
    }
    if (!(resource instanceof SemanticLayerDataSource)) {
        throw new IllegalParameterValueException(
                new ErrorDescriptor.Builder().setErrorCode("resource.type.not.supported")
                        .setParameters(new String[] { domainUri }).getErrorDescriptor());
    }

    try {

        SemanticLayerDataSource dataSource = (SemanticLayerDataSource) resource;
        return metaDataFactoryFactory.getMetaData(dataSource, Collections.EMPTY_MAP);

    } catch (Exception ex) {
        throw new RemoteException(
                messages.getMessage(CANNOT_EXTRACT_METADATA, new Object[] { domainUri }, locale), ex);
    }
}

From source file:org.apache.tapestry5.upload.internal.services.MultipartDecoderImplTest.java

@Test
public void process_file_items_set_file_parameters_with_file_name() throws Exception {
    HttpServletRequest request = mockHttpServletRequest();
    expect(request.getParameterMap()).andReturn(Collections.EMPTY_MAP);
    MultipartDecoderImpl decoder = new MultipartDecoderImpl(fileItemFactory, -1, -1, CHARSET);
    List<FileItem> fileItems = Arrays.asList(createFileItem("one", "first.txt"),
            createFileItem("two", "second.txt"));

    replay();//ww  w .  j  a v a2s . co  m

    HttpServletRequest decodedRequest = decoder.processFileItems(request, fileItems);

    assertNotSame(decodedRequest, request);

    assertEquals(decodedRequest.getParameter("one"), "first.txt");
    assertEquals(decodedRequest.getParameter("two"), "second.txt");

    verify();
}

From source file:marshalsec.Jackson.java

@Override
@Args(minArgs = 1, args = { "jndiUrl" }, defaultArgs = { MarshallerBase.defaultJNDIUrl })
public Object makeBeanFactoryPointcutAdvisor(UtilFactory uf, String[] args) throws Exception {
    String jndiUrl = args[0];/*from  ww  w  . jav a  2s .  co m*/
    Map<String, String> values = new LinkedHashMap<>();
    values.put("beanFactory", makeSpringJndiBeanFactory(jndiUrl));
    values.put("adviceBeanName", quoteString(jndiUrl));
    return writeCollection(HashSet.class.getName(),
            writeObject(DefaultBeanFactoryPointcutAdvisor.class, values),
            writeObject(DefaultBeanFactoryPointcutAdvisor.class, Collections.EMPTY_MAP));
}

From source file:de.hybris.platform.cms2.servicelayer.services.CMSRestrictionServiceTest.java

@Before
public void setUp() throws Exception {
    LOG.info("Creating btg test data ..");
    JaloSession.getCurrentSession().setUser(UserManager.getInstance().getAdminEmployee());
    final long startTime = System.currentTimeMillis();
    new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);
    importCsv("/test/cms2TestData.csv", "windows-1252");
    LOG.info("Finished creating btg test data " + (System.currentTimeMillis() - startTime) + "ms");

    userA = userService.getUser(USER_A);
    userB = userService.getUser(USER_B);

    catalog = catalogService.getCatalog(CATALOG_ID);
    categoryA = categoryService.getCategory(CATEGORY_A);
    categoryB = categoryService.getCategory(CATEGORY_B);
    productA = productService.getProduct(PRODUCT_A);
    productB = productService.getProduct(PRODUCT_B);

    mockRestrictionData = createMock(RestrictionData.class);
}

From source file:edu.amc.sakai.user.SimpleLdapAttributeMapper.java

/** 
 * Completes configuration of this instance.
 * //from   ww  w . j a v  a2  s .  c o  m
 * <p>Initializes internal mappings to a copy of 
 * {@link AttributeMappingConstants#DEFAULT_ATTR_MAPPINGS} if 
 * the current map is empty. Initializes user 
 * type mapping strategy to a 
 * {@link EmptyStringUserTypeMapper} if no strategy
 * has been specified.
 * </p>
 * 
 * <p>This defaulting enables UDP config 
 * forward-compatibility.</p>
 * 
 */
public void init() {

    if (M_log.isDebugEnabled()) {
        M_log.debug("init()");
    }

    if (attributeMappings == null || attributeMappings.isEmpty()) {
        if (M_log.isDebugEnabled()) {
            M_log.debug("init(): creating default attribute mappings");
        }
        setAttributeMappings(AttributeMappingConstants.DEFAULT_ATTR_MAPPINGS);
    }

    if (userTypeMapper == null) {
        userTypeMapper = new EmptyStringUserTypeMapper();
        if (M_log.isDebugEnabled()) {
            M_log.debug("init(): created default user type mapper [mapper = " + userTypeMapper + "]");
        }
    }
    if (valueMappings == null) {
        valueMappings = Collections.EMPTY_MAP;
        if (M_log.isDebugEnabled()) {
            M_log.debug("init(): created default value mapper [mapper = " + valueMappings + "]");
        }
    } else {
        // Check we have good value mappings and throw any out that aren't (warning user).
        Iterator<Entry<String, MessageFormat>> iterator = valueMappings.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, MessageFormat> entry = iterator.next();
            if (entry.getValue().getFormats().length != 1) {
                iterator.remove();
                M_log.warn(String.format("Removed value mapping as it didn't have one format: %s -> %s",
                        entry.getKey(), entry.getValue().toPattern()));
            }
        }
    }
}

From source file:org.cloudfoundry.identity.uaa.scim.bootstrap.ScimGroupBootstrap.java

/**
 * Specify the list of groups to create as a comma-separated list of
 * group-names/*from   w ww  .  ja v  a  2  s . c  o m*/
 *
 * @param groups
 */
public void setGroups(Map<String, String> groups) {
    if (groups == null) {
        groups = Collections.EMPTY_MAP;
    }
    groups.entrySet().forEach(e -> {
        if (!StringUtils.hasText(e.getValue())) {
            e.setValue((String) getMessageSource()
                    .getProperty(String.format(messagePropertyNameTemplate, e.getKey())));
        }
    });
    this.configuredGroups = groups;
    setCombinedGroups();
}