class CharSequenceCodec implements ICharSequenceCodec {

    @Override
    public byte[] encode(@Nonnull final CharSequence message) throws EncodingException {
        try {
            ByteBuffer encodedBuffer = encoder.encode(CharBuffer.wrap(message));
            byte[] bufferCopy = new byte[encodedBuffer.limit()];
            System.arraycopy(encodedBuffer.array(), 0, bufferCopy, 0, encodedBuffer.limit());

            return bufferCopy;
        } catch (CharacterCodingException e) {
            throw new EncodingException("UTF-8 encoding has been failed because: " + e.getMessage(), e);
        }
    }

    private  CharSequenceCodec(final String name);

}