facebookarchive / swift

An annotation-based Java library for creating Thrift serializable types and services.
Apache License 2.0
900 stars 297 forks source link

Allow binding custom thrift codecs by class #102

Closed andrewcox closed 11 years ago

andrewcox commented 11 years ago

All overloads of bindThriftCodec() actually assumed the class you were referring to was a thrift type, and created a binding for the codec using a provider that would ask the codec manager for an appropriate codec. Only one overload let you install a custom codec, and it required an instance, which is problematic because sometimes you want to create a custom codec that depends on an injected ThriftCatalog or ThriftCodecManager.

I renamed this overload bindThriftCustomCodec() to help reduce confusion between overloads that take a thrift type argument, and overloads that take a codec argument, and then added more overloads of this bindThriftCustomCodec() that will take class, typeliteral, and key.

andrewcox commented 11 years ago

The overload taking an instance is different, but you're right the other two (Class & TypeLiteral) could resolve to one-liners that call the Key overload. So I'll make that change.

The reason for keeping the Class & TypeLiteral overloads is just to reduce verbosity for callers.

andrewcox commented 11 years ago

Changes applied, merged and pushed