Class ChannelMapper
Object
ChannelMapper
Helps retrieve channel and an associated converter and apply operation on them jointly.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionChannelMapper
(IntFunction<Channel> channelGetter, IntFunction<Optional<ChannelConverterAttached<Channel, UnsignedByteBuffer>>> converterGetter) Creates a newChannelMapper
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
consumeChannelIfSupported
(int channelIndex, BiConsumer<Channel, ChannelConverterAttached<Channel, UnsignedByteBuffer>> consumer, Consumer<Channel> fallback) LikemapChannelIfSupported(int, BiFunction, Function)
but the mapping has no return-type.<T> T
mapChannelIfSupported
(int channelIndex, BiFunction<Channel, ChannelConverterAttached<Channel, UnsignedByteBuffer>, T> mapFunction, Function<Channel, T> fallback)
-
Constructor Details
-
ChannelMapper
public ChannelMapper(IntFunction<Channel> channelGetter, IntFunction<Optional<ChannelConverterAttached<Channel, UnsignedByteBuffer>>> converterGetter) Creates a newChannelMapper
instance.- Parameters:
channelGetter
- Gets aChannel
corresponding to a particular index (zero-indexed).converterGetter
- Gets a converter corresponding to a channel at a particular index (zero-indexed).
-
-
Method Details
-
mapChannelIfSupported
public <T> T mapChannelIfSupported(int channelIndex, BiFunction<Channel, ChannelConverterAttached<Channel, UnsignedByteBuffer>, T> mapFunction, Function<Channel, T> 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 forchannelIndex
exists.fallback
- used for the mapping, if a corresponding converter forchannelIndex
does not exist.- Returns:
- the result of the mapping.
-
consumeChannelIfSupported
public void consumeChannelIfSupported(int channelIndex, BiConsumer<Channel, ChannelConverterAttached<Channel, UnsignedByteBuffer>> consumer, Consumer<Channel> fallback) LikemapChannelIfSupported(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 forchannelIndex
exists.fallback
- used for the consuming, if a corresponding converter forchannelIndex
does not exist.
-