List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:org.elasticsearch.xpack.core.ssl.SSLService.java
/** * Creates a new SSLService that supports dynamic creation of SSLContext instances. Instances created by this service will not be * cached and will not be monitored for reloading. This dynamic server does have access to the cached and monitored instances that * have been created during initialization *//* ww w . j av a 2 s . c om*/ public SSLService createDynamicSSLService() { return new SSLService(settings, env, globalSSLConfiguration, sslContexts) { @Override Map<SSLConfiguration, SSLContextHolder> loadSSLConfigurations() { // we don't need to load anything... return Collections.emptyMap(); } /** * Returns the existing {@link SSLContextHolder} for the configuration * @throws IllegalArgumentException if not found */ @Override SSLContextHolder sslContextHolder(SSLConfiguration sslConfiguration) { SSLContextHolder holder = sslContexts.get(sslConfiguration); if (holder == null) { // normally we'd throw here but let's create a new one that is not cached and will not be monitored for changes! holder = createSslContext(sslConfiguration); } return holder; } }; }
From source file:com.xwiki.authentication.Config.java
public Map<String, Collection<String>> getOneToManyParam(String name, char separator, Map<String, Collection<String>> def, boolean left, XWikiContext context) { Map<String, Collection<String>> oneToMany = def; List<String> list = getListParam(name, separator, null, context); if (list != null) { if (list.isEmpty()) { oneToMany = Collections.emptyMap(); } else {//from w ww . j a v a 2 s . c o m oneToMany = new LinkedHashMap<String, Collection<String>>(); for (String mapping : list) { int splitIndex = mapping.indexOf('='); if (splitIndex < 1) { LOG.error("Error parsing [" + name + "] attribute: " + mapping); } else { String leftProperty = left ? mapping.substring(0, splitIndex) : mapping.substring(splitIndex + 1); String rightProperty = left ? mapping.substring(splitIndex + 1) : mapping.substring(0, splitIndex); Collection<String> rightCollection = oneToMany.get(leftProperty); if (rightCollection == null) { rightCollection = new HashSet<String>(); oneToMany.put(leftProperty, rightCollection); } rightCollection.add(rightProperty); if (LOG.isDebugEnabled()) { LOG.debug("[" + name + "] mapping found: " + leftProperty + " " + rightCollection); } } } } } return oneToMany; }
From source file:eu.openanalytics.rsb.config.PersistedConfigurationAdapter.java
@Override public Map<String, Set<URI>> getApplicationSpecificRserviPoolUris() { final Map<String, ?> sourcePoolUris = persistedConfiguration.getApplicationSpecificRserviPoolUris(); if ((sourcePoolUris == null) || (sourcePoolUris.isEmpty())) { return Collections.emptyMap(); }//w ww. ja v a2 s.co m final Map<String, Set<URI>> applicationSpecificRserviPoolUris = new HashMap<String, Set<URI>>(); for (final Entry<String, ?> sourcePoolUri : sourcePoolUris.entrySet()) { if (sourcePoolUri.getValue() instanceof String) { applicationSpecificRserviPoolUris.put(sourcePoolUri.getKey(), Collections.singleton(Util.newURI((String) sourcePoolUri.getValue()))); } else { // assuming array of string, will die otherwise @SuppressWarnings("unchecked") final Collection<String> urisForOneApplication = (Collection<String>) sourcePoolUri.getValue(); final Set<URI> uris = new HashSet<URI>(); for (final String uri : urisForOneApplication) { uris.add(Util.newURI(uri)); } applicationSpecificRserviPoolUris.put(sourcePoolUri.getKey(), Collections.unmodifiableSet(uris)); } } return applicationSpecificRserviPoolUris; }
From source file:eu.europa.ec.fisheries.uvms.reporting.service.bean.impl.AlarmServiceBean.java
private Map<String, Double> getPointCoordinates(List<AlarmMovement> alarmMovements, String movementId) { for (AlarmMovement alarmMovement : alarmMovements) { if (alarmMovement.getMovementId().equalsIgnoreCase(movementId)) { return ImmutableMap.<String, Double>builder() .put(LONGITUDE, Double.valueOf(alarmMovement.getxCoordinate())) .put(LATITUDE, Double.valueOf(alarmMovement.getyCoordinate())).build(); }/*from w ww. j ava 2 s. co m*/ } return Collections.emptyMap(); }
From source file:com.ikanow.aleph2.search_service.elasticsearch.utils.ElasticsearchHiveUtils.java
/** Basic validation of the data warehouse schema * @param schema/*w w w . ja v a2 s.c om*/ * @param bucket * @param security_service * @return */ public static List<String> validateSchema(final DataSchemaBean.DataWarehouseSchemaBean schema, final DataBucketBean bucket, Optional<Client> maybe_client, ElasticsearchIndexServiceConfigBean config, final ISecurityService security_service) { final LinkedList<String> mutable_errs = new LinkedList<>(); if (Optional.ofNullable(schema.enabled()).orElse(true)) { if (null == schema.main_table()) { mutable_errs.add(ErrorUtils.get(ERROR_INVALID_MAIN_TABLE, bucket.full_name())); } else { // Currently: auto schema not supported if (Optional.ofNullable(schema.main_table().table_format()).orElse(Collections.emptyMap()) .isEmpty()) { mutable_errs.add(ErrorUtils.get(ERROR_AUTO_SCHEMA_NOT_YET_SUPPORTED, bucket.full_name(), MAIN_TABLE_NAME)); } else { // check the schema is well formed final Validation<String, String> schema_str = generateFullHiveSchema(Optional.empty(), bucket, schema, maybe_client, config); schema_str.validation( fail -> mutable_errs.add( ErrorUtils.get(ERROR_SCHEMA_ERROR, bucket.full_name(), MAIN_TABLE_NAME, fail)), success -> true); } // Currently: sql query not supported if (Optional.ofNullable(schema.main_table().sql_query()).isPresent()) { mutable_errs.add(ErrorUtils.get(ERROR_SQL_QUERY_NOT_YET_SUPPORTED, bucket.full_name())); } // Can't specify view name for main table if (Optional.ofNullable(schema.main_table().view_name()).isPresent()) { mutable_errs .add(ErrorUtils.get(ERROR_INVALID_MAIN_TABLE_FIELD, bucket.full_name(), "view_name")); } } // Currently: no views allowed if (!Optionals.ofNullable(schema.views()).isEmpty()) { mutable_errs.add(ErrorUtils.get(ERROR_NO_VIEWS_ALLOWED_YET, bucket.full_name())); } //TODO (ALEPH-17): need permission to specify table name (wait for security service API to calm down) } return mutable_errs; }
From source file:Main.java
/** * Copies the given {@link Map} into a new {@link Map}.<br> * // w w w . ja v a 2 s .c o m * @param <A> * the type of the keys of the map * @param <B> * the type of the values of the map * @param data * the given map * @return If the given map was empty, a {@link Collections#emptyMap()} is * returned<br> * If the given map contained only one entry, a * {@link Collections#singletonMap(Object, Object)}, containing * said entry, is returned <br> * If the given map contained more than one element, a * {@link Collections#unmodifiableMap(Map)}, containing the entries * of the given map, is returned. */ public static <A, B> Map<A, B> copy(Map<A, B> data) { final int size = data.size(); switch (size) { case 0: return Collections.emptyMap(); case 1: final A key = data.keySet().iterator().next(); return Collections.singletonMap(key, data.get(key)); default: return Collections.unmodifiableMap(new HashMap<A, B>(data)); } }
From source file:com.netflix.imfutility.cpl._2016.Cpl2016ContextBuilderStrategy.java
@Override public Map<String, List<Object>> getEssenceDescriptors() { if (cpl2016.getEssenceDescriptorList() == null) { return Collections.emptyMap(); }/* w ww. j ava2s . c om*/ Map<String, List<Object>> result = new HashMap<>(); for (EssenceDescriptorBaseType essenceDescriptorBase : cpl2016.getEssenceDescriptorList() .getEssenceDescriptor()) { result.put(essenceDescriptorBase.getId(), essenceDescriptorBase.getAny()); } return result; }
From source file:no.ssb.jsonstat.v2.deser.DatasetDeserializer.java
@Override public DatasetBuildable deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (p.getCurrentToken() == JsonToken.START_OBJECT) { p.nextToken();//from w ww.j ava 2 s . c o m } Set<String> ids = Collections.emptySet(); List<Integer> sizes = Collections.emptyList(); Multimap<String, String> roles = ArrayListMultimap.create(); Map<String, Dimension.Builder> dims = Collections.emptyMap(); List<Number> values = Collections.emptyList(); DatasetBuilder builder = Dataset.create(); Optional<String> version = Optional.empty(); Optional<String> clazz = Optional.empty(); Optional<ObjectNode> extension = Optional.empty(); while (p.nextValue() != JsonToken.END_OBJECT) { switch (p.getCurrentName()) { case "label": builder.withLabel(_parseString(p, ctxt)); break; case "source": builder.withSource(_parseString(p, ctxt)); break; case "href": break; case "updated": Instant updated = parseEcmaDate(_parseString(p, ctxt)); builder.updatedAt(updated); break; case "value": values = parseValues(p, ctxt); break; case "dimension": if (!version.orElse("1.x").equals("2.0")) { dims = Maps.newHashMap(); // Deal with the id, size and role inside dimension. while (p.nextValue() != JsonToken.END_OBJECT) { switch (p.getCurrentName()) { case "id": ids = p.readValueAs(ID_SET); break; case "size": sizes = p.readValueAs(SIZE_LIST); break; case "role": roles = p.readValueAs(ROLE_MULTIMAP); break; default: dims.put(p.getCurrentName(), ctxt.readValue(p, Dimension.Builder.class)); } } } else { dims = p.readValueAs(DIMENSION_MAP); } break; case "id": ids = p.readValueAs(ID_SET); break; case "size": sizes = p.readValueAs(SIZE_LIST); break; case "role": roles = p.readValueAs(ROLE_MULTIMAP); break; case "extension": extension = Optional.of(ctxt.readValue(p, ObjectNode.class)); break; case "link": case "status": // TODO p.skipChildren(); break; case "version": version = Optional.of(_parseString(p, ctxt)); break; case "class": // TODO clazz = Optional.of(_parseString(p, ctxt)); break; default: boolean handled = ctxt.handleUnknownProperty(p, this, Dimension.Builder.class, p.getCurrentName()); if (!handled) p.skipChildren(); break; } } // Setup roles for (Map.Entry<String, String> dimRole : roles.entries()) { Dimension.Roles role = Dimension.Roles.valueOf(dimRole.getKey().toUpperCase()); Dimension.Builder dimension = checkNotNull(dims.get(dimRole.getValue()), "could not assign the role {} to the dimension {}. The dimension did not exist", role, dimRole.getValue() ); dimension.withRole(role); } List<Dimension.Builder> orderedDimensions = Lists.newArrayList(); for (String dimensionName : ids) { orderedDimensions.add(dims.get(dimensionName)); } // TODO: Check size? // Check ids and add to the data set. checkArgument(ids.size() == dims.size(), "dimension and size did not match"); if (extension.isPresent()) { builder.withExtension(extension.get()); } return builder.withDimensions(orderedDimensions).withValues(values); }
From source file:com.netflix.imfutility.cpl._2013.Cpl2013ContextBuilderStrategy.java
@Override public Map<String, List<Object>> getEssenceDescriptors() { if (cpl2013.getEssenceDescriptorList() == null) { return Collections.emptyMap(); }/*from w w w . ja v a 2 s . com*/ Map<String, List<Object>> result = new HashMap<>(); for (EssenceDescriptorBaseType essenceDescriptorBase : cpl2013.getEssenceDescriptorList() .getEssenceDescriptor()) { result.put(essenceDescriptorBase.getId(), essenceDescriptorBase.getAny()); } return result; }
From source file:com.hortonworks.streamline.streams.common.StreamlineEventImplTest.java
@Test(expected = UnsupportedOperationException.class) public void testRemove() throws Exception { Map<String, Object> map = new HashMap<>(); map.put("foo", "bar"); StreamlineEvent event = new StreamlineEventImpl(Collections.emptyMap(), StringUtils.EMPTY); event.remove("foo"); }