-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Convert the following code into builtins mapper 👍
import static java.nio.charset.StandardCharsets.UTF_8 ;
import java.io.UnsupportedEncodingException ;
import java.net.URLDecoder ;
import java.net.URLEncoder ;
import java.util.Base64 ;
/**
* @author spornda
*
*/
public final class BuiltinsNetTransformations {
public static final Function<String, byte[]> DECODE_BASE64 = t -> Base64.getDecoder().decode(t) ;
public static final Function<String, String> DECODE_URL = t -> {
if (null == t || "null".equals(t)) {
return null ;
}
try {
return URLDecoder.decode(t, UTF_8.name()) ;
} catch (UnsupportedEncodingException e) {
// Ça ne doit jamais arriver
throw new IllegalStateException("The Character Encoding is not supported : " + t) ;
}
} ;
public static final Function<byte[], String> ENCODE_BASE64 = t -> (null != t) ? Base64.getEncoder().encodeToString(t) : "" ;
public static final Function<String, String> ENCODE_URL = t -> {
if (t == null) {
return t ;
}
try {
return URLEncoder.encode(t, UTF_8.name()) ;
} catch (UnsupportedEncodingException e) {
// Ça ne doit jamais arriver
throw new IllegalStateException("The Character Encoding is not supported : " + t) ;
}
} ;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels