All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.base4j.cache.serializer.StringSerializer Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
package com.base4j.cache.serializer;

/**
 * UTF-8 String serializer
 */
public class StringSerializer implements Serializer {

    @Override
    public byte[] serialize(String str) {
        return (str == null || str.length() == 0) ? EMPTY_BYTES : str.getBytes(UTF_8);
    }

    @Override
    public String deserialize(byte[] bytes) {
        return (bytes == null || bytes.length == 0) ? EMPTY_STR : new String(bytes, UTF_8);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy