com.kuka.comm.codec
Class SwitchEncoder<I,O>
java.lang.Object
com.kuka.comm.codec.Encoder<I,O>
com.kuka.comm.codec.SwitchEncoder<I,O>
- Type Parameters:
I - The input message of type I.O - The resulting output of type O.
public final class SwitchEncoder<I,O>
- extends Encoder<I,O>
Class to determine the encoder according to the type of message which should be send. This class ensures a type-safe
identification of the associated encoder as long as an encoder for this message type exists.
This class won't encode anything directly. It is rather an selector for the right encoder. The encode method will be
used to call the encode method of the chosen encoder.
|
Method Summary |
|
addEncoder(Class<? extends T> inputType,
Encoder<T,O> encoder)
Public method to add an encoder to a list of encoder. |
protected void |
encodeImpl(I in,
O out)
Override this method to implement encoding process. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SwitchEncoder
public SwitchEncoder()
addEncoder
public <T extends I> SwitchEncoder<I,O> addEncoder(Class<? extends T> inputType,
Encoder<T,O> encoder)
throws IllegalArgumentException
- Public method to add an encoder to a list of encoder.
Analyzes the given encoder interface to identify its class and stores them in an internal map.
- Type Parameters:
T - the input type- Parameters:
inputType - the type of the input of the given encoderencoder - an encoder interface to append to internal encoder map
- Returns:
this-pointer to this object.
- Throws:
IllegalArgumentException - An exception thrown if no encoder-type could be resolved.
encodeImpl
protected void encodeImpl(I in,
O out)
throws EncoderException
- Description copied from class:
Encoder
- Override this method to implement encoding process.
Note: You should override either this method or Encoder.encodeImpl(Object, Object, EncoderContext).
Overriding both will have no effect, i.e. only Encoder.encodeImpl(Object, Object, EncoderContext) will be
called.
- Overrides:
encodeImpl in class Encoder<I,O>
- Parameters:
in - the input for this encoderout - the output for this encoder
- Throws:
EncoderException - if an error occurred during encoding- See Also:
Encoder.encodeImpl(Object, Object, EncoderContext)
Copyright © 2019. All rights reserved.