CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-vertx--vertx-core

Vert.x Core is a high-performance, reactive application toolkit for the JVM providing fundamental building blocks for asynchronous I/O operations.

Pending
Overview
Eval results
Files

utilities.mddocs/

Utilities

JSON processing, buffer operations, reactive streams, shared data, CLI support, datagram/DNS operations, and other utility functionality.

Capabilities

JSON Processing

High-performance JSON object and array handling with comprehensive encoding/decoding support.

/**
 * JSON object representation with fluent API
 */
class JsonObject implements Iterable<Map.Entry<String,Object>>, ClusterSerializable, Shareable {
  /**
   * Create empty JSON object
   */
  JsonObject();

  /**
   * Create JSON object from string
   * @param json JSON string to parse
   */
  JsonObject(String json);

  /**
   * Put value in JSON object
   * @param key Property key
   * @param value Property value
   * @return this for chaining
   */
  JsonObject put(String key, Object value);

  /**
   * Get value from JSON object
   * @param key Property key
   * @return Property value
   */
  <T> T getValue(String key);

  /**
   * Get string value
   * @param key Property key
   * @return String value
   */
  String getString(String key);

  /**
   * Get string value with default
   * @param key Property key
   * @param def Default value
   * @return String value or default
   */
  String getString(String key, String def);

  /**
   * Get integer value
   * @param key Property key
   * @return Integer value
   */
  Integer getInteger(String key);

  /**
   * Get integer value with default
   * @param key Property key
   * @param def Default value
   * @return Integer value or default
   */
  Integer getInteger(String key, Integer def);

  /**
   * Get long value
   * @param key Property key
   * @return Long value
   */
  Long getLong(String key);

  /**
   * Get double value
   * @param key Property key
   * @return Double value
   */
  Double getDouble(String key);

  /**
   * Get float value
   * @param key Property key
   * @return Float value
   */
  Float getFloat(String key);

  /**
   * Get boolean value
   * @param key Property key
   * @return Boolean value
   */
  Boolean getBoolean(String key);

  /**
   * Get JSON object value
   * @param key Property key
   * @return JsonObject value
   */
  JsonObject getJsonObject(String key);

  /**
   * Get JSON array value
   * @param key Property key
   * @return JsonArray value
   */
  JsonArray getJsonArray(String key);

  /**
   * Get binary value
   * @param key Property key
   * @return byte array
   */
  byte[] getBinary(String key);

  /**
   * Get instant value
   * @param key Property key
   * @return Instant value
   */
  Instant getInstant(String key);

  /**
   * Check if key exists
   * @param key Property key
   * @return true if key exists
   */
  boolean containsKey(String key);

  /**
   * Get all field names
   * @return Set of field names
   */
  Set<String> fieldNames();

  /**
   * Get number of fields
   * @return Field count
   */
  int size();

  /**
   * Clear all fields
   * @return this for chaining
   */
  JsonObject clear();

  /**
   * Check if empty
   * @return true if empty
   */
  boolean isEmpty();

  /**
   * Remove field
   * @param key Field key to remove
   * @return Removed value
   */
  Object remove(String key);

  /**
   * Copy JSON object
   * @return Deep copy
   */
  JsonObject copy();

  /**
   * Merge another JSON object into this one
   * @param other JSON object to merge
   * @return this for chaining
   */
  JsonObject mergeIn(JsonObject other);

  /**
   * Encode to JSON string
   * @return JSON string
   */
  String encode();

  /**
   * Encode to pretty JSON string
   * @return Pretty JSON string
   */
  String encodePrettily();

  /**
   * Convert to Map
   * @return Map representation
   */
  Map<String, Object> getMap();

  /**
   * Create JsonObject from Map
   * @param map Source map
   * @return JsonObject
   */
  static JsonObject mapFrom(Object map);

  /**
   * Map to POJO
   * @param type Target class
   * @return POJO instance
   */
  <T> T mapTo(Class<T> type);
}

/**
 * JSON array representation with fluent API
 */
class JsonArray implements Iterable<Object>, ClusterSerializable, Shareable {
  /**
   * Create empty JSON array
   */
  JsonArray();

  /**
   * Create JSON array from string
   * @param json JSON string to parse
   */
  JsonArray(String json);

  /**
   * Add value to array
   * @param value Value to add
   * @return this for chaining
   */
  JsonArray add(Object value);

  /**
   * Add null to array
   * @return this for chaining
   */
  JsonArray addNull();

