List of usage examples for java.util Collections singletonMap
public static <K, V> Map<K, V> singletonMap(K key, V value)
From source file:com.dianping.resource.io.util.MimeType.java
/** * Create a new {@code MimeType} for the given type, subtype, and character set. * @param type the primary type//w w w . j a va 2s . c o m * @param subtype the subtype * @param charSet the character set * @throws IllegalArgumentException if any of the parameters contain illegal characters */ public MimeType(String type, String subtype, Charset charSet) { this(type, subtype, Collections.singletonMap(PARAM_CHARSET, charSet.name())); }
From source file:com.haulmont.cuba.web.gui.components.WebSearchField.java
protected void executeSearch(final String newFilter) { if (optionsDatasource == null) return;/*from w ww.j av a 2s .c o m*/ String filterForDs = newFilter; if (mode == Mode.LOWER_CASE) { filterForDs = StringUtils.lowerCase(newFilter); } else if (mode == Mode.UPPER_CASE) { filterForDs = StringUtils.upperCase(newFilter); } if (escapeValueForLike && StringUtils.isNotEmpty(filterForDs)) { filterForDs = QueryUtils.escapeForLike(filterForDs); } if (!isRequired() && StringUtils.isEmpty(filterForDs)) { setValue(null); if (optionsDatasource.getState() == State.VALID) { optionsDatasource.clear(); } return; } if (StringUtils.length(filterForDs) >= minSearchStringLength) { optionsDatasource.refresh(Collections.singletonMap(SEARCH_STRING_PARAM, filterForDs)); if (optionsDatasource.getState() == State.VALID) { if (optionsDatasource.size() == 0) { if (searchNotifications != null) { searchNotifications.notFoundSuggestions(newFilter); } } else if (optionsDatasource.size() == 1) { setValue(optionsDatasource.getItems().iterator().next()); } } } else { if (optionsDatasource.getState() == State.VALID) { optionsDatasource.clear(); } if (searchNotifications != null && StringUtils.length(newFilter) > 0) { searchNotifications.needMinSearchStringLength(newFilter, minSearchStringLength); } } }
From source file:edu.arizona.kra.kim.impl.identity.PersonServiceImpl.java
@Override public Person getPersonByEmployeeId(String employeeId) { if (StringUtils.isBlank(employeeId)) { return null; }//from w w w .j a v a 2s . c o m final List<Person> people = findPeople( Collections.singletonMap(KIMPropertyConstants.Person.EMPLOYEE_ID, employeeId)); if (!people.isEmpty()) { return people.get(0); } // If no person was found above, check for inactive records EntityDefault entity = getIdentityService().getEntityDefaultByEmployeeId(employeeId); if (entity != null) { if (!entity.getPrincipals().isEmpty()) { Principal principal = getIdentityService() .getPrincipal(entity.getPrincipals().get(0).getPrincipalId()); if (principal != null) { return convertEntityToPerson(entity, principal); } } } return null; }
From source file:org.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java
@Test public void testLoadResourceWithDefaultMatch() throws Exception { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setMatchDefault(true);//from ww w. j a v a 2 s .c om factory.setResources(new Resource[] { new ByteArrayResource("one: two\n---\nfoo: bar\nspam: baz\n---\nfoo: bag\nspam: bad".getBytes()) }); factory.setDocumentMatchers(Collections.singletonMap("foo", "bag")); Properties properties = factory.getObject(); assertEquals("bag", properties.get("foo")); assertEquals("bad", properties.get("spam")); assertEquals("two", properties.get("one")); }
From source file:ru.mystamps.web.dao.impl.JdbcCategoryDao.java
@Override public long countByNameRu(String name) { return jdbcTemplate.queryForObject(countByNameRuSql, Collections.singletonMap("name", name), Long.class); }
From source file:org.cloudfoundry.identity.uaa.oauth.token.UaaTokenServicesTests.java
public UaaTokenServicesTests() { clientDetailsService.setClientDetailsStore( Collections.singletonMap("client", new BaseClientDetails("client", "scim, clients", "read, write", "authorization_code, password, implicit, client_credentials", "update"))); tokenServices.setClientDetailsService(clientDetailsService); tokenServices.setDefaultUserAuthorities(AuthorityUtils.authorityListToSet(UaaAuthority.USER_AUTHORITIES)); tokenServices.setIssuer("http://localhost:8080/uaa"); tokenServices.setSignerProvider(signerProvider); tokenServices.setUserDatabase(userDatabase); tokenServices.setApprovalStore(approvalStore); }
From source file:eu.roschi.obdkinesis.webserver.GetCountsServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { MultiMap<String> params = new MultiMap<>(); UrlEncoded.decodeTo(req.getQueryString(), params, "UTF-8"); // We need both parameters to properly query for counts if (!params.containsKey(PARAMETER_RESOURCE) || !params.containsKey(PARAMETER_RANGE_IN_SECONDS)) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); return;//from w w w . ja v a 2 s. c o m } // Parse query string as a single integer - the number of seconds since "now" to query for new counts String resource = params.getString(PARAMETER_RESOURCE); int rangeInSeconds = Integer.parseInt(params.getString(PARAMETER_RANGE_IN_SECONDS)); Calendar c = Calendar.getInstance(); c.add(Calendar.SECOND, -1 * rangeInSeconds); Date startTime = c.getTime(); //if (LOG.isDebugEnabled()) { LOG.debug(String.format("Querying for counts of resource %s since %s", resource, DATE_FORMATTER.get().format(startTime))); //} DynamoDBQueryExpression<HttpReferrerPairsCount> query = new DynamoDBQueryExpression<>(); HttpReferrerPairsCount hashKey = new HttpReferrerPairsCount(); hashKey.setResource(resource); query.setHashKeyValues(hashKey); Condition recentUpdates = new Condition().withComparisonOperator(ComparisonOperator.GT) .withAttributeValueList(new AttributeValue().withS(DATE_FORMATTER.get().format(startTime))); query.setRangeKeyConditions(Collections.singletonMap("timestamp", recentUpdates)); List<HttpReferrerPairsCount> counts = mapper.query(HttpReferrerPairsCount.class, query); // Return the counts as JSON resp.setContentType("application/json"); resp.setStatus(HttpServletResponse.SC_OK); JSON.writeValue(resp.getWriter(), counts); }
From source file:org.zenoss.zep.dao.impl.HeartbeatDaoImpl.java
@Override @TransactionalRollbackAllExceptions//from w w w . j a v a 2 s. c o m public int deleteByMonitor(String monitor) throws ZepException { final Map<String, String> fields = Collections.singletonMap(COLUMN_MONITOR, monitor); final String sql = "DELETE FROM daemon_heartbeat WHERE monitor=:monitor"; return this.template.update(sql, fields); }
From source file:com.alertlogic.aws.kinesis.test1.webserver.GetCountsServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { MultiMap<String> params = new MultiMap<>(); UrlEncoded.decodeTo(req.getQueryString(), params, "UTF-8"); // We need both parameters to properly query for counts if (!params.containsKey(PARAMETER_RESOURCE) || !params.containsKey(PARAMETER_RANGE_IN_SECONDS)) { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); return;//from w w w. ja v a2 s.co m } // Parse query string as a single integer - the number of seconds since "now" to query for new counts String resource = params.getString(PARAMETER_RESOURCE); int rangeInSeconds = Integer.parseInt(params.getString(PARAMETER_RANGE_IN_SECONDS)); Calendar c = Calendar.getInstance(); c.add(Calendar.SECOND, -1 * rangeInSeconds); Date startTime = c.getTime(); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Querying for counts of resource %s since %s", resource, DATE_FORMATTER.get().format(startTime))); } DynamoDBQueryExpression<HttpReferrerPairsCount> query = new DynamoDBQueryExpression<>(); HttpReferrerPairsCount hashKey = new HttpReferrerPairsCount(); hashKey.setResource(resource); query.setHashKeyValues(hashKey); Condition recentUpdates = new Condition().withComparisonOperator(ComparisonOperator.GT) .withAttributeValueList(new AttributeValue().withS(DATE_FORMATTER.get().format(startTime))); query.setRangeKeyConditions(Collections.singletonMap("timestamp", recentUpdates)); List<HttpReferrerPairsCount> counts = mapper.query(HttpReferrerPairsCount.class, query); // Return the counts as JSON resp.setContentType("application/json"); resp.setStatus(HttpServletResponse.SC_OK); JSON.writeValue(resp.getWriter(), counts); }
From source file:de.tud.inf.db.sparqlytics.bench.LDBCBenchmark.java
@Test public void testQ08() throws Exception { test("08", Collections.singletonMap("tag", "http://dbpedia.org/resource/Germany")); }