class UriEncoding {

    public static String encodeQuery(final String query, final EncodingType encType) {
        requireNonNull(query);
        requireNonNull(encType);

        if (encType == EncodingType.FORM_URL_ENCODED) {
            return encodeFormUrlEncoded(query) //
                    .replaceAll("%3D", "=") //
                    .replaceAll("%26", "&");
        } else {
            return encodeRFC3986UriComponent(query, ALLOWED_IN_QUERY);
        }
    }

}