  /**
   * Get value at index
   * @param index Array index
   * @return Value at index
   */
  <T> T getValue(int index);

  /**
   * Get string at index
   * @param index Array index
   * @return String value
   */
  String getString(int index);

  /**
   * Get integer at index
   * @param index Array index
   * @return Integer value
   */
  Integer getInteger(int index);

  /**
   * Get long at index
   * @param index Array index
   * @return Long value
   */
  Long getLong(int index);

  /**
   * Get double at index
   * @param index Array index
   * @return Double value
   */
  Double getDouble(int index);

  /**
   * Get float at index
   * @param index Array index
   * @return Float value
   */
  Float getFloat(int index);

  /**
   * Get boolean at index
   * @param index Array index
   * @return Boolean value
   */
  Boolean getBoolean(int index);

  /**
   * Get JSON object at index
   * @param index Array index
   * @return JsonObject value
   */
  JsonObject getJsonObject(int index);

  /**
   * Get JSON array at index
   * @param index Array index
   * @return JsonArray value
   */
  JsonArray getJsonArray(int index);

  /**
   * Get binary at index
   * @param index Array index
   * @return byte array
   */
  byte[] getBinary(int index);

  /**
   * Get instant at index
   * @param index Array index
   * @return Instant value
   */
  Instant getInstant(int index);

  /**
   * Check if contains null at index
   * @param index Array index
   * @return true if null
   */
  boolean hasNull(int index);

  /**
   * Check if contains value
   * @param value Value to check
   * @return true if contains
   */
  boolean contains(Object value);

  /**
   * Remove value at index
   * @param index Array index
   * @return Removed value
   */
  Object remove(int index);

  /**
   * Remove value
   * @param value Value to remove
   * @return true if removed
   */
  boolean remove(Object value);

  /**
   * Get array size
   * @return Array size
   */
  int size();

  /**
   * Clear array
   * @return this for chaining
   */
  JsonArray clear();

  /**
   * Check if empty
   * @return true if empty
   */
  boolean isEmpty();

  /**
   * Copy array
   * @return Deep copy
   */
  JsonArray copy();

  /**
   * Encode to JSON string
   * @return JSON string
   */
  String encode();

  /**
   * Encode to pretty JSON string
   * @return Pretty JSON string
   */
  String encodePrettily();

  /**
   * Get as List
   * @return List representation
   */
  List<Object> getList();

  /**
   * Get stream of elements
   * @return Stream of elements
   */
  Stream<Object> stream();
}

/**
 * Static JSON utilities
 */
class Json {
  /**
   * Encode object to JSON string
   * @param obj Object to encode
   * @return JSON string
   */
  static String encode(Object obj);

  /**
   * Encode object to pretty JSON string
   * @param obj Object to encode
   * @return Pretty JSON string
   */
  static String encodePrettily(Object obj);

  /**
   * Decode JSON string to object
   * @param str JSON string
   * @return Decoded object
   */
  static Object decodeValue(String str);

  /**
   * Decode JSON string to specific type
   * @param str JSON string
   * @param clazz Target class
   * @return Decoded object
   */
  static <T> T decodeValue(String str, Class<T> clazz);

  /**
   * Get Jackson ObjectMapper
   * @return ObjectMapper instance
   */
  static ObjectMapper mapper;

  /**
   * Get pretty Jackson ObjectMapper
   * @return Pretty ObjectMapper instance
   */
  static ObjectMapper prettyMapper;
}

Buffer Operations

Mutable byte buffer operations with support for various data types and JSON conversion.

/**
 * Mutable byte buffer with fluent API
 */
interface Buffer extends ClusterSerializable, Shareable {
  /**
   * Create empty buffer
   * @return Empty buffer
   */
  static Buffer buffer();

  /**
   * Create buffer with initial capacity
   * @param initialSizeHint Initial size hint
   * @return Buffer with capacity
   */
  static Buffer buffer(int initialSizeHint);

  /**
   * Create buffer from string
   * @param string Source string
   * @return Buffer with string data
   */
  static Buffer buffer(String string);

  /**
   * Create buffer from string with encoding
   * @param string Source string
   * @param enc Character encoding
   * @return Buffer with encoded string data
   */
  static Buffer buffer(String string, String enc);

  /**
   * Create buffer from byte array
   * @param bytes Source byte array
   * @return Buffer with byte data
   */
  static Buffer buffer(byte[] bytes);

  /**
   * Append buffer
   * @param buff Buffer to append
   * @return this for chaining
   */
  Buffer appendBuffer(Buffer buff);

