Class ChannelMapper

Object
ChannelMapper

public class ChannelMapper extends Object
Helps retrieve channel and an associated converter and apply operation on them jointly.
Author:
Owen Feehan
  • Constructor Details

  • Method Details

    • mapChannelIfSupported

      public <T> T mapChannelIfSupported(int channelIndex, BiFunction<Channel,ChannelConverterAttached<Channel,UnsignedByteBuffer>,T> mapFunction, Function<Channel,T> fallback)
      Maps a Channel with mapFunction if a corresponding converter exists, otherwise with fallback.
      Type Parameters:
      T - the destination type to map to.
      Parameters:
      channelIndex - the index of the channel to map, as well as the corresponding converter.
      mapFunction - used for the mapping, if a corresponding converter for channelIndex exists.
      fallback - used for the mapping, if a corresponding converter for channelIndex does not exist.
      Returns:
      the result of the mapping.
    • consumeChannelIfSupported

      public void consumeChannelIfSupported(int channelIndex, BiConsumer<Channel,ChannelConverterAttached<Channel,UnsignedByteBuffer>> consumer, Consumer<Channel> fallback)
      Like mapChannelIfSupported(int, BiFunction, Function) but the mapping has no return-type.
      Parameters:
      channelIndex - the index of the channel to consume, as well as the corresponding converter.
      consumer - used for the consuming, if a corresponding converter for channelIndex exists.
      fallback - used for the consuming, if a corresponding converter for channelIndex does not exist.