Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization issue with RuntimeTypeAdapterFactory #712

Closed
ultraon opened this issue Oct 15, 2015 · 8 comments
Closed

Serialization issue with RuntimeTypeAdapterFactory #712

ultraon opened this issue Oct 15, 2015 · 8 comments
Assignees

Comments

@ultraon
Copy link

ultraon commented Oct 15, 2015

Hello, i found after serialization root object 'type' field is not injected, for inner object 'type' fields are added. Example:

public class Test {
  public class Base {
    String baseField = "base";
  }
  public class Child extends Base {
    String childField = "child";
    Base baseInChild = new Base();
  }

  public static void main(String[] args) {
        Gson mGson = new GsonBuilder()
                .setPrettyPrinting()
                .registerTypeAdapterFactory(
                        RuntimeTypeAdapterFactory.
                                of(Base.class).
                                registerSubtype(Base.class).
                                registerSubtype(Child.class)
                )
                .create();

        final String jsonStr = mGson.toJson(new Child());
        final Base child = mGson.fromJson(jsonStr, Base.class); // ERROR HERE: "Caused by: com.google.gson.JsonParseException: cannot deserialize class mypackage.Test$Base because it does not define a field named type"
  }
}

and json output after serialization:

{
  "baseInChild": {
    "type": "Base",
    "baseField": "base"
  },
  "childField": "child",
  "baseField": "base"
//in this place should be generated field 'type' with value 'Child'
}
@ultraon
Copy link
Author

ultraon commented Oct 17, 2015

Hello, i've found bug in RuntimeTypeAdapterFactory (line185, method create(), and resolved this issue, need replace

if (type.getRawType() != baseType)

with

if (null == type || !baseType.isAssignableFrom(type.getRawType()))

Then RuntimeTypeAdapterFactory works well as expected.
Full version: RuntimeTypeAdapterFactory

@renanferrari
Copy link

@ultraon Thanks, just ran into this issue today and your answer solved it.

@calrsom
Copy link

calrsom commented Feb 12, 2016

Thank you. This solved an issue I had with serializing an subtype with a custom serializer and type field not being included. This fix should really get pulled into the codebase.

@swankjesse
Copy link
Collaborator

Try replacing this:

        final String jsonStr = mGson.toJson(new Child());

With this:

        final String jsonStr = mGson.toJson(new Child(), Base.class);

@ghost
Copy link

ghost commented Feb 23, 2016

@swankjesse i guess thats where the problem is. i tried using the same it didnt work. Am about to try with the solution which @ultraon has given.

@headsvk
Copy link

headsvk commented Mar 2, 2017

@swankjesse What if you want to serialize a List? @ultraon solution works for that

@luizfp
Copy link

luizfp commented Jun 12, 2017

The solution proposed by @ultraon have worked for me as well. I agree with @calrsom, this should be added in the codebase with the proper tests.

JayTSmith added a commit to JayTSmith/mazes_and_minotaurs that referenced this issue Oct 18, 2017
ThorinSchmidt pushed a commit to CIS-Stars/mazes_and_minotaurs that referenced this issue Oct 19, 2017
* Started to add the character class into the Game.

* + Added references in game_references.xml for
    - Genders
    - Classes
    - Levels
+ Finalized Warrior Type Classes along with Base Classes
+ Created Barbarian Class
+ Created Util Class to provide helper functions and values
+ Removed CharClass
+ Renamed Core to Score to better explain usage.

* Actually pushed the files

* Started to add the character class into the Game.

* + Added references in game_references.xml for
    - Genders
    - Classes
    - Levels
+ Finalized Warrior Type Classes along with Base Classes
+ Created Barbarian Class
+ Created Util Class to provide helper functions and values
+ Removed CharClass
+ Renamed Core to Score to better explain usage.

* Actually pushed the files

* + Changed the code to use AttributeScores rather than just raw Integers.
+ Created a basic form of Amazon
+ Swapped the ResId in Barbarian for the ResId defined in the Enum.

* + Added Money enum
+ Added Money property to Character
+ Improved the functionality of Barbarian
    - Added LevelUp
    - Added LevelDown
    - Added property to track user choices of leveling up
+ Added Money strings to game_references.xml

+ Created Magician abstract class
+ Created mEffectiveLevel property in base class to ease the burden of leveling up and down.

* + Changed Character class to PlayerCharacter

* + Changed getCoreStatScore to getScore

* + Modified LevelUp and LevelDown to restore the proper scores rather than calculated scores.
---WARNING---
Changes made in a sleepy state, they may not be implemented properly or effectively.

* Removed the EffectiveLevel property from BaseClass
Removed the updateLevel method
Added an example of getting modifier to CharacterSheet

* + Added methods for saving throws in PlayerCharacter.java
    +getAthleticProwess
    +getDangerEvasion
    +getMysticFortitude
    +getPhysicalVigor
    +getCharisma

* + Added the Equipment functionality to Barbarian
+ Changed some int arguments to use Weapon instead
+ Added some documentation to PlayerCharacter
+ Also fixed some typos in method names in PlayerCharacter.

* + Added the equipment functionality to the PlayerCharacter
    - Weapon Attribute
    - Weapon of Choice checking
+ Added weapon of choice to specialist

* + Fixed more typos
+ Added the initializeClass method to ease the burden of switching classes at first.

* + Changed Portfolio to work with the new method of Character Creation

* + Changed mWeapon to mCurrentWeapon
+ Added getWeapons method to PlayerCharacter
+ Fixed issue where PlayerCharacter wouldn't have a weapon equipped.

* + Made getHitTotal function properly
+ Improved documentation on the PlayerCharacter class

* + Removed initialization from PlayerCharacter's constructor.

* + Added GSON lib.
+ Added Saving Functionality
+ Broken Load Functionality at the moment.

* Fixed loading functionality.

* Added javadoc for SaveAndLoadPerformer

* Finished commit.