  /**
   * Append buffer with offset and length
   * @param buff Buffer to append
   * @param offset Offset in source buffer
   * @param len Length to append
   * @return this for chaining
   */
  Buffer appendBuffer(Buffer buff, int offset, int len);

  /**
   * Append byte array
   * @param bytes Bytes to append
   * @return this for chaining
   */
  Buffer appendBytes(byte[] bytes);

  /**
   * Append byte array with offset and length
   * @param bytes Bytes to append
   * @param offset Offset in array
   * @param len Length to append
   * @return this for chaining
   */
  Buffer appendBytes(byte[] bytes, int offset, int len);

  /**
   * Append single byte
   * @param b Byte to append
   * @return this for chaining
   */
  Buffer appendByte(byte b);

  /**
   * Append int as 4 bytes
   * @param i Int value
   * @return this for chaining
   */
  Buffer appendInt(int i);

  /**
   * Append int as 4 bytes with endianness
   * @param i Int value
   * @param endianness Byte order
   * @return this for chaining
   */
  Buffer appendIntLE(int i);

  /**
   * Append long as 8 bytes
   * @param l Long value
   * @return this for chaining
   */
  Buffer appendLong(long l);

  /**
   * Append long as 8 bytes with endianness
   * @param l Long value
   * @return this for chaining
   */
  Buffer appendLongLE(long l);

  /**
   * Append short as 2 bytes
   * @param s Short value
   * @return this for chaining
   */
  Buffer appendShort(short s);

  /**
   * Append short as 2 bytes with endianness
   * @param s Short value
   * @return this for chaining
   */
  Buffer appendShortLE(short s);

  /**
   * Append float as 4 bytes
   * @param f Float value
   * @return this for chaining
   */
  Buffer appendFloat(float f);

  /**
   * Append double as 8 bytes
   * @param d Double value
   * @return this for chaining
   */
  Buffer appendDouble(double d);

  /**
   * Append string
   * @param str String to append
   * @return this for chaining
   */
  Buffer appendString(String str);

  /**
   * Append string with encoding
   * @param str String to append
   * @param enc Character encoding
   * @return this for chaining
   */
  Buffer appendString(String str, String enc);

  /**
   * Get byte at position
   * @param pos Buffer position
   * @return Byte value
   */
  byte getByte(int pos);

  /**
   * Get bytes from position
   * @param start Start position
   * @param end End position
   * @return Byte array
   */
  byte[] getBytes(int start, int end);

  /**
   * Get int from position
   * @param pos Buffer position
   * @return Int value
   */
  int getInt(int pos);

  /**
   * Get int with endianness
   * @param pos Buffer position
   * @return Int value
   */
  int getIntLE(int pos);

  /**
   * Get long from position
   * @param pos Buffer position
   * @return Long value
   */
  long getLong(int pos);

  /**
   * Get long with endianness
   * @param pos Buffer position
   * @return Long value
   */
  long getLongLE(int pos);

  /**
   * Get short from position
   * @param pos Buffer position
   * @return Short value
   */
  short getShort(int pos);

  /**
   * Get short with endianness
   * @param pos Buffer position
   * @return Short value
   */
  short getShortLE(int pos);

  /**
   * Get float from position
   * @param pos Buffer position
   * @return Float value
   */
  float getFloat(int pos);

  /**
   * Get double from position
   * @param pos Buffer position
   * @return Double value
   */
  double getDouble(int pos);

  /**
   * Get string from position range
   * @param start Start position
   * @param end End position
   * @return String value
   */
  String getString(int start, int end);

  /**
   * Get string with encoding
   * @param start Start position
   * @param end End position
   * @param enc Character encoding
   * @return String value
   */
  String getString(int start, int end, String enc);

  /**
   * Set byte at position
   * @param pos Buffer position
   * @param b Byte value
   * @return this for chaining
   */
  Buffer setByte(int pos, byte b);

  /**
   * Set bytes at position
   * @param pos Buffer position
   * @param bytes Byte array
   * @return this for chaining
   */
  Buffer setBytes(int pos, byte[] bytes);

  /**
   * Set bytes with offset and length
   * @param pos Buffer position
   * @param bytes Byte array
   * @param offset Offset in array
   * @param len Length to set
   * @return this for chaining
   */
  Buffer setBytes(int pos, byte[] bytes, int offset, int len);

  /**
   * Set buffer at position
   * @param pos Buffer position
   * @param buff Buffer to set
   * @return this for chaining
   */
  Buffer setBuffer(int pos, Buffer buff);

