List of usage examples for java.util Collections EMPTY_MAP
Map EMPTY_MAP
To view the source code for java.util Collections EMPTY_MAP.
Click Source Link
From source file:com.pscnlab.train.services.impls.TrainPeopleServiceImpl.java
@Override public Map<Integer, List<TrainPeople>> findMapByTrainIds(List<Integer> es) { List<TrainPeople> trainPeoples = this.findListByTrainIds(es); if (CollectionUtils.isEmpty(trainPeoples)) { return Collections.EMPTY_MAP; }/* ww w.j ava 2 s . c om*/ return trainPeoples.stream().collect(Collectors.groupingBy(TrainPeople::getUuidTrain)); }
From source file:net.mlw.vlh.adapter.hibernate3.util.StatementBuilder.java
/** * Usage of filters: {key} -> :keyName add to query's parameter map keyValue * [key] -> keyValue// w w w . j a v a 2 s . c o m * * @param hql * @param whereClause * @return Query for ordinary list * @throws HibernateException * @throws ParseException */ public Query generate(Session session, StringBuffer hql, Map whereClause, boolean isRemoveEmptyStrings) throws HibernateException, ParseException { if (whereClause == null) { whereClause = Collections.EMPTY_MAP; } Map arguments = new HashMap(); // Include or exclude the filters. for (int i = 0, end = 0, start; ((start = hql.toString().indexOf("/~", end)) >= 0); i++) { end = hql.toString().indexOf("~/", start); String key = hql.substring(start + 2, hql.indexOf(":", start)); Object value = whereClause.get(key); if (isValuePopulated(value, isRemoveEmptyStrings)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("The filter key=[" + key + "] with the value=[" + value + "] is accepted by the hql preprocesor"); } hql.replace(start, end + 2, hql.substring(hql.indexOf(":", start) + 1, end)); } else { if (LOGGER.isInfoEnabled()) { LOGGER.info("The filter key=[" + key + "] is removed from the query by the hql preprocesor."); } hql.replace(start, end + 2, ""); } end -= start; } // Replace any [key] with the value in the whereClause Map. for (int i = 0, end = 0, start; ((start = hql.toString().indexOf('[', end)) >= 0); i++) { end = hql.toString().indexOf(']', start); String key = hql.substring(start + 1, end); Object value = whereClause.get(key); hql.replace(start, end + 1, (value == null) ? "" : value.toString()); end -= (key.length() + 2); } // 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 = hql.toString().indexOf('{', end)) >= 0); i++) { end = hql.toString().indexOf('}', start); String key = hql.substring(start + 1, end); Object value = whereClause.get(key); if (value == null) { throw new NullPointerException("Property '" + key + "' was not provided."); } arguments.put(key, value); hql.replace(start, end + 1, ":" + key); end -= (key.length() + 2); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("The final query is " + hql); } Query query = session.createQuery(hql.toString()); // Now set all the patameters on the statement. if (setters == null) { for (Iterator keys = arguments.keySet().iterator(); keys.hasNext();) { String key = (String) keys.next(); Object value = arguments.get(key); if (value instanceof List) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Setting a paremeterList to the query."); } query.setParameterList(key, ((List) value).toArray()); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug( "Using the default setter for key=[" + key + "] with the value=[" + value + "]"); } getDefaultSetter().set(query, key, value); } } } else { for (Iterator keys = arguments.keySet().iterator(); keys.hasNext();) { String key = (String) keys.next(); Object value = arguments.get(key); getSetter(key).set(query, key, value); } } return query; }
From source file:com.impetus.kundera.persistence.EntityManagerFactoryBuilder.java
/** * Builds up EntityManagerFactory for a given persistenceUnitName and * overriding properties./*w w w. j av a 2 s. c om*/ * * @param persistenceUnitName * the persistence unit name * @param override * the override * @return the entity manager factory */ public EntityManagerFactory buildEntityManagerFactory(String persistenceUnitName, Map<Object, Object> override) { Properties props = new Properties(); // Override properties KunderaMetadata kunderaMetadata = KunderaMetadata.INSTANCE; PersistenceUnitMetadata puMetadata = kunderaMetadata.getApplicationMetadata() .getPersistenceUnitMetadata(persistenceUnitName); Properties metadataProperties = puMetadata.getProperties(); // 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: " + puMetadata.getPersistenceUnitName() + ", and Properties:" + props); return new EntityManagerFactoryImpl(puMetadata, props); }
From source file:org.apache.beam.sdk.io.elasticsearch.ElasticSearchIOTestUtils.java
/** * Synchronously deletes the target if it exists and then (re)creates it as a copy of source * synchronously./*w w w. jav a 2 s . com*/ */ static void copyIndex(RestClient restClient, String source, String target) throws IOException { deleteIndex(restClient, target); HttpEntity entity = new NStringEntity( String.format("{\"source\" : { \"index\" : \"%s\" }, \"dest\" : { \"index\" : \"%s\" } }", source, target), ContentType.APPLICATION_JSON); restClient.performRequest("POST", "/_reindex", Collections.EMPTY_MAP, entity); }
From source file:org.geoserver.kml.KMLTest.java
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); Catalog catalog = getCatalog();/*from w w w . j av a 2s . c o m*/ testData.addStyle("notthere", "notthere.sld", getClass(), catalog); testData.addStyle("scaleRange", "scaleRange.sld", getClass(), catalog); testData.addVectorLayer(STORM_OBS, Collections.EMPTY_MAP, "storm_obs.properties", getClass(), catalog); }
From source file:io.fabric8.spring.cloud.discovery.KubernetesServiceInstance.java
public Map<String, String> getMetadata() { return Collections.EMPTY_MAP; }
From source file:org.jhk.pulsing.search.elasticsearch.client.ESRestClient.java
public Optional<String> getDocument(String index, String type, String id) { String endpoint = new StringJoiner("/").add(index).add(type).add(id).toString(); try {/*ww w .ja va 2s .c o m*/ Optional<Response> response = performRequest("GET", endpoint, Collections.EMPTY_MAP, null, EMPTY_HEADER); if (response.isPresent()) { HttpEntity hEntity = response.get().getEntity(); String result = EntityUtils.toString(hEntity); _LOGGER.debug("ESRestClient.getDocument: result - " + result); return Optional.of(result); } } catch (IOException iException) { iException.printStackTrace(); } return Optional.empty(); }
From source file:org.jasig.services.persondir.support.xml.XmlPersonAttributeDaoTest.java
public void testQueryByUsername() { final IPersonAttributes boringPerson = this.xmlPersonAttributeDao.getPerson("iboring"); assertNotNull(boringPerson);/*from w ww. j a v a2s . c o m*/ assertEquals("iboring", boringPerson.getName()); assertEquals(Collections.EMPTY_MAP, boringPerson.getAttributes()); final IPersonAttributes mstaffPerson = this.xmlPersonAttributeDao.getPerson("mstaff"); assertNotNull(mstaffPerson); assertEquals("mstaff", mstaffPerson.getName()); final Map<String, List<String>> mstaffAttributes = new LinkedHashMap<String, List<String>>(); mstaffAttributes.put("givenName", Arrays.asList("Mary")); mstaffAttributes.put("familyName", Arrays.asList("Staff")); mstaffAttributes.put("email", Arrays.asList("mstaff@example.edu")); mstaffAttributes.put("emplid", Arrays.asList("963852741")); mstaffAttributes.put("portalId", Arrays.asList("!@#$%^*()_+")); assertEquals(mstaffAttributes, mstaffPerson.getAttributes()); final IPersonAttributes nullPerson = this.xmlPersonAttributeDao.getPerson("doesntexist"); assertNull(nullPerson); }
From source file:org.apereo.services.persondir.support.xml.XmlPersonAttributeDaoTest.java
public void testQueryByUsername() { final IPersonAttributes boringPerson = this.xmlPersonAttributeDao.getPerson("iboring"); assertNotNull(boringPerson);//from ww w .ja v a 2 s .co m assertEquals("iboring", boringPerson.getName()); assertEquals(Collections.EMPTY_MAP, boringPerson.getAttributes()); final IPersonAttributes mstaffPerson = this.xmlPersonAttributeDao.getPerson("mstaff"); assertNotNull(mstaffPerson); assertEquals("mstaff", mstaffPerson.getName()); final Map<String, List<String>> mstaffAttributes = new LinkedHashMap<>(); mstaffAttributes.put("givenName", Arrays.asList("Mary")); mstaffAttributes.put("familyName", Arrays.asList("Staff")); mstaffAttributes.put("email", Arrays.asList("mstaff@example.edu")); mstaffAttributes.put("emplid", Arrays.asList("963852741")); mstaffAttributes.put("portalId", Arrays.asList("!@#$%^*()_+")); assertEquals(mstaffAttributes, mstaffPerson.getAttributes()); final IPersonAttributes nullPerson = this.xmlPersonAttributeDao.getPerson("doesntexist"); assertNull(nullPerson); }
From source file:org.fishwife.jrugged.spring.retry.ClassifierSimpleRetryPolicy.java
/*** * Constructor./*from w ww. ja va 2 s .c o m*/ * * @param maxAttempts The maximum number of attempts allowed * @param classifier The classifier used to determine if an exception should trigger a retry */ public ClassifierSimpleRetryPolicy(int maxAttempts, Classifier<Throwable, Boolean> classifier) { super(maxAttempts, Collections.EMPTY_MAP); this.classifier = classifier; }