class IpAddressMatcher {

  private static final Logger logger = LoggerFactory.getLogger(IpAddressMatcher.class);

  private final int nMaskBits;

  private final InetAddress requiredAddress;

  /**
   * Takes a specific IP address or a range specified using the IP/Netmask (e.g.
   * 192.168.1.0/24 or 202.24.0.0/14).
   *
   * @param ipAddress the address or range of addresses from which the request must
   *        come.
   */
  public IpAddressMatcher(String ipAddress) {
    if (ipAddress.indexOf('/') > 0) {
      String[] addressWithMask = ipAddress.split("\\/");
      ipAddress = addressWithMask[0];
      this.nMaskBits = Integer.parseInt(addressWithMask[1]);
    } else {
      this.nMaskBits = -1;
    }
    this.requiredAddress = parseAddress(ipAddress);
  }

  public boolean matches(String address) {<FILL_FUNCTION_BODY>}

  private InetAddress parseAddress(String address) {
    try {
      return InetAddress.getByName(address);
    } catch (UnknownHostException e) {
      // Log error only when address is not generated by client as default parameters
      if (!Config.DEFAULT_MASTER_URL.contains(address)) {
        logger.error("Failed to resolve hostname: {}", address);
      }
      return null;
    }
  }
}

    InetAddress remoteAddress = parseAddress(address);
    if (remoteAddress == null || requiredAddress == null) {
      return false;
    }
    if (!this.requiredAddress.getClass().equals(remoteAddress.getClass())) {
      return false;
    }
    if (this.nMaskBits < 0) {
      return remoteAddress.equals(this.requiredAddress);
    }
    byte[] remAddr = remoteAddress.getAddress();
    byte[] reqAddr = this.requiredAddress.getAddress();
    int nMaskFullBytes = this.nMaskBits / 8;
    byte finalByte = (byte) (0xFF00 >> (this.nMaskBits & 0x07));
    for (int i = 0; i < nMaskFullBytes; i++) {
      if (remAddr[i] != reqAddr[i]) {
        return false;
      }
    }
    if (finalByte != 0) {
      return (remAddr[nMaskFullBytes] & finalByte) == (reqAddr[nMaskFullBytes] & finalByte);
    }
    return true;
  
<no_super_class>