  /**
   * Set buffer with offset and length
   * @param pos Buffer position
   * @param buff Buffer to set
   * @param offset Offset in source buffer
   * @param len Length to set
   * @return this for chaining
   */
  Buffer setBuffer(int pos, Buffer buff, int offset, int len);

  /**
   * Set int at position
   * @param pos Buffer position
   * @param i Int value
   * @return this for chaining
   */
  Buffer setInt(int pos, int i);

  /**
   * Set int with endianness
   * @param pos Buffer position
   * @param i Int value
   * @return this for chaining
   */
  Buffer setIntLE(int pos, int i);

  /**
   * Set long at position
   * @param pos Buffer position
   * @param l Long value
   * @return this for chaining
   */
  Buffer setLong(int pos, long l);

  /**
   * Set long with endianness
   * @param pos Buffer position
   * @param l Long value
   * @return this for chaining
   */
  Buffer setLongLE(int pos, long l);

  /**
   * Set short at position
   * @param pos Buffer position
   * @param s Short value
   * @return this for chaining
   */
  Buffer setShort(int pos, short s);

  /**
   * Set short with endianness
   * @param pos Buffer position
   * @param s Short value
   * @return this for chaining
   */
  Buffer setShortLE(int pos, short s);

  /**
   * Set float at position
   * @param pos Buffer position
   * @param f Float value
   * @return this for chaining
   */
  Buffer setFloat(int pos, float f);

  /**
   * Set double at position
   * @param pos Buffer position
   * @param d Double value
   * @return this for chaining
   */
  Buffer setDouble(int pos, double d);

  /**
   * Set string at position
   * @param pos Buffer position
   * @param str String value
   * @return this for chaining
   */
  Buffer setString(int pos, String str);

  /**
   * Set string with encoding
   * @param pos Buffer position
   * @param str String value
   * @param enc Character encoding
   * @return this for chaining
   */
  Buffer setString(int pos, String str, String enc);

  /**
   * Get buffer length
   * @return Buffer length
   */
  int length();

  /**
   * Copy buffer
   * @return Deep copy
   */
  Buffer copy();

  /**
   * Get slice of buffer
   * @param start Start position
   * @param end End position
   * @return Buffer slice
   */
  Buffer slice(int start, int end);

  /**
   * Get slice from start
   * @param start Start position
   * @return Buffer slice
   */
  Buffer slice(int start);

  /**
   * Convert to JSON object
   * @return JsonObject
   */
  JsonObject toJsonObject();

  /**
   * Convert to JSON array
   * @return JsonArray
   */
  JsonArray toJsonArray();

  /**
   * Convert to string
   * @return String representation
   */
  String toString();

  /**
   * Convert to string with encoding
   * @param enc Character encoding
   * @return String representation
   */
  String toString(String enc);

  /**
   * Get underlying byte array
   * @return Byte array
   */
  byte[] getBytes();
}

Reactive Streams

Stream abstractions with back-pressure support for reading and writing data.

/**
 * Readable stream interface
 */
interface ReadStream<T> extends StreamBase {
  /**
   * Set data handler
   * @param handler Handler for data items
   * @return this for chaining
   */
  ReadStream<T> handler(Handler<T> handler);

  /**
   * Pause reading
   * @return this for chaining
   */
  ReadStream<T> pause();

  /**
   * Resume reading
   * @return this for chaining
   */
  ReadStream<T> resume();

  /**
   * Fetch specific number of items
   * @param amount Number of items to fetch
   * @return this for chaining
   */
  ReadStream<T> fetch(long amount);

  /**
   * Set end handler
   * @param endHandler Handler called when stream ends
   * @return this for chaining
   */
  ReadStream<T> endHandler(Handler<Void> endHandler);

  /**
   * Pipe to write stream
   * @param dst Destination write stream
   * @return Pipe instance
   */
  <R> Pipe<R> pipe();

  /**
   * Pipe to write stream
   * @param dst Destination write stream
   * @return Future that completes when piping is done
   */
  Future<Void> pipeTo(WriteStream<T> dst);
}

/**
 * Writable stream interface
 */
interface WriteStream<T> extends StreamBase {
  /**
   * Write data to stream
   * @param data Data to write
   * @return Future that completes when written
   */
  Future<Void> write(T data);

  /**
   * End the stream
   * @return Future that completes when ended
   */
  Future<Void> end();

  /**
   * End the stream with final data
   * @param data Final data to write
   * @return Future that completes when ended
   */
  Future<Void> end(T data);

