class IPAnonymizationUtils {

	public static String anonymize(String ip) {
		InetAddress inetAddress;
		try {
			inetAddress = InetAddresses.forString(ip);
		} catch (IllegalArgumentException e) {
			logger.warn(e.getMessage(), e);
			inetAddress = null;
		}
		InetAddress anonymized = null;
		if (inetAddress instanceof Inet4Address) {
			anonymized = anonymizeIpV4Address((Inet4Address) inetAddress);
		} else if (inetAddress instanceof Inet6Address) {
			anonymized = anonymizeIpV6Address((Inet6Address) inetAddress);
		}
		if (anonymized != null) {
			return anonymized.getHostAddress();
		} else {
			return null;
		}
	}

	private  IPAnonymizationUtils();

}