* Changed and added methods to the Util class.
* Added javadoc to signature roll(int)
* Added method roll(int, int) with javadoc

Started to add Amazon PlayerCharacter class.

* Finished with Amazon

* Created Centaur (should be ready to implement).

* Fixed bugged gold for Amazon and Barb.

* Created and added Noble
Fixed bug where Barb's weapon of choice would always be set to Barb Axe.

* Added and Created Spearman class.
Added Heroic Heritage to Nobles.

* Added Battle Fortune to Noble.

* Setup project on new PC.
Multiple files changed to resolve errors.

* Fully implemented Centaur.
* Finished up the constructor.

* Fully implemented Thief.

* Created Hunter and fully implemented!

Specialist.java:
* Added Special Talent Method

Thief.java:
* Implemented Special Talent Method

* Moved getSpecialTalent to Specialist.java

* Removed getSpecialTalent from the respective classes.

* Added new values.

* Renamed the values.

* Resolved the TODOs in the code.

* Fixed a typo.

* Removed methods that are inside of the Level Interface, and made getLevelDescription abstract.

* Fixed issue #2.

* Added functionality to Patron.

* Fixed Specialist lacking the Level Descriptions.

* Added the instance field for possibleStartWeapons to BaseClass
Also, added the fully implemented feature into Amazon.

* Updated Barbarian to new format.

* Added the instance field mPossibleWeaponsOfChoice to Warrior.
Made the setter for mWeaponOfChoice check if it is valid.

* Changed how Amazon would validate starting weapon.

* Changed Warrior so it would still weaponOfChoice even if argument wasn't valid.

* Changed Amazon and Barbarian to remove their checking of weaponOfChoice.

* Centaur has been brought up-to-date.

* Noble has been brought up-to-date.

* Spearman has been brought up-to-date.

* Added instance field mPossibleWeaponsOfChoice to Specialist.

* Hunter has been brought up-to-date.

* Thief has been brought up-to-date.

* Added safe-checking to Specialist's setWeaponOfChoice

* All available Magicans classes have been brought up-to-date.

* Fixed bug with App Crash

* Fixed EDC issue where it could return the incorrect values.

* Added Patreon instance field to PlayerCharacter

* Created res/dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created DetailFragment class

* Have a very rough version of the new dialog working.

* Still a rough version but slightly improved.

* Added a blank construcutor for all subclasses of BaseClass.

* Added values into the Classes Enum

* Created a custom adapter.

* Created the layout for weapons in a spinner.

* Finalized the layout of the spinner items

* Added getters

* Changed startGold to startMoney.

* Fixed a massive issue regarding scope in the character package.

* Incomplete update for editing attribute values on the character

* Added the ability to edit the Might score.

* Added the edit ability to the rest of the attribute scores.

* Modified the layout of attribute editing dialog.

* Added the proper values for the labels on the CharacterSheet.

* Adding mCurrentHits functionality.

* Rearranged the layout of the Attribute edit dialog to fix issues of cropping.

* Added safe-checking when getting a value from the dialog.

* Fixed an issue where it would refresh the UI regardless of change.

* Added value checking onto the setCurHits method of PlayerCharacter.

* Moved StatChangeFragment to fragments package.

* Created the HitsChangeFragment class

* Fixed an issue where newInstance wasn't exposed.

* Added the ability to edit hits on the character sheet.

* The user can change hits now on the character sheet.

* Fixed an issue causing a crash every time the HitsDialog popped up

* Fixed an issue causing a crash every time the HitsDialog's confirm button was pressed

* Fixed setCurHits allowing bad values.

* Removed debugPrintScores function from PlayerCharacter.

* Reformatted some code.

* PlayerCharacter now updates curHits when initalizeClass is called.

* Removed unused instance fields from Util.

* Removed a todo.

* Added a getter for the instance field weapons.

* MID-WORK COMMIT - This is to simply save work.

* Weapon of Choice is now checked when making an attack.

* Melee bonus is now properly updated in the GUI.

* Disabled some stuff to disable crashing.

* Changed the textView's id to make it more unique.

* Implemented a working version of the DetailedDialog.

* Removed the WeaponArrayAdapter.

* Updated values in strings.xml

* Fixed values in layout and strings.xml

* Changed layout to simple support layout.

* Added safe checking to event handlers in DetailDialog.

* Added a default constructor for Priest.

* Rearranged constructor args to be fitting with other code.

* Added getAmmo to Util.

* Removed unused imports.

* Made getAmmo static.

* Changed constructors that had RangedWeapons involved in startGear.

* Made the dialog swap out the starting weapon with chosen starting weapon.

* Fixed the error where Centaur would start with weaponOfChoice.

* Made the dialog properly create an instance with filled in values.

* Binded a PlayerCharacter to the newly created instance.

* Modified the listener's interface.

* Made BaseClass serializable.

* Made a rough version of passing character between the dialog and sheet.

* Added throwing knife as a weapon

* Removed System.out statements.

* Added some error handling to the dialog.

* Fixed bug where the class wasn't fully initialized.

* Feature complete, able to transfer newly created character to sheet.

* Removed invalid weapon, "mace".

* Added null handling Noble.

* Added a Club Entry.

* Fixed Noble crash potential.

* Implemented the new dialog for all of the classes.

* Added more error-handling into the code.

* Removed outdated variables.

* Fixed a bug where the CreateCharacter and CharcterSheetFragment would both be visible.

* Moved most of the code to fill in the fragment into a seperate method.

* Removed unused code.

* Allows the active character to be perserved after the character changes.

* Merge branch 'master' of https://github.com/CIS-Extra/mazes_and_minotaurs

# Conflicts:
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/NewCharacter/CreateCharacter.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/rollDice/rollDice.java
#	MazesAndMinotaurs/instapk.log

* Resolved issue with merge.

* Added value for Priest.

* Added handling in case there is no possible starting weapon.

* Added handling for lack of a weapon

* Added handling for the dialog for lack of a weapon as well.

