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 newChannelMapperinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsumeChannelIfSupported(int channelIndex, BiConsumer<Channel, ChannelConverterAttached<Channel, UnsignedByteBuffer>> consumer, Consumer<Channel> fallback) LikemapChannelIfSupported(int, BiFunction, Function)but the mapping has no return-type.<T> TmapChannelIfSupported(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 newChannelMapperinstance.- Parameters:
channelGetter- Gets aChannelcorresponding 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 forchannelIndexexists.fallback- used for the mapping, if a corresponding converter forchannelIndexdoes 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 forchannelIndexexists.fallback- used for the consuming, if a corresponding converter forchannelIndexdoes not exist.
-