  /**
   * Set write queue max size
   * @param maxSize Maximum queue size
   * @return this for chaining
   */
  WriteStream<T> setWriteQueueMaxSize(int maxSize);

  /**
   * Check if write queue is full
   * @return true if full
   */
  boolean writeQueueFull();

  /**
   * Set drain handler for back-pressure
   * @param handler Handler called when queue drains
   * @return this for chaining
   */
  WriteStream<T> drainHandler(Handler<Void> handler);
}

/**
 * Base stream interface
 */
interface StreamBase {
  /**
   * Set exception handler
   * @param handler Exception handler
   * @return this for chaining
   */
  StreamBase exceptionHandler(Handler<Throwable> handler);
}

/**
 * Stream pipe for connecting read and write streams
 */
interface Pipe<T> {
  /**
   * Set end on failure behavior
   * @param end Whether to end destination on failure
   * @return this for chaining
   */
  Pipe<T> endOnFailure(boolean end);

  /**
   * Set end on success behavior
   * @param end Whether to end destination on success
   * @return this for chaining
   */
  Pipe<T> endOnSuccess(boolean end);

  /**
   * Set end on complete behavior
   * @param end Whether to end destination on complete
   * @return this for chaining
   */
  Pipe<T> endOnComplete(boolean end);

  /**
   * Pipe to destination
   * @param dst Destination write stream
   * @return Future that completes when done
   */
  Future<Void> to(WriteStream<T> dst);

  /**
   * Close the pipe
   */
  void close();
}

/**
 * Utility for pumping data between streams
 */
class Pump {
  /**
   * Create pump between streams
   * @param rs Read stream
   * @param ws Write stream
   * @return Pump instance
   */
  static Pump pump(ReadStream rs, WriteStream ws);

  /**
   * Create pump with throughput control
   * @param rs Read stream
   * @param ws Write stream
   * @param writeQueueMaxSize Write queue max size
   * @return Pump instance
   */
  static Pump pump(ReadStream rs, WriteStream ws, int writeQueueMaxSize);

  /**
   * Start pumping
   * @return this for chaining
   */
  Pump start();

  /**
   * Stop pumping
   * @return Stopped pump
   */
  Pump stop();

  /**
   * Get number of bytes pumped
   * @return Bytes pumped count
   */
  int numberPumped();
}

Shared Data

Thread-safe and cluster-wide data sharing mechanisms.

/**
 * Shared data access
 * @return SharedData instance
 */
SharedData sharedData();

/**
 * Shared data interface for maps, locks, and counters
 */
interface SharedData {
  /**
   * Get local shared map
   * @param name Map name
   * @return Local map
   */
  <K, V> LocalMap<K, V> getLocalMap(String name);

  /**
   * Get cluster-wide async map
   * @param name Map name
   * @return Future that completes with async map
   */
  <K, V> Future<AsyncMap<K, V>> getAsyncMap(String name);

  /**
   * Get cluster-wide async map (deprecated method name)
   * @param name Map name
   * @return Future that completes with async map
   */
  <K, V> Future<AsyncMap<K, V>> getClusterWideMap(String name);

  /**
   * Get distributed lock
   * @param name Lock name
   * @return Future that completes with lock
   */
  Future<Lock> getLock(String name);

  /**
   * Get distributed lock with timeout
   * @param name Lock name
   * @param timeout Timeout in milliseconds
   * @return Future that completes with lock
   */
  Future<Lock> getLockWithTimeout(String name, long timeout);

  /**
   * Get local lock
   * @param name Lock name
   * @return Future that completes with lock
   */
  Future<Lock> getLocalLock(String name);

  /**
   * Get local lock with timeout
   * @param name Lock name
   * @param timeout Timeout in milliseconds
   * @return Future that completes with lock
   */
  Future<Lock> getLocalLockWithTimeout(String name, long timeout);

  /**
   * Get distributed counter
   * @param name Counter name
   * @return Future that completes with counter
   */
  Future<Counter> getCounter(String name);

  /**
   * Get local counter
   * @param name Counter name
   * @return Future that completes with counter
   */
  Future<Counter> getLocalCounter(String name);
}

/**
 * Local shared map within Vert.x instance
 */
interface LocalMap<K, V> extends ClusterSerializable {
  V get(Object key);
  V put(K key, V value);
  V remove(Object key);
  void clear();
  int size();
  boolean isEmpty();
  V putIfAbsent(K key, V value);
  boolean removeIfPresent(K key, V value);
  boolean replaceIfPresent(K key, V oldValue, V newValue);
  V replace(K key, V value);
  void close();
  Set<K> keySet();
  Collection<V> values();
}

