All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.ext.cluster.infinispan.InfinispanAsyncMap Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR3
Show newest version
/*
 * Copyright 2021 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.ext.cluster.infinispan;

import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Handler;
import io.vertx.core.shareddata.AsyncMap;
import io.vertx.core.shareddata.impl.SharedDataImpl.WrappedAsyncMap;
import io.vertx.core.streams.ReadStream;

import java.util.Map;

/**
 * Extensions to the generic {@link AsyncMap}.
 *
 * @author Thomas Segismont
 */
@VertxGen
public interface InfinispanAsyncMap {

  /**
   * Unwraps a generic {@link AsyncMap} to an {@link InfinispanAsyncMap}.
   *
   * @throws IllegalArgumentException if underlying implementation is not Infinispan
   */
  @SuppressWarnings("unchecked")
  static  InfinispanAsyncMap unwrap(AsyncMap asyncMap) {
    if (asyncMap instanceof WrappedAsyncMap) {
      WrappedAsyncMap wrappedAsyncMap = (WrappedAsyncMap) asyncMap;
      AsyncMap delegate = wrappedAsyncMap.getDelegate();
      if (delegate instanceof InfinispanAsyncMap) {
        return (InfinispanAsyncMap) delegate;
      }
    }
    throw new IllegalArgumentException(String.valueOf(asyncMap != null ? asyncMap.getClass() : null));
  }

  /**
   * Get the keys of the map as a {@link ReadStream}.
   * 

* The stream will be automatically closed if it fails or ends. * Otherwise you must set a null {@link ReadStream#handler(Handler) data handler} after usage to avoid leaking resources. * * @return a stream of map keys */ ReadStream keyStream(); /** * Get the values of the map as a {@link ReadStream}. *

* The stream will be automatically closed if it fails or ends. * Otherwise you must set a null {@link ReadStream#handler(Handler) data handler} after usage to avoid leaking resources. * * @return a stream of map values */ ReadStream valueStream(); /** * Get the entries of the map as a {@link ReadStream}. *

* The stream will be automatically closed if it fails or ends. * Otherwise you must set a null {@link ReadStream#handler(Handler) data handler} after usage to avoid leaking resources. * * @return a stream of map entries */ @GenIgnore ReadStream> entryStream(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy