@Retention(value=RUNTIME) @Target(value=TYPE) @Documented public @interface CodecRegistry
public class MyOwnType {...}
@CodecRegistry
public [class | abstract class | interface] MyCodecRegistry {
//Source type = int, target type = String (according to IntToStringCodec codec)
@Codec(IntToStringCodec.class)
private int intToString;
//Source type = MyOwnType, target type = String (according to MyOwnTypeToStringCodec codec)
@Codec(MyOwnTypeToStringCodec.class)
private MyOwnType myOwnTypeToString;
//Source type = AnotherBean, target type = String (because of @JSON)
@JSON
private AnotherBean beanToJSON;
//Source type = MyEnum, target type = int (because of Encoding.ORDINAL)
@Enumerated(Encoding.ORDINAL)
private MyEnum enumToOrdinal;
}
@CodecRegistry
public class MyCodecRegistry {
@Codec(MyOwnTypeToStringCodec.class)
private MyOwnType myOwnTypeToString;
// ERROR, not possible to have a 2nd codec for the same source type MyOwnType
@Codec(MyOwnTypeToBytesCodec.class)
private MyOwnType myOwnTypeToBytes;
}
Copyright © 2012-2021. All Rights Reserved.