* fixed issue #24, discovered issue #25, and fixed issue #25

* Removed statements related to debuggging.

* Added helper methods,

* Changed the choice weapon spinner to hide if the user selects a Magician.

* Added resIds to Score enum.

* Now have a working implentmention of Noble Heritage.

* Cleaned up some of the code related to Noble creation.

* Added safe checking to doHeritage.

* #27 fixed

* Created DetailedWeaponAdapater

* Changed DeteailedWeaponAdapter to subclass BaseAdapter.

* CreatedlLayout for individual spinner items for DetailedWeaponAdapter

* Exposed some code to make it easier to implement.

* Added the ability to change active weapon. Issue #11 fixed.

* Added handling for null values.

* Fixed #30.

* Simplified SaveAndLoadPerformer

* Changed name to fit with conventions.

* Added layout for character spinner items.

* Added save icon.

* Added action item, "Save Portfolio".

* Added methods to serialize Portfolio.

* Reverted SaveAndLoadPerformer

* Seperated SaveAndLoadPerformer and CharacterSerializer

* Added RuntimeTypeAdapterFactory.

* Fixed with solution located at google/gson#712

* Serialization should finally work as intended aside from issue #34.

* Added ability to handle failed load.

* Labeled certain methods and classes as deprecated

* Added the ability to handle polymorphism in Equipment objects.

* Replaced multiple gson creations with static one(s).

* Created CharacterAdapter

* Added functionality to CharacterAdapter

* Added a character select screen.

* Added a character delete screen.

* The list nows updates when a character is deleted.

* Fixed #34
ThorinSchmidt pushed a commit to CIS-Stars/mazes_and_minotaurs that referenced this issue Nov 1, 2017
* + Changed Character class to PlayerCharacter

* + Changed getCoreStatScore to getScore

* + Modified LevelUp and LevelDown to restore the proper scores rather than calculated scores.
---WARNING---
Changes made in a sleepy state, they may not be implemented properly or effectively.

* Removed the EffectiveLevel property from BaseClass
Removed the updateLevel method
Added an example of getting modifier to CharacterSheet

* + Added methods for saving throws in PlayerCharacter.java
    +getAthleticProwess
    +getDangerEvasion
    +getMysticFortitude
    +getPhysicalVigor
    +getCharisma

* + Added the Equipment functionality to Barbarian
+ Changed some int arguments to use Weapon instead
+ Added some documentation to PlayerCharacter
+ Also fixed some typos in method names in PlayerCharacter.

* + Added the equipment functionality to the PlayerCharacter
    - Weapon Attribute
    - Weapon of Choice checking
+ Added weapon of choice to specialist

* + Fixed more typos
+ Added the initializeClass method to ease the burden of switching classes at first.

* + Changed Portfolio to work with the new method of Character Creation

* + Changed mWeapon to mCurrentWeapon
+ Added getWeapons method to PlayerCharacter
+ Fixed issue where PlayerCharacter wouldn't have a weapon equipped.

* + Made getHitTotal function properly
+ Improved documentation on the PlayerCharacter class

* + Removed initialization from PlayerCharacter's constructor.

* + Added GSON lib.
+ Added Saving Functionality
+ Broken Load Functionality at the moment.

* Fixed loading functionality.

* Added javadoc for SaveAndLoadPerformer

* Finished commit.

* Changed and added methods to the Util class.
* Added javadoc to signature roll(int)
* Added method roll(int, int) with javadoc

Started to add Amazon PlayerCharacter class.

* Finished with Amazon

* Created Centaur (should be ready to implement).

* Fixed bugged gold for Amazon and Barb.

* Created and added Noble
Fixed bug where Barb's weapon of choice would always be set to Barb Axe.

* Added and Created Spearman class.
Added Heroic Heritage to Nobles.

* Added Battle Fortune to Noble.

* Setup project on new PC.
Multiple files changed to resolve errors.

* Fully implemented Centaur.
* Finished up the constructor.

* Fully implemented Thief.

* Created Hunter and fully implemented!

Specialist.java:
* Added Special Talent Method

Thief.java:
* Implemented Special Talent Method

* Moved getSpecialTalent to Specialist.java

* Removed getSpecialTalent from the respective classes.

* Added new values.

* Renamed the values.

* Resolved the TODOs in the code.

* Fixed a typo.

* Removed methods that are inside of the Level Interface, and made getLevelDescription abstract.

* Fixed issue #2.

* Added functionality to Patron.

* Fixed Specialist lacking the Level Descriptions.

* Added the instance field for possibleStartWeapons to BaseClass
Also, added the fully implemented feature into Amazon.

* Updated Barbarian to new format.

* Added the instance field mPossibleWeaponsOfChoice to Warrior.
Made the setter for mWeaponOfChoice check if it is valid.

* Changed how Amazon would validate starting weapon.

* Changed Warrior so it would still weaponOfChoice even if argument wasn't valid.

* Changed Amazon and Barbarian to remove their checking of weaponOfChoice.

* Centaur has been brought up-to-date.

* Noble has been brought up-to-date.

* Spearman has been brought up-to-date.

* Added instance field mPossibleWeaponsOfChoice to Specialist.

* Hunter has been brought up-to-date.

* Thief has been brought up-to-date.

* Added safe-checking to Specialist's setWeaponOfChoice

* All available Magicans classes have been brought up-to-date.

* Fixed bug with App Crash

* Fixed EDC issue where it could return the incorrect values.

* Added Patreon instance field to PlayerCharacter

* Created res/dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created DetailFragment class

* Have a very rough version of the new dialog working.

* Still a rough version but slightly improved.

* Added a blank construcutor for all subclasses of BaseClass.

* Added values into the Classes Enum

* Created a custom adapter.

* Created the layout for weapons in a spinner.

* Finalized the layout of the spinner items

* Added getters

* Changed startGold to startMoney.

* Fixed a massive issue regarding scope in the character package.

* Incomplete update for editing attribute values on the character

