net.i2p.data

## Class MetaLease

- java.lang.Object
- - net.i2p.data.DataStructureImpl
  - - net.i2p.data.Lease
    - - net.i2p.data.MetaLease

- All Implemented Interfaces:
    Serializable, DataStructure

      public class MetaLease
      extends Lease

  Implementation of MetaLease as specified in Proposal 123: New NetDb Entries.

  MetaLease extends the Lease concept to reference other LeaseSets rather than tunnel endpoints:

  - Points to another LeaseSet via its hash instead of a gateway router
  - Enables advanced routing and load balancing strategies
  - Includes cost and type information for selection algorithms
  - Fixed length of 40 bytes for consistency with Lease2

  Structure:

  - LeaseSet Hash: 32-byte hash of the target LeaseSet (available via `Lease.getGateway()`)
  - Cost: 4-byte cost value for routing decisions
  - Type: 4-byte type identifier for the referenced LeaseSet

  Key Differences from Lease:

  - Reference: Points to LeaseSet hash, not gateway router
  - TunnelId: Not supported (throws `UnsupportedOperationException`)
  - Metadata: Includes cost and type for intelligent selection
  - Usage: Used within MetaLeaseSet for indirect routing

  Usage Scenarios:

  - Load Balancing: Distribute traffic across multiple LeaseSets
  - Geographic Routing: Select LeaseSets based on location or performance
  - Fallback Strategies: Provide alternative LeaseSets for redundancy
  - Service Aggregation: Combine multiple services under one destination

  Selection Criteria:

  - Cost: Lower values indicate preferred routes
  - Type: Application-specific categorization
  - Hash: Uniquely identifies the target LeaseSet

  Implementation Status: PRELIMINARY - Subject to change as proposal evolves

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `LENGTH`

    - ### Fields inherited from class net.i2p.data.Lease

      `_end, _gateway, _tunnelId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetaLease()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object object)`
    `int` | `getCost()`
    `TunnelId` | `getTunnelId()` Tunnel on the gateway to communicate with
    `int` | `getType()`
    `int` | `hashCode()`
    `void` | `readBytes(InputStream in)` Load up the current object with data from the given stream.
    `void` | `setCost(int cost)`
    `void` | `setTunnelId(TunnelId id)` Configure the tunnel on the gateway to communicate with
    `void` | `setType(int type)`
    `String` | `toString()`
    `void` | `writeBytes(OutputStream out)` Write out the data structure to the stream, using the format defined in the I2P data structure specification.

    - ### Methods inherited from class net.i2p.data.Lease

      `getEndTime, getGateway, isExpired, isExpired, setEndDate, setGateway`

    - ### Methods inherited from class net.i2p.data.DataStructureImpl

      `calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### LENGTH

          public static final int LENGTH

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### MetaLease

          public MetaLease()

  - ### Method Detail

    - #### equals

          public boolean equals(Object object)

      Overrides:
        `equals` in class `Lease`

    - #### getCost

          public int getCost()

    - #### getTunnelId

          public TunnelId getTunnelId()

      Description copied from class: `Lease`
      Tunnel on the gateway to communicate with
      Overrides:
        `getTunnelId` in class `Lease`
      Returns:
        tunnel ID
      Throws:
        `UnsupportedOperationException` - always

    - #### getType

          public int getType()

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Lease`

    - #### readBytes

          public void readBytes(InputStream in)
                         throws DataFormatException,
                                IOException

      Description copied from interface: `DataStructure`
      Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification. Warning - many classes will throw IllegalStateException if data is already set.
      Specified by:
        `readBytes` in interface `DataStructure`
      Overrides:
        `readBytes` in class `Lease`
      Parameters:
        `in` - stream to read from
      Throws:
        `DataFormatException` - if the data is improperly formatted
        `IOException` - if there was a problem reading the stream

    - #### setCost

          public void setCost(int cost)

    - #### setTunnelId

          public void setTunnelId(TunnelId id)

      Description copied from class: `Lease`
      Configure the tunnel on the gateway to communicate with
      Overrides:
        `setTunnelId` in class `Lease`
      Parameters:
        `id` - tunnel ID
      Throws:
        `UnsupportedOperationException` - always

    - #### setType

          public void setType(int type)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Lease`

    - #### writeBytes

          public void writeBytes(OutputStream out)
                          throws DataFormatException,
                                 IOException

      Description copied from interface: `DataStructure`
      Write out the data structure to the stream, using the format defined in the I2P data structure specification.
      Specified by:
        `writeBytes` in interface `DataStructure`
      Overrides:
        `writeBytes` in class `Lease`
      Parameters:
        `out` - stream to write to
      Throws:
        `DataFormatException` - if the data was incomplete or not yet ready to be written
        `IOException` - if there was a problem writing to the stream