/**
 * Asynchronous distributed map
 */
interface AsyncMap<K, V> {
  Future<V> get(K k);
  Future<Void> put(K k, V v);
  Future<Void> put(K k, V v, long timeout);
  Future<V> putIfAbsent(K k, V v);
  Future<V> putIfAbsent(K k, V v, long timeout);
  Future<V> remove(K k);
  Future<Boolean> removeIfPresent(K k, V v);
  Future<V> replace(K k, V v);
  Future<Boolean> replaceIfPresent(K k, V oldValue, V newValue);
  Future<Void> clear();
  Future<Integer> size();
  Future<Set<K>> keys();
  Future<List<V>> values();
  Future<Map<K, V>> entries();
  Future<Void> close();
}

/**
 * Distributed counter
 */
interface Counter {
  Future<Long> get();
  Future<Long> incrementAndGet();
  Future<Long> getAndIncrement();
  Future<Long> decrementAndGet();
  Future<Long> getAndDecrement();
  Future<Long> addAndGet(long value);
  Future<Long> getAndAdd(long value);
  Future<Boolean> compareAndSet(long expected, long value);
}

/**
 * Distributed lock
 */
interface Lock {
  Future<Void> release();
}

/**
 * Marker interface for shareable objects
 */
interface Shareable {
}

/**
 * Interface for cluster serializable objects  
 */
interface ClusterSerializable {
}

Datagram and DNS Support

UDP datagram sockets and DNS resolution capabilities.

/**
 * Create datagram socket
 * @return DatagramSocket instance
 */
DatagramSocket createDatagramSocket();

/**
 * Create datagram socket with options
 * @param options Socket options
 * @return DatagramSocket instance
 */
DatagramSocket createDatagramSocket(DatagramSocketOptions options);

/**
 * UDP datagram socket interface
 */
interface DatagramSocket extends Measured, Closeable {
  /**
   * Send datagram packet
   * @param packet Packet data
   * @param port Target port  
   * @param host Target host
   * @return Future that completes when sent
   */
  Future<Void> send(Buffer packet, int port, String host);

  /**
   * Send datagram packet to address
   * @param packet Packet data
   * @param recipient Target address
   * @return Future that completes when sent
   */
  Future<Void> send(Buffer packet, SocketAddress recipient);

  /**
   * Get sender for address
   * @param port Target port
   * @param host Target host
   * @return Packet sender
   */
  PacketWritestream sender(int port, String host);

  /**
   * Set packet handler
   * @param handler Packet handler
   * @return this for chaining
   */
  DatagramSocket handler(Handler<DatagramPacket> handler);

  /**
   * Listen for packets
   * @param port Local port
   * @param host Local host
   * @return Future that completes when listening
   */
  Future<DatagramSocket> listen(int port, String host);

  /**
   * Join multicast group
   * @param multicastAddress Multicast address
   * @return Future that completes when joined
   */
  Future<Void> listenMulticastGroup(String multicastAddress);

  /**
   * Leave multicast group
   * @param multicastAddress Multicast address
   * @return Future that completes when left
   */
  Future<Void> unlistenMulticastGroup(String multicastAddress);

  /**
   * Block multicast group
   * @param multicastAddress Multicast address  
   * @param sourceToBlock Source to block
   * @return Future that completes when blocked
   */
  Future<Void> blockMulticastGroup(String multicastAddress, String sourceToBlock);

  /**
   * Get local address
   * @return Local socket address
   */
  SocketAddress localAddress();

  /**
   * Close socket
   * @return Future that completes when closed
   */
  Future<Void> close();
}

/**
 * Datagram packet interface
 */
interface DatagramPacket {
  /**
   * Get sender address
   * @return Sender address
   */
  SocketAddress sender();

  /**
   * Get packet data
   * @return Packet data buffer
   */
  Buffer data();
}

/**
 * Create DNS client
 * @return DnsClient instance
 */
DnsClient createDnsClient();

/**
 * Create DNS client with options
 * @param options DNS client options
 * @return DnsClient instance
 */
DnsClient createDnsClient(DnsClientOptions options);

/**
 * DNS client interface
 */
interface DnsClient {
  /**
   * Resolve hostname
   * @param name Hostname to resolve
   * @return Future that completes with addresses
   */
  Future<List<String>> resolve(String name);