* Added the ability to edit the Might score.

* Added the edit ability to the rest of the attribute scores.

* Modified the layout of attribute editing dialog.

* Added the proper values for the labels on the CharacterSheet.

* Adding mCurrentHits functionality.

* Rearranged the layout of the Attribute edit dialog to fix issues of cropping.

* Added safe-checking when getting a value from the dialog.

* Fixed an issue where it would refresh the UI regardless of change.

* Added value checking onto the setCurHits method of PlayerCharacter.

* Moved StatChangeFragment to fragments package.

* Created the HitsChangeFragment class

* Fixed an issue where newInstance wasn't exposed.

* Added the ability to edit hits on the character sheet.

* The user can change hits now on the character sheet.

* Fixed an issue causing a crash every time the HitsDialog popped up

* Fixed an issue causing a crash every time the HitsDialog's confirm button was pressed

* Fixed setCurHits allowing bad values.

* Removed debugPrintScores function from PlayerCharacter.

* Reformatted some code.

* PlayerCharacter now updates curHits when initalizeClass is called.

* Removed unused instance fields from Util.

* Removed a todo.

* Added a getter for the instance field weapons.

* MID-WORK COMMIT - This is to simply save work.

* Weapon of Choice is now checked when making an attack.

* Melee bonus is now properly updated in the GUI.

* Disabled some stuff to disable crashing.

* Changed the textView's id to make it more unique.

* Implemented a working version of the DetailedDialog.

* Removed the WeaponArrayAdapter.

* Updated values in strings.xml

* Fixed values in layout and strings.xml

* Changed layout to simple support layout.

* Added safe checking to event handlers in DetailDialog.

* Added a default constructor for Priest.

* Rearranged constructor args to be fitting with other code.

* Added getAmmo to Util.

* Removed unused imports.

* Made getAmmo static.

* Changed constructors that had RangedWeapons involved in startGear.

* Made the dialog swap out the starting weapon with chosen starting weapon.

* Fixed the error where Centaur would start with weaponOfChoice.

* Made the dialog properly create an instance with filled in values.

* Binded a PlayerCharacter to the newly created instance.

* Modified the listener's interface.

* Made BaseClass serializable.

* Made a rough version of passing character between the dialog and sheet.

* Added throwing knife as a weapon

* Removed System.out statements.

* Added some error handling to the dialog.

* Fixed bug where the class wasn't fully initialized.

* Feature complete, able to transfer newly created character to sheet.

* Removed invalid weapon, "mace".

* Added null handling Noble.

* Added a Club Entry.

* Fixed Noble crash potential.

* Implemented the new dialog for all of the classes.

* Added more error-handling into the code.

* Removed outdated variables.

* Fixed a bug where the CreateCharacter and CharcterSheetFragment would both be visible.

* Moved most of the code to fill in the fragment into a seperate method.

* Removed unused code.

* Allows the active character to be perserved after the character changes.

* Merge branch 'master' of https://github.com/CIS-Extra/mazes_and_minotaurs

# Conflicts:
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/NewCharacter/CreateCharacter.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/rollDice/rollDice.java
#	MazesAndMinotaurs/instapk.log

* Resolved issue with merge.

* Added value for Priest.

* Added handling in case there is no possible starting weapon.

* Added handling for lack of a weapon

* Added handling for the dialog for lack of a weapon as well.

* fixed issue #24, discovered issue #25, and fixed issue #25

* Removed statements related to debuggging.

* Added helper methods,

* Changed the choice weapon spinner to hide if the user selects a Magician.

* Added resIds to Score enum.

* Now have a working implentmention of Noble Heritage.

* Cleaned up some of the code related to Noble creation.

* Added safe checking to doHeritage.

* #27 fixed

* Created DetailedWeaponAdapater

* Changed DeteailedWeaponAdapter to subclass BaseAdapter.

* CreatedlLayout for individual spinner items for DetailedWeaponAdapter

* Exposed some code to make it easier to implement.

* Added the ability to change active weapon. Issue #11 fixed.

* Added handling for null values.

* Fixed #30.

* Simplified SaveAndLoadPerformer

* Changed name to fit with conventions.

* Added layout for character spinner items.

* Added save icon.

* Added action item, "Save Portfolio".

* Added methods to serialize Portfolio.

* Reverted SaveAndLoadPerformer

* Seperated SaveAndLoadPerformer and CharacterSerializer

* Added RuntimeTypeAdapterFactory.

* Fixed with solution located at google/gson#712

* Serialization should finally work as intended aside from issue #34.

* Added ability to handle failed load.

* Labeled certain methods and classes as deprecated

* Added the ability to handle polymorphism in Equipment objects.

* Replaced multiple gson creations with static one(s).

* Created CharacterAdapter

* Added functionality to CharacterAdapter

* Added a character select screen.

* Added a character delete screen.

* The list nows updates when a character is deleted.

* Fixed #34

* Fixed improper melee mod value.

* Armor is now automatically equipped if a class starts with armor.

* Added functionality to save and load EquipmentDB.

* EquipmentDB is now saved on startup.

* EquipmentDB is now saveable.

* Hotfix: Portfolio and EquipmentDB not loaded on startup.

* Created spinner layout for Equipment.

* Added an inventory screen. (Accessable through the Save Sinet button.)

* Moved code related to serialization to its own package.

* Moved equipment strings to util.CommonStrings

* Changed the EquipmentDB to use values from util.CommonStrings.

* Fixed classes to work with EquipmentDB's changes.

* Fixed the rest of the code to work with the changes.

* Added helper methods for EquipmentDB. (Weapon, Armor, Equipment)

* Fixed InventoryAdapter for Equipment Change

* Refactored some code to fix serialization issues. (mWeaponType -> mIsMelee)

* Fixed inventory fragment after the weapon change.

* Added an message for the inventory screen explaining what to do.

* Added resource values for magician classes' talents.

* Magician's talent will now be displayed. (Fixes #14)

