Package st.orm.spi

Interface CursorCodecProvider


public interface CursorCodecProvider
Service provider interface for registering custom cursor codecs.

Implementations are discovered via ServiceLoader and used to extend the set of types that Scrollable.toCursor() and Scrollable.from(String) can serialize. To register a custom codec, implement this interface and add the fully qualified class name to META-INF/services/st.orm.spi.CursorCodecProvider.


 public class MyCursorCodecProvider implements CursorCodecProvider {
     @Override
     public List<CursorCodecEntry<?>> codecs() {
         return List.of(
             new CursorCodecEntry<>(64, UserId.class, new CursorCodec<UserId>() {
                 public void write(DataOutputStream out, UserId value) throws IOException {
                     out.writeLong(value.value());
                 }
                 public UserId read(DataInputStream in) throws IOException {
                     return new UserId(in.readLong());
                 }
             })
         );
     }
 }
 

Custom codecs must use tags in the range [64, 255]. Tags 0-63 are reserved for built-in types.

Since:
1.11
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the list of custom cursor codec entries to register.
  • Method Details

    • codecs

      List<CursorCodecEntry<?>> codecs()
      Returns the list of custom cursor codec entries to register.
      Returns:
      codec entries (must not be null or contain null elements).