  /**
   * Resolve A record
   * @param name Hostname to resolve
   * @return Future that completes with IPv4 addresses
   */
  Future<List<String>> resolveA(String name);

  /**
   * Resolve AAAA record
   * @param name Hostname to resolve
   * @return Future that completes with IPv6 addresses
   */
  Future<List<String>> resolveAAAA(String name);

  /**
   * Resolve CNAME record
   * @param name Hostname to resolve
   * @return Future that completes with canonical names
   */
  Future<List<String>> resolveCNAME(String name);

  /**
   * Resolve MX record
   * @param name Domain to resolve
   * @return Future that completes with MX records
   */
  Future<List<MxRecord>> resolveMX(String name);

  /**
   * Resolve TXT record
   * @param name Domain to resolve
   * @return Future that completes with TXT records
   */
  Future<List<String>> resolveTXT(String name);

  /**
   * Resolve PTR record (reverse lookup)
   * @param name IP address to resolve
   * @return Future that completes with hostnames
   */
  Future<String> resolvePTR(String name);

  /**
   * Resolve NS record
   * @param name Domain to resolve
   * @return Future that completes with name servers
   */
  Future<List<String>> resolveNS(String name);

  /**
   * Resolve SRV record
   * @param name Service name to resolve
   * @return Future that completes with SRV records
   */
  Future<List<SrvRecord>> resolveSRV(String name);

  /**
   * Reverse lookup IP address
   * @param ipaddress IP address
   * @return Future that completes with hostname
   */
  Future<String> reverseLookup(String ipaddress);

  /**
   * Close DNS client
   * @return Future that completes when closed
   */
  Future<Void> close();
}

Multi-valued Maps

Case-insensitive multi-valued maps used for HTTP headers and parameters.

/**
 * Multi-valued map interface
 */
interface MultiMap extends Iterable<Map.Entry<String, String>> {
  /**
   * Get first value for name
   * @param name Header name
   * @return First value or null
   */
  String get(String name);

  /**
   * Get all values for name
   * @param name Header name
   * @return List of values
   */
  List<String> getAll(String name);

  /**
   * Check if contains name
   * @param name Header name
   * @return true if contains
   */
  boolean contains(String name);

  /**
   * Check if empty
   * @return true if empty
   */
  boolean isEmpty();

  /**
   * Get all names
   * @return Set of names
   */
  Set<String> names();

  /**
   * Add name-value pair
   * @param name Header name
   * @param value Header value
   * @return this for chaining
   */
  MultiMap add(String name, String value);

  /**
   * Add name with multiple values
   * @param name Header name
   * @param values Header values
   * @return this for chaining
   */
  MultiMap add(String name, Iterable<String> values);

  /**
   * Add all from another MultiMap
   * @param map Source MultiMap
   * @return this for chaining
   */
  MultiMap addAll(MultiMap map);

  /**
   * Set name-value pair (replace existing)
   * @param name Header name
   * @param value Header value
   * @return this for chaining
   */
  MultiMap set(String name, String value);

  /**
   * Set name with multiple values
   * @param name Header name
   * @param values Header values
   * @return this for chaining
   */
  MultiMap set(String name, Iterable<String> values);

  /**
   * Set all from another MultiMap
   * @param map Source MultiMap
   * @return this for chaining
   */
  MultiMap setAll(MultiMap map);

  /**
   * Remove all values for name
   * @param name Header name
   * @return this for chaining
   */
  MultiMap remove(String name);

  /**
   * Clear all entries
   * @return this for chaining
   */
  MultiMap clear();

  /**
   * Get number of entries
   * @return Entry count
   */
  int size();

  /**
   * Create case-insensitive MultiMap
   * @return Empty MultiMap
   */
  static MultiMap caseInsensitiveMultiMap();
}

Usage Examples

JSON Processing:

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

// Create and manipulate JSON objects
JsonObject user = new JsonObject()
  .put("id", 123)
  .put("name", "John Doe")
  .put("email", "john@example.com")
  .put("active", true);

// Read values
String name = user.getString("name");
Integer id = user.getInteger("id");
Boolean active = user.getBoolean("active");

// Nested objects
JsonObject address = new JsonObject()
  .put("street", "123 Main St")
  .put("city", "Anytown");
user.put("address", address);

// JSON arrays
JsonArray hobbies = new JsonArray()
  .add("reading")
  .add("swimming")
  .add("coding");
user.put("hobbies", hobbies);