* Made getPowerPoints abstract.

* Fixed #38

* Added a method to reset the data.

* Fixed the portfolio reset.

* Added the function to reset the EquipmentDB. Fixed #44

* Added backstack features.

* Fixed #40

* Moved clearBackStack to Util class.

* Added the inventory screen. (Fixed #6)
ThorinSchmidt pushed a commit to CIS-Stars/mazes_and_minotaurs that referenced this issue Nov 10, 2017
* + Changed getCoreStatScore to getScore

* + Modified LevelUp and LevelDown to restore the proper scores rather than calculated scores.
---WARNING---
Changes made in a sleepy state, they may not be implemented properly or effectively.

* Removed the EffectiveLevel property from BaseClass
Removed the updateLevel method
Added an example of getting modifier to CharacterSheet

* + Added methods for saving throws in PlayerCharacter.java
    +getAthleticProwess
    +getDangerEvasion
    +getMysticFortitude
    +getPhysicalVigor
    +getCharisma

* + Added the Equipment functionality to Barbarian
+ Changed some int arguments to use Weapon instead
+ Added some documentation to PlayerCharacter
+ Also fixed some typos in method names in PlayerCharacter.

* + Added the equipment functionality to the PlayerCharacter
    - Weapon Attribute
    - Weapon of Choice checking
+ Added weapon of choice to specialist

* + Fixed more typos
+ Added the initializeClass method to ease the burden of switching classes at first.

* + Changed Portfolio to work with the new method of Character Creation

* + Changed mWeapon to mCurrentWeapon
+ Added getWeapons method to PlayerCharacter
+ Fixed issue where PlayerCharacter wouldn't have a weapon equipped.

* + Made getHitTotal function properly
+ Improved documentation on the PlayerCharacter class

* + Removed initialization from PlayerCharacter's constructor.

* + Added GSON lib.
+ Added Saving Functionality
+ Broken Load Functionality at the moment.

* Fixed loading functionality.

* Added javadoc for SaveAndLoadPerformer

* Finished commit.

* Changed and added methods to the Util class.
* Added javadoc to signature roll(int)
* Added method roll(int, int) with javadoc

Started to add Amazon PlayerCharacter class.

* Finished with Amazon

* Created Centaur (should be ready to implement).

* Fixed bugged gold for Amazon and Barb.

* Created and added Noble
Fixed bug where Barb's weapon of choice would always be set to Barb Axe.

* Added and Created Spearman class.
Added Heroic Heritage to Nobles.

* Added Battle Fortune to Noble.

* Setup project on new PC.
Multiple files changed to resolve errors.

* Fully implemented Centaur.
* Finished up the constructor.

* Fully implemented Thief.

* Created Hunter and fully implemented!

Specialist.java:
* Added Special Talent Method

Thief.java:
* Implemented Special Talent Method

* Moved getSpecialTalent to Specialist.java

* Removed getSpecialTalent from the respective classes.

* Added new values.

* Renamed the values.

* Resolved the TODOs in the code.

* Fixed a typo.

* Removed methods that are inside of the Level Interface, and made getLevelDescription abstract.

* Fixed issue #2.

* Added functionality to Patron.

* Fixed Specialist lacking the Level Descriptions.

* Added the instance field for possibleStartWeapons to BaseClass
Also, added the fully implemented feature into Amazon.

* Updated Barbarian to new format.

* Added the instance field mPossibleWeaponsOfChoice to Warrior.
Made the setter for mWeaponOfChoice check if it is valid.

* Changed how Amazon would validate starting weapon.

* Changed Warrior so it would still weaponOfChoice even if argument wasn't valid.

* Changed Amazon and Barbarian to remove their checking of weaponOfChoice.

* Centaur has been brought up-to-date.

* Noble has been brought up-to-date.

* Spearman has been brought up-to-date.

* Added instance field mPossibleWeaponsOfChoice to Specialist.

* Hunter has been brought up-to-date.

* Thief has been brought up-to-date.

* Added safe-checking to Specialist's setWeaponOfChoice

* All available Magicans classes have been brought up-to-date.

* Fixed bug with App Crash

* Fixed EDC issue where it could return the incorrect values.

* Added Patreon instance field to PlayerCharacter

* Created res/dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created DetailFragment class

* Have a very rough version of the new dialog working.

* Still a rough version but slightly improved.

* Added a blank construcutor for all subclasses of BaseClass.

* Added values into the Classes Enum

* Created a custom adapter.

* Created the layout for weapons in a spinner.

* Finalized the layout of the spinner items

* Added getters

* Changed startGold to startMoney.

* Fixed a massive issue regarding scope in the character package.

* Incomplete update for editing attribute values on the character

* Added the ability to edit the Might score.

* Added the edit ability to the rest of the attribute scores.

* Modified the layout of attribute editing dialog.

* Added the proper values for the labels on the CharacterSheet.

* Adding mCurrentHits functionality.

* Rearranged the layout of the Attribute edit dialog to fix issues of cropping.

* Added safe-checking when getting a value from the dialog.

* Fixed an issue where it would refresh the UI regardless of change.

* Added value checking onto the setCurHits method of PlayerCharacter.

* Moved StatChangeFragment to fragments package.

* Created the HitsChangeFragment class

* Fixed an issue where newInstance wasn't exposed.

* Added the ability to edit hits on the character sheet.

* The user can change hits now on the character sheet.

* Fixed an issue causing a crash every time the HitsDialog popped up

* Fixed an issue causing a crash every time the HitsDialog's confirm button was pressed

* Fixed setCurHits allowing bad values.

* Removed debugPrintScores function from PlayerCharacter.

* Reformatted some code.

* PlayerCharacter now updates curHits when initalizeClass is called.

* Removed unused instance fields from Util.

* Removed a todo.

* Added a getter for the instance field weapons.

* MID-WORK COMMIT - This is to simply save work.

* Weapon of Choice is now checked when making an attack.

* Melee bonus is now properly updated in the GUI.

* Disabled some stuff to disable crashing.

* Changed the textView's id to make it more unique.

* Implemented a working version of the DetailedDialog.

* Removed the WeaponArrayAdapter.

* Updated values in strings.xml

* Fixed values in layout and strings.xml

* Changed layout to simple support layout.

* Added safe checking to event handlers in DetailDialog.

* Added a default constructor for Priest.

* Rearranged constructor args to be fitting with other code.

* Added getAmmo to Util.

* Removed unused imports.

* Made getAmmo static.

* Changed constructors that had RangedWeapons involved in startGear.

* Made the dialog swap out the starting weapon with chosen starting weapon.

* Fixed the error where Centaur would start with weaponOfChoice.

* Made the dialog properly create an instance with filled in values.

* Binded a PlayerCharacter to the newly created instance.

* Modified the listener's interface.

* Made BaseClass serializable.

* Made a rough version of passing character between the dialog and sheet.

* Added throwing knife as a weapon

* Removed System.out statements.

* Added some error handling to the dialog.

* Fixed bug where the class wasn't fully initialized.

* Feature complete, able to transfer newly created character to sheet.

* Removed invalid weapon, "mace".

* Added null handling Noble.

* Added a Club Entry.

* Fixed Noble crash potential.

* Implemented the new dialog for all of the classes.

* Added more error-handling into the code.

* Removed outdated variables.

* Fixed a bug where the CreateCharacter and CharcterSheetFragment would both be visible.

* Moved most of the code to fill in the fragment into a seperate method.

* Removed unused code.

* Allows the active character to be perserved after the character changes.

* Merge branch 'master' of https://github.com/CIS-Extra/mazes_and_minotaurs

# Conflicts:
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/NewCharacter/CreateCharacter.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/rollDice/rollDice.java
#	MazesAndMinotaurs/instapk.log

* Resolved issue with merge.

* Added value for Priest.

* Added handling in case there is no possible starting weapon.

* Added handling for lack of a weapon

* Added handling for the dialog for lack of a weapon as well.

* fixed issue #24, discovered issue #25, and fixed issue #25

* Removed statements related to debuggging.

* Added helper methods,

* Changed the choice weapon spinner to hide if the user selects a Magician.

* Added resIds to Score enum.

* Now have a working implentmention of Noble Heritage.

* Cleaned up some of the code related to Noble creation.

* Added safe checking to doHeritage.

* #27 fixed

* Created DetailedWeaponAdapater

* Changed DeteailedWeaponAdapter to subclass BaseAdapter.

* CreatedlLayout for individual spinner items for DetailedWeaponAdapter

* Exposed some code to make it easier to implement.

* Added the ability to change active weapon. Issue #11 fixed.

* Added handling for null values.

* Fixed #30.

* Simplified SaveAndLoadPerformer

* Changed name to fit with conventions.

* Added layout for character spinner items.

* Added save icon.

* Added action item, "Save Portfolio".

* Added methods to serialize Portfolio.

* Reverted SaveAndLoadPerformer

* Seperated SaveAndLoadPerformer and CharacterSerializer

* Added RuntimeTypeAdapterFactory.

* Fixed with solution located at google/gson#712

* Serialization should finally work as intended aside from issue #34.

* Added ability to handle failed load.

* Labeled certain methods and classes as deprecated

* Added the ability to handle polymorphism in Equipment objects.

* Replaced multiple gson creations with static one(s).

* Created CharacterAdapter

* Added functionality to CharacterAdapter

* Added a character select screen.

* Added a character delete screen.

* The list nows updates when a character is deleted.

* Fixed #34

* Fixed improper melee mod value.

* Armor is now automatically equipped if a class starts with armor.

* Added functionality to save and load EquipmentDB.

* EquipmentDB is now saved on startup.

* EquipmentDB is now saveable.

* Hotfix: Portfolio and EquipmentDB not loaded on startup.

* Created spinner layout for Equipment.

* Added an inventory screen. (Accessable through the Save Sinet button.)

* Moved code related to serialization to its own package.

* Moved equipment strings to util.CommonStrings

* Changed the EquipmentDB to use values from util.CommonStrings.

* Fixed classes to work with EquipmentDB's changes.

* Fixed the rest of the code to work with the changes.

* Added helper methods for EquipmentDB. (Weapon, Armor, Equipment)

* Fixed InventoryAdapter for Equipment Change

* Refactored some code to fix serialization issues. (mWeaponType -> mIsMelee)

* Fixed inventory fragment after the weapon change.

* Added an message for the inventory screen explaining what to do.

* Added resource values for magician classes' talents.

* Magician's talent will now be displayed. (Fixes #14)

* Made getPowerPoints abstract.

* Fixed #38

* Added a method to reset the data.

* Fixed the portfolio reset.

* Added the function to reset the EquipmentDB. Fixed #44

* Added backstack features.

* Fixed #40

* Moved clearBackStack to Util class.

* Added the inventory screen. (Fixed #6)

* Fixed issue of stuff showing after clearing the back stack
JayTSmith added a commit to JayTSmith/mazes_and_minotaurs that referenced this issue Nov 15, 2017
* Added a comparator for AttributeScore(s).

* Updated gradle to 4.1.1.

* Created AttributePriorityDialog along with its layout.
Also, hotfixed some errors in the .xml files.

* Bugfix (#39)

* + Changed getCoreStatScore to getScore

* + Modified LevelUp and LevelDown to restore the proper scores rather than calculated scores.
---WARNING---
Changes made in a sleepy state, they may not be implemented properly or effectively.

* Removed the EffectiveLevel property from BaseClass
Removed the updateLevel method
Added an example of getting modifier to CharacterSheet

* + Added methods for saving throws in PlayerCharacter.java
    +getAthleticProwess
    +getDangerEvasion
    +getMysticFortitude
    +getPhysicalVigor
    +getCharisma

* + Added the Equipment functionality to Barbarian
+ Changed some int arguments to use Weapon instead
+ Added some documentation to PlayerCharacter
+ Also fixed some typos in method names in PlayerCharacter.

* + Added the equipment functionality to the PlayerCharacter
    - Weapon Attribute
    - Weapon of Choice checking
+ Added weapon of choice to specialist

* + Fixed more typos
+ Added the initializeClass method to ease the burden of switching classes at first.

* + Changed Portfolio to work with the new method of Character Creation

* + Changed mWeapon to mCurrentWeapon
+ Added getWeapons method to PlayerCharacter
+ Fixed issue where PlayerCharacter wouldn't have a weapon equipped.

* + Made getHitTotal function properly
+ Improved documentation on the PlayerCharacter class

* + Removed initialization from PlayerCharacter's constructor.

* + Added GSON lib.
+ Added Saving Functionality
+ Broken Load Functionality at the moment.

* Fixed loading functionality.

* Added javadoc for SaveAndLoadPerformer

* Finished commit.

* Changed and added methods to the Util class.
* Added javadoc to signature roll(int)
* Added method roll(int, int) with javadoc

Started to add Amazon PlayerCharacter class.

* Finished with Amazon

* Created Centaur (should be ready to implement).

* Fixed bugged gold for Amazon and Barb.

* Created and added Noble
Fixed bug where Barb's weapon of choice would always be set to Barb Axe.

* Added and Created Spearman class.
Added Heroic Heritage to Nobles.

* Added Battle Fortune to Noble.

* Setup project on new PC.
Multiple files changed to resolve errors.

* Fully implemented Centaur.
* Finished up the constructor.

* Fully implemented Thief.

* Created Hunter and fully implemented!

Specialist.java:
* Added Special Talent Method

Thief.java:
* Implemented Special Talent Method

* Moved getSpecialTalent to Specialist.java

* Removed getSpecialTalent from the respective classes.

* Added new values.

* Renamed the values.

* Resolved the TODOs in the code.

* Fixed a typo.

* Removed methods that are inside of the Level Interface, and made getLevelDescription abstract.

* Fixed issue #2.

* Added functionality to Patron.

* Fixed Specialist lacking the Level Descriptions.

* Added the instance field for possibleStartWeapons to BaseClass
Also, added the fully implemented feature into Amazon.

* Updated Barbarian to new format.

* Added the instance field mPossibleWeaponsOfChoice to Warrior.
Made the setter for mWeaponOfChoice check if it is valid.

* Changed how Amazon would validate starting weapon.

* Changed Warrior so it would still weaponOfChoice even if argument wasn't valid.

* Changed Amazon and Barbarian to remove their checking of weaponOfChoice.

* Centaur has been brought up-to-date.

* Noble has been brought up-to-date.

* Spearman has been brought up-to-date.

* Added instance field mPossibleWeaponsOfChoice to Specialist.

* Hunter has been brought up-to-date.

* Thief has been brought up-to-date.

* Added safe-checking to Specialist's setWeaponOfChoice

* All available Magicans classes have been brought up-to-date.

* Fixed bug with App Crash

* Fixed EDC issue where it could return the incorrect values.

* Added Patreon instance field to PlayerCharacter

* Created res/dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created the layout of dialog_class_selection.xml

* Created DetailFragment class

* Have a very rough version of the new dialog working.

* Still a rough version but slightly improved.

* Added a blank construcutor for all subclasses of BaseClass.

* Added values into the Classes Enum

* Created a custom adapter.

* Created the layout for weapons in a spinner.

* Finalized the layout of the spinner items

* Added getters

* Changed startGold to startMoney.

* Fixed a massive issue regarding scope in the character package.

* Incomplete update for editing attribute values on the character

* Added the ability to edit the Might score.

* Added the edit ability to the rest of the attribute scores.

* Modified the layout of attribute editing dialog.

* Added the proper values for the labels on the CharacterSheet.

* Adding mCurrentHits functionality.

* Rearranged the layout of the Attribute edit dialog to fix issues of cropping.

* Added safe-checking when getting a value from the dialog.

* Fixed an issue where it would refresh the UI regardless of change.

* Added value checking onto the setCurHits method of PlayerCharacter.

* Moved StatChangeFragment to fragments package.

* Created the HitsChangeFragment class

* Fixed an issue where newInstance wasn't exposed.

* Added the ability to edit hits on the character sheet.

* The user can change hits now on the character sheet.

* Fixed an issue causing a crash every time the HitsDialog popped up

* Fixed an issue causing a crash every time the HitsDialog's confirm button was pressed

* Fixed setCurHits allowing bad values.

* Removed debugPrintScores function from PlayerCharacter.

* Reformatted some code.

* PlayerCharacter now updates curHits when initalizeClass is called.

* Removed unused instance fields from Util.

* Removed a todo.

* Added a getter for the instance field weapons.

* MID-WORK COMMIT - This is to simply save work.

* Weapon of Choice is now checked when making an attack.

* Melee bonus is now properly updated in the GUI.

* Disabled some stuff to disable crashing.

* Changed the textView's id to make it more unique.

* Implemented a working version of the DetailedDialog.

* Removed the WeaponArrayAdapter.

* Updated values in strings.xml

* Fixed values in layout and strings.xml

* Changed layout to simple support layout.

* Added safe checking to event handlers in DetailDialog.

* Added a default constructor for Priest.

* Rearranged constructor args to be fitting with other code.

* Added getAmmo to Util.

* Removed unused imports.

* Made getAmmo static.

* Changed constructors that had RangedWeapons involved in startGear.

* Made the dialog swap out the starting weapon with chosen starting weapon.

* Fixed the error where Centaur would start with weaponOfChoice.

* Made the dialog properly create an instance with filled in values.

* Binded a PlayerCharacter to the newly created instance.

* Modified the listener's interface.

* Made BaseClass serializable.

* Made a rough version of passing character between the dialog and sheet.

* Added throwing knife as a weapon

* Removed System.out statements.

* Added some error handling to the dialog.

* Fixed bug where the class wasn't fully initialized.

* Feature complete, able to transfer newly created character to sheet.

* Removed invalid weapon, "mace".

* Added null handling Noble.

* Added a Club Entry.

* Fixed Noble crash potential.

* Implemented the new dialog for all of the classes.

* Added more error-handling into the code.

* Removed outdated variables.

* Fixed a bug where the CreateCharacter and CharcterSheetFragment would both be visible.

* Moved most of the code to fill in the fragment into a seperate method.

* Removed unused code.

* Allows the active character to be perserved after the character changes.

* Merge branch 'master' of https://github.com/CIS-Extra/mazes_and_minotaurs

# Conflicts:
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/CharacterSheetFragment.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/NewCharacter/CreateCharacter.java
#	MazesAndMinotaurs/app/src/main/java/com/example/cis/mazeminotaurs/rollDice/rollDice.java
#	MazesAndMinotaurs/instapk.log

* Resolved issue with merge.

* Added value for Priest.

* Added handling in case there is no possible starting weapon.

* Added handling for lack of a weapon

* Added handling for the dialog for lack of a weapon as well.

* fixed issue #24, discovered issue #25, and fixed issue #25

* Removed statements related to debuggging.

* Added helper methods,

* Changed the choice weapon spinner to hide if the user selects a Magician.

* Added resIds to Score enum.

* Now have a working implentmention of Noble Heritage.

* Cleaned up some of the code related to Noble creation.

* Added safe checking to doHeritage.

* #27 fixed

* Created DetailedWeaponAdapater

* Changed DeteailedWeaponAdapter to subclass BaseAdapter.

* CreatedlLayout for individual spinner items for DetailedWeaponAdapter

* Exposed some code to make it easier to implement.

* Added the ability to change active weapon. Issue #11 fixed.

* Added handling for null values.

* Fixed #30.

* Simplified SaveAndLoadPerformer

* Changed name to fit with conventions.

* Added layout for character spinner items.

* Added save icon.

* Added action item, "Save Portfolio".

* Added methods to serialize Portfolio.

* Reverted SaveAndLoadPerformer

* Seperated SaveAndLoadPerformer and CharacterSerializer

* Added RuntimeTypeAdapterFactory.

* Fixed with solution located at google/gson#712

* Serialization should finally work as intended aside from issue #34.

* Added ability to handle failed load.

* Labeled certain methods and classes as deprecated

* Added the ability to handle polymorphism in Equipment objects.

* Replaced multiple gson creations with static one(s).

* Created CharacterAdapter

* Added functionality to CharacterAdapter

* Added a character select screen.

* Added a character delete screen.

* The list nows updates when a character is deleted.

* Fixed #34

* Fixed improper melee mod value.

* Armor is now automatically equipped if a class starts with armor.

* Added functionality to save and load EquipmentDB.

* EquipmentDB is now saved on startup.

* EquipmentDB is now saveable.

* Hotfix: Portfolio and EquipmentDB not loaded on startup.

* Created spinner layout for Equipment.

* Added an inventory screen. (Accessable through the Save Sinet button.)

* Moved code related to serialization to its own package.

* Moved equipment strings to util.CommonStrings

* Changed the EquipmentDB to use values from util.CommonStrings.

* Fixed classes to work with EquipmentDB's changes.

* Fixed the rest of the code to work with the changes.

* Added helper methods for EquipmentDB. (Weapon, Armor, Equipment)

* Fixed InventoryAdapter for Equipment Change

* Refactored some code to fix serialization issues. (mWeaponType -> mIsMelee)

* Fixed inventory fragment after the weapon change.

* Added an message for the inventory screen explaining what to do.

* Added resource values for magician classes' talents.

* Magician's talent will now be displayed. (Fixes #14)

* Made getPowerPoints abstract.

* Fixed #38

* Added a method to reset the data.

* Fixed the portfolio reset.

* Added the function to reset the EquipmentDB. Fixed #44

* Added backstack features.

* Fixed #40

* Moved clearBackStack to Util class.

* Added the inventory screen. (Fixed #6)

* Fixed issue of stuff showing after clearing the back stack

* Added ids to each of the attribute spinners.

* Made Score serializable.

* Implemented a rough version of the AttributeScorePriority dialog into createCharacter.
* Reroll was also implemented into the createCharacter.

* Added a contains method to Util.

* Added new value to CommonStrings

* Fixed issue where the attributes wouldn't be ordered properly when the
AttributePriorityDialog was restored.

* Fixed #51

* Cleaned up the AttributePriorityDialog visually. (Fixed #52)

* The elements now go directly into the adapter. (Fixed #51)
ML23KE added a commit to ML23KE/gson that referenced this issue Sep 6, 2018
- Serialization issue with RuntimeTypeAdapterFactory
- like @ultraon already stated in google#712 "after serialization root object 'type' field is not injected, for inner object 'type' fields are added"
t-oster added a commit to t-oster/gson that referenced this issue Jun 27, 2022
Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization.
The fix from google#712 (comment) works. No idea why this is not merged yet.
t-oster added a commit to t-oster/gson that referenced this issue Jun 28, 2022
Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization.
The fix from google#712 (comment) works. No idea why this is not merged yet.
t-oster added a commit to t-oster/gson that referenced this issue Jun 28, 2022
Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization.
The fix from google#712 (comment) works. No idea why this is not merged yet.
t-oster added a commit to t-oster/gson that referenced this issue Jun 29, 2022
Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization.
The fix from google#712 (comment) works. No idea why this is not merged yet.
eamonnmcmanus pushed a commit that referenced this issue Jul 21, 2022
* Change the RuntimeTypeAdapterFactoryTest, so it fails because of #712

* Fix RuntimeTypeAdapterFactory

Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization.
The fix from #712 (comment) works. No idea why this is not merged yet.
@Marcono1234
Copy link
Collaborator

#2160 added a method for solving this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants