create factories/abstract factory for similar objects
https://github.com/asdru22/OOPack/blob/main/src/main/java/com/asdru/oopack/internal/TextFile.java
https://github.com/asdru22/OOPack/blob/main/src/main/java/com/asdru/oopack/Objects/JsonFile.java
https://github.com/asdru22/OOPack/blob/main/src/main/java/com/asdru/oopack/Objects/LootTable.java
https://github.com/asdru22/OOPack/blob/main/src/main/java/com/asdru/oopack/Objects/Model.java
i have these objects, where json file extends text file, loot table and model extend jsonfile. Whats the best way to setup a factory so that i dont have to inherit all the constructors?
3 Replies
⌛ This post has been reserved for your question.
Hey @Asdru! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
this is a very chatgpt-d solution and i get what its doing, altho i was hoping to avoid having to use a
Class<T> clazz param for clarity reasons. if that's not possible or this is the best solution i can live with it tho...
because the syntax would go from
LootTable lt1 = new LootTable( "loot1", "{...json...}");
to
LootTable lt1 = JsonFileFactory.fromNameAndContent(LootTable.class, "loot1", "{...json...}");💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.