// Encoding/decoding
String json = user.encode();
JsonObject parsed = new JsonObject(json);

// POJO mapping
User userPojo = user.mapTo(User.class);
JsonObject fromPojo = JsonObject.mapFrom(userPojo);

Buffer Operations:

import io.vertx.core.buffer.Buffer;

// Create and manipulate buffers
Buffer buffer = Buffer.buffer();
buffer.appendString("Hello ")
      .appendString("World")
      .appendByte((byte) '!')
      .appendInt(42);

// Read data
String text = buffer.getString(0, 11); // "Hello World"
byte exclamation = buffer.getByte(11);
int number = buffer.getInt(12);

// Binary data
Buffer binaryData = Buffer.buffer()
  .appendInt(0x12345678)
  .appendLong(0x123456789ABCDEF0L)
  .appendFloat(3.14f)
  .appendDouble(2.718);

// Convert to/from JSON
JsonObject obj = new JsonObject().put("message", "hello");
Buffer jsonBuffer = Buffer.buffer(obj.encode());
JsonObject parsed = jsonBuffer.toJsonObject();

Stream Processing:

import io.vertx.core.streams.ReadStream;
import io.vertx.core.streams.WriteStream;
import io.vertx.core.streams.Pump;

// Stream data processing
ReadStream<Buffer> source = getDataSource();
WriteStream<Buffer> destination = getDataDestination();

// Simple piping
source.pipeTo(destination).onSuccess(v -> {
  System.out.println("Piping completed");
});

// Manual pump with control
Pump pump = Pump.pump(source, destination);
pump.start();

// Monitor progress
vertx.setPeriodic(1000, id -> {
  System.out.println("Pumped bytes: " + pump.numberPumped());
});

// Back-pressure handling
destination.drainHandler(v -> {
  System.out.println("Write queue drained, resuming");
  source.resume();
});

if (destination.writeQueueFull()) {
  source.pause();
}

Shared Data Usage:

import io.vertx.core.shareddata.SharedData;
import io.vertx.core.shareddata.LocalMap;

SharedData sharedData = vertx.sharedData();

// Local map within Vert.x instance
LocalMap<String, String> localMap = sharedData.getLocalMap("config");
localMap.put("database.url", "jdbc:postgresql://localhost/mydb");
localMap.put("cache.size", "1000");

String dbUrl = localMap.get("database.url");

// Cluster-wide async map
sharedData.<String, JsonObject>getAsyncMap("users").onSuccess(map -> {
  JsonObject user = new JsonObject()
    .put("name", "Alice")
    .put("age", 30);
  
  map.put("user123", user).onSuccess(v -> {
    System.out.println("User stored in cluster");
    
    map.get("user123").onSuccess(retrieved -> {
      System.out.println("Retrieved: " + retrieved.encode());
    });
  });
});

// Distributed counter
sharedData.getCounter("page-views").onSuccess(counter -> {
  counter.incrementAndGet().onSuccess(count -> {
    System.out.println("Page views: " + count);
  });
});

// Distributed lock
sharedData.getLock("critical-section").onSuccess(lock -> {
  System.out.println("Acquired lock, performing critical operation");
  
  // Perform critical work
  performCriticalOperation();
  
  // Release lock
  lock.release().onSuccess(v -> {
    System.out.println("Lock released");
  });
});

UDP and DNS Operations:

// UDP datagram socket
DatagramSocket socket = vertx.createDatagramSocket();

socket.handler(packet -> {
  System.out.println("Received packet from " + packet.sender());
  System.out.println("Data: " + packet.data().toString());
});

socket.listen(1234, "localhost").onSuccess(sock -> {
  System.out.println("UDP socket listening on port 1234");
  
  // Send response
  Buffer response = Buffer.buffer("Hello UDP Client!");
  socket.send(response, 1235, "localhost");
});

// DNS resolution
DnsClient dnsClient = vertx.createDnsClient();

dnsClient.resolveA("example.com").onSuccess(addresses -> {
  System.out.println("IPv4 addresses for example.com:");
  addresses.forEach(System.out::println);
});

dnsClient.resolveMX("example.com").onSuccess(mxRecords -> {
  System.out.println("MX records for example.com:");
  mxRecords.forEach(record -> {
    System.out.println("Priority: " + record.priority() + 
                      ", Name: " + record.name());
  });
});

Install with Tessl CLI

npx tessl i tessl/maven-io-vertx--vertx-core

docs

core-api.md

event-bus.md

file-system.md

http.md

index.md

networking.md

utilities.md

tile.json