Code Monkey home page Code Monkey logo

Comments (4)

iamironz avatar iamironz commented on May 25, 2024

Hi !
What kind of generic types for collections do you mean? Because you just can't serialize all data types, only primitives and Strings.
Of course, you can rewrite StringSetSerializer and Preferences classes for accepting all inheritors of Iterable interface but you should refactor serializer class for accepting all kinds of generics like primitives and Strings. All this steps requires mid codebase refactoring and if you desire create this functionality you should provide small reference proof-of-concept of your ideas.

--

Cheers,
Alex

from binaryprefs.

Cilenco avatar Cilenco commented on May 25, 2024

I thought of collections of all primitive types, Strings and inheritors of Persistable.

To only rewrite the StringSetSerializer is not a good solution in my opinion. That would imply that each value is first converted to a string which may not be good practice. I think that rewriting all serializer classes is the better way to go here. I forked this repo and did some refactoring.

For POC look for example at the BooleanSerializer which now inherits from AbstractSerializer. There is most of the code for the Collection serialization. This new implementation does not break with the current one (except of FLAGS and NULL values) and also new test cases work pretty well.

Of course the Preferences as well as the PreferencesEditor interface have to change to accept collections and arrays but that shouldn't be the problem I guess.

from binaryprefs.

iamironz avatar iamironz commented on May 25, 2024

That would imply that each value is first converted to a string

nope, I meant that you should rewrite this one for working with generic types natively not String.valueOf

inherits from AbstractSerializer

This is not good enough because your base serializer has methods which is useless for most serializers and used not always, I prefer use delegates instead of inheritors, keep your code simple.

from binaryprefs.

Cilenco avatar Cilenco commented on May 25, 2024

Let me check if I got your point right:

Your idea is to only rewrite the StringSetSerializer (apart from Preferences) to accept all kinds of Collection. Then each Collection is serialized similar to a Set<String> and only the encoding of the types change? So e.g. List<Integer> would call a method in StringSetSerializer but the encoding of the elements itself is then handeled by IntegerSerializer?

from binaryprefs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.