У меня есть сценарий использования, когда я хочу отобразить объекты в ByteBuffer для передачи ....
@Mapper
public static interface ByteBufferMapper {
public static ByteBufferMapper INSTANCE = Mappers.getMapper(ByteBufferMapper.class);
default byte toByte(ByteBuffer buffer) {
byte b = buffer.get();
return b;
}
}
public static class Dto {
public byte b;
public byte bb;
...
}
@Mapper(uses = ByteBufferMapper.class)
public static interface DtoMapper {
public static DtoMapper INSTANCE = Mappers.getMapper(DtoMapper.class);
@Mapping(source = "buffer", target = "bb")
@Mapping(source = "buffer", target = "b")
Dto byteBufferToDto(ByteBuffer buffer);
}
public static void main( String[] args ) {
ByteBuffer buffer = ByteBuffer.allocate(2).put((byte) 0xFF).put((byte) 0x00).flip();
System.out.println(DtoMapper.INSTANCE.byteBufferToDto(buffer));
}
Есть ли способ управления порядком отображения MapStructs, чтобы переменная b
заполнялась с 0xFF и bb
заполняется значением 0x00?