code: public IPv6Address maskWithNetworkMask(final IPv6NetworkMask networkMask)
      {
          if (networkMask.asPrefixLength() == 128)
          {
              return this;
          }
          else if (networkMask.asPrefixLength() == 64)
          {
              return new IPv6Address(this.highBits, 0);
          }
          else if (networkMask.asPrefixLength() == 0)
          {
              return new IPv6Address(0, 0);
          }
          else if (networkMask.asPrefixLength() > 64)
          {
              // apply mask on low bits only
              final int remainingPrefixLength = networkMask.asPrefixLength() - 64;
              return new IPv6Address(this.highBits, this.lowBits & (0xFFFFFFFFFFFFFFFFL << (64 - remainingPrefixLength)));
          }
          else
          {
              // apply mask on high bits, low bits completely 0
              return new IPv6Address(this.highBits & (0xFFFFFFFFFFFFFFFFL << (64 - networkMask.asPrefixLength())), 0);
          }
      }
docs: Mask the address with the given network mask.
  
  @param networkMask network mask
  @return an address of which the last 128 - networkMask.asPrefixLength() bits are zero