[
  {
    "path": ".codebeatignore",
    "content": "preferenceholder-lib/src/androidTest/**\npreferenceholder-lib/src/main/java/com/marcinmoskala/kotlinpreferences/PreferenceHolder.kt\npreferenceholder-lib/src/main/java/com/marcinmoskala/kotlinpreferences/PreferenceHolderApplication.kt\nsample/**"
  },
  {
    "path": ".gitignore",
    "content": "*.iml\n.gradle\n/local.properties\n/.idea/*\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: android\njdk: oraclejdk8\n\nandroid:\n  components:\n    - tools\n    - platform-tools\n    - build-tools-27.0.1\n    - android-27\n    - android-22\n    - extra-android-m2repository\n    - sys-img-armeabi-v7a-android-22\n\njdk:\n  - oraclejdk8\n\nsudo: true\n\nbefore_script:\n  - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a\n  - emulator -avd test -no-skin -no-audio -no-window &\n  - android-wait-for-emulator\n  - sleep 10\n  - adb shell input keyevent 82\n\nenv:\n  matrix:\n    - TEST=:preferenceholder:connectedDebugAndroidTest\n    - TEST=:preferenceholder-gson-serializer:connectedDebugAndroidTest\n\nscript:\n  - ./gradlew $TEST -i\n\nbranches:\n  only:\n  - master\n  - stable\n\ncache:\n  directories:\n    - $HOME/.m2\n    - $HOME/.gradle"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# PreferenceHolder\nKotlin Android Library, that makes preference usage simple and fun.\n\n[![](https://jitpack.io/v/com.MarcinMoskala/PreferenceHolder.svg)](https://jitpack.io/#com.MarcinMoskala/PreferenceHolder)[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Build Status](https://travis-ci.org/MarcinMoskala/PreferenceHolder.svg?branch=master)](https://travis-ci.org/MarcinMoskala/PreferenceHolder)\n[![codebeat badge](https://codebeat.co/badges/035647e2-1a10-48b8-80ae-e6a02c5c0ded)](https://codebeat.co/projects/github-com-marcinmoskala-preferenceholder-master)\n[![Analytics](https://ga-beacon.appspot.com/UA-92159206-8/main-page?pixel)](https://github.com/MarcinMoskala/PreferenceHolder)\n[![Analytics](https://ga-beacon.appspot.com/UA-92159206-7/main-page?pixel)](https://github.com/MarcinMoskala/PreferenceHolder)\n\nTo stay up-to-date with news about library [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40marcinmoskala)](https://twitter.com/marcinmoskala?ref_src=twsrc%5Etfw)\n\nThis library is younger brother of [KotlinPreferences](https://github.com/MarcinMoskala/KotlinPreferences).\n\nWith PreferenceHolder, you can define different preference fields this way:\n\n```kotlin\nobject Pref: PreferenceHolder() {\n    var canEatPie: Boolean by bindToPreferenceField(true)\n}\n```\n\nAnd use it this way:\n\n```kotlin\nif(Pref.canEatPie) //...\n```\n\nHere are other preference definition examples: (see [full example](https://github.com/MarcinMoskala/PreferenceHolder/blob/master/kotlinpreferences-lib/src/androidTest/java/com/marcinmoskala/kotlinpreferences/ExampleConfig.kt) and [usage](https://github.com/MarcinMoskala/PreferenceHolder/tree/master/kotlinpreferences-lib/src/androidTest/java/com/marcinmoskala/kotlinpreferences))\n\n```kotlin\nobject UserPref: PreferenceHolder() {\n    var canEatPie: Boolean by bindToPreferenceField(true)\n    var allPieInTheWorld: Long by bindToPreferenceField(0)\n\n    var isMonsterKiller: Boolean? by bindToPreferenceFieldNullable()\n    var monstersKilled: Int? by bindToPreferenceFieldNullable()\n    \n    // Property with backup is reading stored value in the first usage, \n    // and saving it, in background, each time it is changed.\n    var experience: Float? by bindToPropertyWithBackup(-1.0F) \n    var className: String? by bindToPropertyWithBackupNullable()\n\n    // Any type can used if serializer is set. See: Gson serialization\n    var character: Character? by bindToPreferenceFieldNullable()\n    var savedGame: Game? by bindToPreferenceFieldNullable()\n\n    // Single level collections are also supported if serializer is set. See: Gson serialization\n    var longList: Map<Int, Long> by bindToPreferenceField(mapOf(0 to 12L, 10 to 143L))\n    var propTest: List<Character>? by bindToPropertyWithBackupNullable()\n    var elemTest: Set<Elems> by bindToPreferenceField(setOf(Elems.Elem1, Elems.Elem3))\n}\n```\n\nThere must be application Context added to PreferenceHolder companion object. Example:\n\n```kotlin\nclass App : Application() {\n\n    override fun onCreate() {\n        super.onCreate()\n        PreferenceHolder.setContext(applicationContext)\n    }\n}\n```\n\nIt it suggested to do it in project Application class. As an alternative, PreferenceHolderApplication can also be added as a name of an application in AndroidManifest: ([example](https://github.com/MarcinMoskala/PreferenceHolder/blob/master/sample/src/main/AndroidManifest.xml#L12))\n\n```\nandroid:name=\"com.marcinmoskala.kotlinpreferences.PreferenceHolderApplication\"\n```\n\n## Unit testing components\n\nLibrary also include test mode:\n\n```\nPreferenceHolder.testingMode = true\n```\n\nWhen it is turned on, then all properties are acting just like normal properties without binding to preference field. This allows to make unit tests to presenters and to use cases that are using instance of PreferenceHolder.\n\n## Install\n\nTo add PreferenceHolder to the project, add to build.gradle file:\n\n```groovy\ndependencies {\n    compile \"com.marcinmoskala.PreferenceHolder:preferenceholder:1.51\"\n}\n```\n\nWhile library is located on JitPack, remember to add to module build.gradle (unless you already have it):\n\n```groovy\nrepositories {\n    maven { url 'https://jitpack.io' }\n}\n```\n\n## Gson serialization\n\nTo use Gson serializer, we need to add following dependency:\n\n```groovy\ndependencies {\n    compile \"com.marcinmoskala.PreferenceHolder:preferenceholder-gson-serializer:1.51\"\n}\n```\n\nAnd specify `GsonSerializer` as `PreferenceHolder` serializer: \n\n```kotlin\nPreferenceHolder.serializer = GsonSerializer(Gson())\n```\n\nSince then, we can use all types, even one not supported by SharedPreference (like custom objects `Character` and `Game`, or collections)\n\n## Other libraries\n\nIf you like it, remember to leave the star and check out my other libraries:\n * [ActivityStarter](https://github.com/MarcinMoskala/ActivityStarter/blob/master/README.md) - Simple Android Library, that provides easy way to start and save state of Activities, Fragments, Services and Receivers with arguments.\n * [ArcSeekBar](https://github.com/MarcinMoskala/ArcSeekBar) - Good looking curved Android SeekBar\n * [VideoPlayView](https://github.com/MarcinMoskala/VideoPlayView) - Custom Android view with video player, loader and placeholder image\n * [KotlinAndroidViewBindings](https://github.com/MarcinMoskala/KotlinAndroidViewBindings) - Bindings for properties with simple Kotlin types (Boolean, String) to layout traits (visibility, text).\n\nLicense\n-------\n\n    Copyright 2017 Marcin Moskała\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n"
  },
  {
    "path": "build.gradle",
    "content": "buildscript {\n    ext.kotlin_version = '1.2.0-rc-84'\n    repositories {\n        google()\n        jcenter()\n        maven { url \"http://dl.bintray.com/kotlin/kotlin-eap-1.2\" }\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.0.0'\n        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n    }\n}\n\nallprojects {\n    repositories {\n        google()\n        jcenter()\n        maven { url 'https://jitpack.io' }\n        maven { url \"http://dl.bintray.com/kotlin/kotlin-eap-1.2\" }\n    }\n}\n\nrepositories {\n    mavenCentral()\n}"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Tue Nov 28 16:54:24 CET 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-4.1-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\norg.gradle.jvmargs=-Xmx1536m\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "preferenceholder/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "preferenceholder/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'kotlin-android'\n\napply plugin: 'com.github.dcendents.android-maven'\n\ngroup='com.marcinmoskala'\n\nandroid {\n    compileSdkVersion 27\n    buildToolsVersion '27.0.1'\n\n    defaultConfig {\n        minSdkVersion 14\n        targetSdkVersion 27\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n}\n\ndependencies {\n    compile \"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version\"\n\n    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n    testCompile 'junit:junit:4.12'\n}\nrepositories {\n    mavenCentral()\n}\n\n// Fancy test print\ntasks.withType(Test) {\n    testLogging {\n        // set options for log level LIFECYCLE\n        events \"passed\", \"skipped\", \"failed\", \"standardOut\"\n        showExceptions true\n        exceptionFormat \"full\"\n        showCauses true\n        showStackTraces true\n\n        // set options for log level DEBUG and INFO\n        debug {\n            events \"started\", \"passed\", \"skipped\", \"failed\", \"standardOut\", \"standardError\"\n            exceptionFormat \"full\"\n        }\n        info.events = debug.events\n        info.exceptionFormat = debug.exceptionFormat\n\n        afterSuite { desc, result ->\n            if (!desc.parent) { // will match the outermost suite\n                def output = \"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)\"\n                def startItem = '|  ', endItem = '  |'\n                def repeatLength = startItem.length() + output.length() + endItem.length()\n                println('\\n' + ('-' * repeatLength) + '\\n' + startItem + output + endItem + '\\n' + ('-' * repeatLength))\n            }\n        }\n    }\n}\n\ntask sourcesJar(type: Jar) {\n    from android.sourceSets.main.java.srcDirs\n    classifier = 'sources'\n}\n\nartifacts {\n    archives sourcesJar\n}\n\ninstall {\n    repositories.mavenInstaller {\n        pom.project {\n            licenses {\n                license {\n                    name 'The Apache Software License, Version 2.0'\n                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'\n                    distribution 'repo'\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "preferenceholder/proguard-rules.pro",
    "content": ""
  },
  {
    "path": "preferenceholder/src/androidTest/java/com/marcinmoskala/kotlinpreferences/BaseTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.support.test.InstrumentationRegistry\n\nopen class BaseTest {\n\n    init {\n        PreferenceHolder.setContext(InstrumentationRegistry.getTargetContext())\n        PreferenceHolder.serializer = null\n        TestPreferences.clear()\n    }\n}"
  },
  {
    "path": "preferenceholder/src/androidTest/java/com/marcinmoskala/kotlinpreferences/CleaningTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.className\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.experience\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.isMonsterKiller\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.monstersKilled\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.numberOfHahaInLough\nimport org.junit.Assert\nimport org.junit.Assert.assertEquals\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass CleaningTest: BaseTest() {\n\n    @Test\n    fun afterCleaningPropertiesAreSetToDefaultTest() {\n        TestPreferences.canEatPie = false\n        TestPreferences.pieBaked = 1000\n        TestPreferences.allPieInTheWorld = 9090\n        TestPreferences.pieEaten = 190F\n        TestPreferences.bestPieName = \"Marcin\"\n        TestPreferences.clear()\n        assertEquals(true, TestPreferences.canEatPie)\n        assertEquals(5, TestPreferences.pieBaked)\n        assertEquals(-1L, TestPreferences.allPieInTheWorld)\n        assertEquals(0.0F, TestPreferences.pieEaten)\n        assertEquals(\"Pie\", TestPreferences.bestPieName)\n    }\n\n    @Test\n    fun afterCleaningNullablePropertiesAreSetToNullTest() {\n        TestPreferences.isMonsterKiller = false\n        TestPreferences.monstersKilled = 1000\n        TestPreferences.numberOfHahaInLough = 9090\n        TestPreferences.experience = 190F\n        TestPreferences.className = \"Marcin\"\n        TestPreferences.clear()\n        assertEquals(null, isMonsterKiller)\n        assertEquals(null, monstersKilled)\n        assertEquals(null, numberOfHahaInLough)\n        assertEquals(null, experience)\n        assertEquals(null, className)\n    }\n\n    @Test\n    fun cleaningIsOnlyApplyedToSinglePrefClass() {\n        TestPreferences.isMonsterKiller = false\n        TestPreferences.monstersKilled = 1000\n        assertEquals(false, isMonsterKiller)\n        assertEquals(1000, monstersKilled)\n    }\n}\n"
  },
  {
    "path": "preferenceholder/src/androidTest/java/com/marcinmoskala/kotlinpreferences/ExampleConfig.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nobject TestPreferences: PreferenceHolder() {\n    var canEatPie: Boolean by bindToPreferenceField(true)\n    var pieBaked: Int by bindToPreferenceField(5)\n    var allPieInTheWorld: Long by bindToPreferenceField(-1L)\n    var pieEaten: Float by bindToPreferenceField(0.0F)\n    var bestPieName: String by bindToPreferenceField(\"Pie\")\n\n    var isMonsterKiller: Boolean? by bindToPreferenceFieldNullable()\n    var monstersKilled: Int? by bindToPreferenceFieldNullable()\n    var numberOfHahaInLough: Long? by bindToPreferenceFieldNullable()\n    var experience: Float? by bindToPreferenceFieldNullable()\n    var className: String? by bindToPreferenceFieldNullable()\n}"
  },
  {
    "path": "preferenceholder/src/androidTest/java/com/marcinmoskala/kotlinpreferences/PreferenceFieldNullableTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.className\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.experience\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.isMonsterKiller\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.monstersKilled\nimport com.marcinmoskala.kotlinpreferences.TestPreferences.numberOfHahaInLough\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass PreferenceFieldNullableTest: BaseTest() {\n\n    @Test\n    fun booleanDefaultChangeTest() {\n        testValues(TestPreferences::isMonsterKiller, null, true, false, true, null)\n    }\n\n    @Test\n    fun intDefaultChangeTest() {\n        testValues(TestPreferences::monstersKilled, null, 10, 0, 10, -19)\n    }\n\n    @Test\n    fun longDefaultChangeTest() {\n        testValues(TestPreferences::numberOfHahaInLough, null, 10L, 0L, 100L)\n    }\n\n    @Test\n    fun floatDefaultChangeTest() {\n        testValues(TestPreferences::experience, null, 10F, 0F, 100F)\n    }\n\n    @Test\n    fun stringDefaultChangeTest() {\n        testValues(TestPreferences::className, null, \"BlueberryPie\", \"SuperPie\")\n    }\n}\n"
  },
  {
    "path": "preferenceholder/src/androidTest/java/com/marcinmoskala/kotlinpreferences/PreferenceFieldTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.support.test.runner.AndroidJUnit4\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass PreferenceFieldTest: BaseTest() {\n\n    @Test\n    fun booleanDefaultChangeTest() {\n        testValues(TestPreferences::canEatPie, true, false, true, false)\n    }\n\n    @Test\n    fun intDefaultChangeTest() {\n        testValues(TestPreferences::pieBaked, 5, 10, 0, 10, -19)\n    }\n\n    @Test\n    fun longDefaultChangeTest() {\n        testValues(TestPreferences::allPieInTheWorld, -1L, 10L, 0L, 100L)\n    }\n\n    @Test\n    fun floatDefaultChangeTest() {\n        testValues(TestPreferences::pieEaten, 0.0F, 10F, 0.06F, 100F)\n    }\n\n    @Test\n    fun stringDefaultChangeTest() {\n        testValues(TestPreferences::bestPieName, \"Pie\", \"BlueberryPie\", \"SuperPie\")\n    }\n}\n"
  },
  {
    "path": "preferenceholder/src/androidTest/java/com/marcinmoskala/kotlinpreferences/TestUtills.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport org.junit.Assert\nimport kotlin.reflect.KMutableProperty0\n\nfun <T> testValues(property: KMutableProperty0<T>, start: T?, vararg values: T) {\n    Assert.assertEquals(start, property.get())\n    values.forEach {\n        property.set(it)\n        Assert.assertEquals(it, property.get())\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"com.marcinmoskala.kotlinpreferences\" />"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/PreferenceHolder.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.content.Context\nimport android.content.SharedPreferences\nimport android.preference.PreferenceManager\nimport com.marcinmoskala.kotlinpreferences.bindings.*\nimport java.lang.reflect.Type\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KClass\nimport kotlin.reflect.KProperty\nimport kotlin.reflect.KProperty1\nimport kotlin.reflect.full.declaredMemberProperties\nimport kotlin.reflect.jvm.isAccessible\n\nabstract class PreferenceHolder {\n\n    protected inline fun <reified T : Any> bindToPreferenceField(default: T, key: String? = null, caching: Boolean = true): ReadWriteProperty<PreferenceHolder, T>\n            = bindToPreferenceField(T::class, object : TypeToken<T>() {}.type, default, key, caching)\n\n    protected inline fun <reified T : Any> bindToPreferenceFieldNullable(key: String? = null, caching: Boolean = true): ReadWriteProperty<PreferenceHolder, T?>\n            = bindToPreferenceFieldNullable(T::class, object : TypeToken<T>() {}.type, key, caching)\n\n    protected fun <T : Any> bindToPreferenceField(clazz: KClass<T>, type: Type, default: T, key: String?, caching: Boolean = true): ReadWriteProperty<PreferenceHolder, T>\n            = if (caching) PreferenceFieldBinderCaching(clazz, type, default, key) else PreferenceFieldBinder(clazz, type, default, key)\n\n    protected fun <T : Any> bindToPreferenceFieldNullable(clazz: KClass<T>, type: Type, key: String?, caching: Boolean = true): ReadWriteProperty<PreferenceHolder, T?>\n            = if (caching) PreferenceFieldBinderNullableCaching(clazz, type, key) else PreferenceFieldBinderNullable(clazz, type, key)\n\n    /**\n     *  Function used to clear all SharedPreference and PreferenceHolder data. Useful especially\n     *  during tests or when implementing Logout functionality.\n     */\n    fun clear() {\n        forEachDelegate { delegate, property ->\n            delegate.clear(this, property)\n        }\n    }\n\n    fun clearCache() {\n        forEachDelegate { delegate, property ->\n            delegate.clearCache()\n        }\n    }\n\n    private fun forEachDelegate(f: (Clearable, KProperty<*>) -> Unit) {\n        val pref = preferences ?: return\n        val properties = this::class.declaredMemberProperties\n                .filterIsInstance<KProperty1<SharedPreferences, *>>()\n        for (p in properties) {\n            val prevAccessible = p.isAccessible\n            if (!prevAccessible) p.isAccessible = true\n            val delegate = p.getDelegate(pref)\n            if (delegate is Clearable) f(delegate, p)\n            p.isAccessible = prevAccessible\n        }\n    }\n\n    companion object {\n\n        /**\n         *  This property should be used to set serializer to use types that are not supported by SharedPreference.\n         */\n        var serializer: Serializer? = null\n\n        /**\n         *  When testing mode is turned on, then there is no need to provide Context, and all bindings\n         *  are acting just like standard Kotln fields. If we then need to mock some situation then all\n         *  we need to do is to set values on Preferences. Example:\n         *\n         *  fun newUserCreationTest() {\n         *      PreferenceHolder.testingMode = true\n         *      UserPreferences.user = null\n         *      val mockedView = object : UserView {\n         *         fun getName() = \"Marcin\"\n         *         gun getSurname() = \"Moskala\"\n         *      }\n         *      val presenter = UserPresenter(mockedView)\n         *      presenter.createUser()\n         *      assert(User(\"Marcin\", \"Moskala\"), UserPreferences.user)\n         *  }\n         */\n        var testingMode: Boolean = false\n\n        /**\n         *  It should be used to set ApplicationContext on project Application class. Only case when\n         *  it could be ommitted is when testingMode is turned on.\n         */\n        fun setContext(context: Context) {\n            preferences = PreferenceManager.getDefaultSharedPreferences(context)\n        }\n\n        private const val noPreferencesSetErrorText = \"No preferences in PreferenceHolder instance. Add in Application class PreferenceHolder.setContext(applicationContext) or make PreferenceHolderApplication to be your project application class (android:name field in AndroidManifest).\"\n\n        internal var preferences: SharedPreferences? = null\n\n        internal fun getPreferencesOrThrowError(): SharedPreferences = PreferenceHolder.preferences ?: throw Error(noPreferencesSetErrorText)\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/PreferenceHolderApplication.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.app.Application\n\nclass PreferenceHolderApplication : Application() {\n    override fun onCreate() {\n        super.onCreate()\n        PreferenceHolder.setContext(applicationContext)\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/Serializer.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport java.lang.reflect.Type\n\ninterface Serializer {\n\n    fun serialize(toSerialize: Any?): String?\n\n    fun deserialize(serialized: String?, type: Type): Any?\n}\n"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/TypeToken.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport java.io.Serializable\nimport java.lang.reflect.GenericArrayType\nimport java.lang.reflect.Modifier\nimport java.lang.reflect.ParameterizedType\nimport java.lang.reflect.Type\nimport java.lang.reflect.WildcardType\nimport java.util.Arrays\n\nopen class TypeToken<T> protected constructor() {\n\n    private val superclass = javaClass.genericSuperclass as ParameterizedType\n    val type: Type = canonicalize(superclass.actualTypeArguments[0])\n\n    private class ParameterizedTypeImpl(ownerType: Type?, rawType: Type, vararg typeArguments: Type) : ParameterizedType, Serializable {\n        private val ownerType: Type?\n        private val rawType: Type\n        private val typeArguments: List<Type>\n\n        init {\n            // require an owner type if the raw type needs it\n            if (rawType is Class<*>) {\n                val isStaticOrTopLevelClass = Modifier.isStatic(rawType.modifiers) || rawType.enclosingClass == null\n                checkArgument(ownerType != null || isStaticOrTopLevelClass)\n            }\n\n            this.ownerType = if (ownerType == null) null else canonicalize(ownerType)\n            this.rawType = canonicalize(rawType)\n            this.typeArguments = typeArguments.map { canonicalize(it) }\n        }\n\n        override fun getActualTypeArguments() = typeArguments.toTypedArray()\n\n        override fun getRawType() = rawType\n\n        override fun getOwnerType() = ownerType\n\n        override fun toString(): String {\n            val stringBuilder = StringBuilder(30 * (typeArguments.size + 1))\n            stringBuilder.append(typeToString(rawType))\n\n            if (typeArguments.isEmpty()) {\n                return stringBuilder.toString()\n            }\n\n            stringBuilder.append(\"<\").append(typeToString(typeArguments[0]))\n            for (i in 1 until typeArguments.size) {\n                stringBuilder.append(\", \").append(typeToString(typeArguments[i]))\n            }\n            return stringBuilder.append(\">\").toString()\n        }\n    }\n\n    private class GenericArrayTypeImpl(componentType: Type) : GenericArrayType, Serializable {\n\n        private val componentType: Type = canonicalize(componentType)\n\n        override fun getGenericComponentType() = componentType\n\n        override fun toString() = typeToString(componentType) + \"[]\"\n    }\n\n    private class WildcardTypeImpl(upperBounds: Array<Type>, lowerBounds: Array<Type>) : WildcardType, Serializable {\n        private val upperBound: Type\n        private val lowerBound: Type?\n\n        init {\n            checkArgument(lowerBounds.size <= 1)\n            checkArgument(upperBounds.size == 1)\n\n            if (lowerBounds.size == 1) {\n                checkNotNull(lowerBounds[0])\n                checkNotPrimitive(lowerBounds[0])\n                checkArgument(upperBounds[0] === Any::class.java)\n                this.lowerBound = canonicalize(lowerBounds[0])\n                this.upperBound = Any::class.java\n\n            } else {\n                checkNotNull(upperBounds[0])\n                checkNotPrimitive(upperBounds[0])\n                this.lowerBound = null\n                this.upperBound = canonicalize(upperBounds[0])\n            }\n        }\n\n        override fun getUpperBounds() = arrayOf(upperBound)\n\n        override fun getLowerBounds() =\n                if (lowerBound != null) arrayOf(lowerBound) else EMPTY_TYPE_ARRAY\n\n        override fun toString(): String = when {\n            lowerBound != null -> \"? super \" + typeToString(lowerBound)\n            upperBound === Any::class.java -> \"?\"\n            else -> \"? extends \" + typeToString(upperBound)\n        }\n    }\n\n    companion object {\n\n        internal val EMPTY_TYPE_ARRAY = arrayOf<Type>()\n\n        internal fun canonicalize(type: Type): Type = if (type is Class<*>) {\n            if (type.isArray) GenericArrayTypeImpl(canonicalize(type.componentType)) else type\n        } else if (type is ParameterizedType) {\n            ParameterizedTypeImpl(type.ownerType, type.rawType, *type.actualTypeArguments)\n        } else if (type is GenericArrayType) {\n            GenericArrayTypeImpl(type.genericComponentType)\n        } else if (type is WildcardType) {\n            WildcardTypeImpl(type.upperBounds, type.lowerBounds)\n        } else {\n            type\n        }\n\n        internal fun typeToString(type: Type): String {\n            return if (type is Class<*>) type.name else type.toString()\n        }\n\n        internal fun checkNotPrimitive(type: Type) {\n            checkArgument(type !is Class<*> || !type.isPrimitive)\n        }\n\n        internal fun <T> checkNotNull(obj: T?): T = if (obj != null) obj else throw NullPointerException()\n\n        internal fun checkArgument(condition: Boolean) {\n            if (!condition) throw IllegalArgumentException()\n        }\n    }\n}\n"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/Clearable.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport kotlin.reflect.KProperty\n\ninterface Clearable {\n    fun clear(thisRef: PreferenceHolder, property: KProperty<*>)\n    fun clearCache()\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/Errors.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nobject Errors {\n    val serializerNotSet = \"Serializer needs to be set if you want to use custom types\"\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/GetKey.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nimport kotlin.reflect.KProperty\n\ninternal fun getKey(keySet: String?, property: KProperty<*>) = keySet ?: \"${property.name}Key\"\n"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/PreferenceFieldBinder.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nimport android.content.SharedPreferences\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.getPreferencesOrThrowError\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.testingMode\nimport java.lang.reflect.Type\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KClass\nimport kotlin.reflect.KProperty\n\ninternal class PreferenceFieldBinder<T : Any>(\n        private val clazz: KClass<T>,\n        private val type: Type,\n        private val default: T,\n        private val key: String?\n) : ReadWriteProperty<PreferenceHolder, T>, Clearable {\n\n    override fun clear(thisRef: PreferenceHolder, property: KProperty<*>) {\n        setValue(thisRef, property, default)\n    }\n\n    override fun clearCache() {\n    }\n\n    var field: T? = null\n\n    override operator fun getValue(thisRef: PreferenceHolder, property: KProperty<*>): T = when {\n        testingMode -> field ?: default\n        else -> readValue(property)\n    }\n\n    override fun setValue(thisRef: PreferenceHolder, property: KProperty<*>, value: T) {\n        if (testingMode) {\n            if (value == field) return\n            field = value\n        } else {\n            saveNewValue(property, value)\n        }\n    }\n\n    private fun saveNewValue(property: KProperty<*>, value: T) {\n        val pref = getPreferencesOrThrowError()\n        pref.edit().apply { putValue(clazz, value, getKey(key, property)) }.apply()\n    }\n\n    private fun readValue(property: KProperty<*>): T {\n        val pref = getPreferencesOrThrowError()\n        return pref.getValue(property)\n    }\n\n    private fun SharedPreferences.getValue(property: KProperty<*>): T {\n        val key = getKey(key, property)\n        return getFromPreference(clazz, type, default, key) as T\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/PreferenceFieldBinderCaching.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nimport android.content.SharedPreferences\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.getPreferencesOrThrowError\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.testingMode\nimport java.lang.reflect.Type\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KClass\nimport kotlin.reflect.KProperty\n\ninternal class PreferenceFieldBinderCaching<T : Any>(\n        private val clazz: KClass<T>,\n        private val type: Type,\n        private val default: T,\n        private val key: String?\n) : ReadWriteProperty<PreferenceHolder, T>, Clearable {\n\n    override fun clear(thisRef: PreferenceHolder, property: KProperty<*>) {\n        setValue(thisRef, property, default)\n    }\n\n    override fun clearCache() {\n        field = null\n    }\n\n    var field: T? = null\n\n    override operator fun getValue(thisRef: PreferenceHolder, property: KProperty<*>): T = when {\n        testingMode -> field ?: default\n        else -> readValue(property)\n    }\n\n    override fun setValue(thisRef: PreferenceHolder, property: KProperty<*>, value: T) {\n        if (value == field) return\n        field = value\n        if (!testingMode) saveNewValue(property, value)\n    }\n\n    private fun saveNewValue(property: KProperty<*>, value: T) {\n        val pref = getPreferencesOrThrowError()\n        pref.edit().apply { putValue(clazz, value, getKey(key, property)) }.apply()\n    }\n\n    private fun readValue(property: KProperty<*>): T {\n        val pref = getPreferencesOrThrowError()\n        return pref.getValue(property)\n    }\n\n    private fun SharedPreferences.getValue(property: KProperty<*>): T {\n        val key = getKey(key, property)\n        return getFromPreference(clazz, type, default, key) as T\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/PreferenceFieldBinderNullable.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.getPreferencesOrThrowError\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.testingMode\nimport java.lang.reflect.Type\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KClass\nimport kotlin.reflect.KProperty\n\ninternal class PreferenceFieldBinderNullable<T : Any>(\n        private val clazz: KClass<T>,\n        private val type: Type,\n        private val key: String?\n) : ReadWriteProperty<PreferenceHolder, T?>, Clearable {\n\n    override fun clear(thisRef: PreferenceHolder, property: KProperty<*>) {\n        setValue(thisRef, property, null)\n    }\n\n    override fun clearCache() {\n        propertySet = false\n        field = null\n    }\n\n    var propertySet: Boolean = false\n    var field: T? = null\n\n    override operator fun getValue(thisRef: PreferenceHolder, property: KProperty<*>): T? = when {\n        testingMode -> field\n        else -> readAndSetValue(property)\n    }\n\n    private fun readAndSetValue(property: KProperty<*>): T? {\n        val newValue = readValue(property)\n        field = newValue\n        propertySet = true\n        return newValue\n    }\n\n    override fun setValue(thisRef: PreferenceHolder, property: KProperty<*>, value: T?) {\n        if (testingMode) {\n            propertySet = true\n            if (value == field) return\n            field = value\n        } else {\n            saveNewValue(property, value)\n        }\n    }\n\n    private fun saveNewValue(property: KProperty<*>, value: T?) {\n        if (value == null) {\n            removeValue(property)\n        } else {\n            saveValue(property, value)\n        }\n    }\n\n    private fun readValue(property: KProperty<*>): T? {\n        val key = getKey(key, property)\n        val pref = getPreferencesOrThrowError()\n        if (!pref.contains(key)) return null\n        return pref.getFromPreference(clazz, type, key)\n    }\n\n    private fun removeValue(property: KProperty<*>) {\n        val pref = getPreferencesOrThrowError()\n        pref.edit()\n                .remove(getKey(key, property))\n                .apply()\n    }\n\n    private fun saveValue(property: KProperty<*>, value: T) {\n        val pref = getPreferencesOrThrowError()\n        pref.edit().apply { putValue(clazz, value, getKey(key, property)) }.apply()\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/PreferenceFieldBinderNullableCaching.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.bindings\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.getPreferencesOrThrowError\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder.Companion.testingMode\nimport java.lang.reflect.Type\nimport kotlin.concurrent.thread\nimport kotlin.properties.ReadWriteProperty\nimport kotlin.reflect.KClass\nimport kotlin.reflect.KProperty\n\ninternal class PreferenceFieldBinderNullableCaching<T : Any>(\n        private val clazz: KClass<T>,\n        private val type: Type,\n        private val key: String?\n) : ReadWriteProperty<PreferenceHolder, T?>, Clearable {\n\n    override fun clear(thisRef: PreferenceHolder, property: KProperty<*>) {\n        setValue(thisRef, property, null)\n    }\n\n    override fun clearCache() {\n        propertySet = false\n        field = null\n    }\n\n    var propertySet: Boolean = false\n    var field: T? = null\n\n    override operator fun getValue(thisRef: PreferenceHolder, property: KProperty<*>): T? = when {\n        testingMode || propertySet -> field\n        else -> readAndSetValue(property)\n    }\n\n    private fun readAndSetValue(property: KProperty<*>): T? {\n        val newValue = readValue(property)\n        field = newValue\n        propertySet = true\n        return newValue\n    }\n\n    override fun setValue(thisRef: PreferenceHolder, property: KProperty<*>, value: T?) {\n        propertySet = true\n        if (value == field) return\n        field = value\n\n        if (!testingMode)\n            saveNewValue(property, value)\n    }\n\n    private fun saveNewValue(property: KProperty<*>, value: T?) {\n        thread {\n            if (value == null) {\n                removeValue(property)\n            } else {\n                saveValue(property, value)\n            }\n        }\n    }\n\n    private fun readValue(property: KProperty<*>): T? {\n        val key = getKey(key, property)\n        val pref = getPreferencesOrThrowError()\n        if (!pref.contains(key)) return null\n        return pref.getFromPreference(clazz, type, key)\n    }\n\n    private fun removeValue(property: KProperty<*>) {\n        val pref = getPreferencesOrThrowError()\n        pref.edit()\n                .remove(getKey(key, property))\n                .apply()\n    }\n\n    private fun saveValue(property: KProperty<*>, value: T) {\n        val pref = getPreferencesOrThrowError()\n        pref.edit().apply { putValue(clazz, value, getKey(key, property)) }.apply()\n    }\n}"
  },
  {
    "path": "preferenceholder/src/main/java/com/marcinmoskala/kotlinpreferences/bindings/PutValueExt.kt",
    "content": "@file:Suppress(\"UNCHECKED_CAST\", \"IMPLICIT_CAST_TO_ANY\")\n\npackage com.marcinmoskala.kotlinpreferences.bindings\n\nimport android.content.SharedPreferences\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport java.lang.reflect.Type\nimport kotlin.reflect.KClass\n\ninternal fun SharedPreferences.Editor.putValue(clazz: KClass<*>, value: Any, key: String) {\n    when (clazz.simpleName) {\n        \"Long\" -> putLong(key, value as Long)\n        \"Int\" -> putInt(key, value as Int)\n        \"String\" -> putString(key, value as String?)\n        \"Boolean\" -> putBoolean(key, value as Boolean)\n        \"Float\" -> putFloat(key, value as Float)\n        else -> putString(key, value.serialize())\n    }\n}\n\ninternal fun <T : Any> SharedPreferences.getFromPreference(clazz: KClass<T>, type: Type, default: T?, key: String): T? = when (clazz.simpleName) {\n    \"Long\" -> getLong(key, default as Long) as? T\n    \"Int\" -> getInt(key, default as Int) as? T\n    \"String\" -> getString(key, default as? String) as? T\n    \"Boolean\" -> getBoolean(key, default as Boolean) as? T\n    \"Float\" -> getFloat(key, default as Float) as? T\n    else -> getString(key, default.serialize()).deserialize(type)\n}\n\ninternal fun <T: Any> SharedPreferences.getFromPreference(clazz: KClass<T>, type: Type, key: String): T?\n        = getFromPreference(clazz, type, getDefault(clazz), key)\n\nprivate fun <T: Any> String.deserialize(type: Type): T? = getSerializer().deserialize(this, type) as? T\n\nprivate fun <T> T.serialize() = getSerializer().serialize(this)\n\nprivate fun getSerializer() = PreferenceHolder.serializer ?: throw Error(Errors.serializerNotSet)\n\nprivate fun <T: Any> getDefault(clazz: KClass<T>): T? = when(clazz.simpleName) {\n    \"Long\" -> -1L\n    \"Int\" -> -1\n    \"Boolean\" -> false\n    \"Float\" -> -1.0F\n    else -> null\n} as? T"
  },
  {
    "path": "preferenceholder-gson-serializer/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "preferenceholder-gson-serializer/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'kotlin-android'\n\napply plugin: 'com.github.dcendents.android-maven'\n\ngroup='com.marcinmoskala'\n\nandroid {\n    compileSdkVersion 27\n    buildToolsVersion '27.0.1'\n\n    defaultConfig {\n        minSdkVersion 14\n        targetSdkVersion 27\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n}\n\ndependencies {\n    compile project(':preferenceholder')\n\n    compile \"com.google.code.gson:gson:2.8.0\"\n    compile \"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version\"\n\n    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n    testCompile 'junit:junit:4.12'\n}\n\nrepositories {\n    mavenCentral()\n}\n\n// Fancy test print\ntasks.withType(Test) {\n    testLogging {\n        // set options for log level LIFECYCLE\n        events \"passed\", \"skipped\", \"failed\", \"standardOut\"\n        showExceptions true\n        exceptionFormat \"full\"\n        showCauses true\n        showStackTraces true\n\n        // set options for log level DEBUG and INFO\n        debug {\n            events \"started\", \"passed\", \"skipped\", \"failed\", \"standardOut\", \"standardError\"\n            exceptionFormat \"full\"\n        }\n        info.events = debug.events\n        info.exceptionFormat = debug.exceptionFormat\n\n        afterSuite { desc, result ->\n            if (!desc.parent) { // will match the outermost suite\n                def output = \"Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)\"\n                def startItem = '|  ', endItem = '  |'\n                def repeatLength = startItem.length() + output.length() + endItem.length()\n                println('\\n' + ('-' * repeatLength) + '\\n' + startItem + output + endItem + '\\n' + ('-' * repeatLength))\n            }\n        }\n    }\n}\n\ntask sourcesJar(type: Jar) {\n    from android.sourceSets.main.java.srcDirs\n    classifier = 'sources'\n}\n\nartifacts {\n    archives sourcesJar\n}\n\ninstall {\n    repositories.mavenInstaller {\n        pom.project {\n            licenses {\n                license {\n                    name 'The Apache Software License, Version 2.0'\n                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'\n                    distribution 'repo'\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "preferenceholder-gson-serializer/proguard-rules.pro",
    "content": ""
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/DeserializationTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.support.test.runner.AndroidJUnit4\nimport com.google.gson.Gson\nimport com.marcinmoskala.kotlinpreferences.gson.GsonSerializer\nimport org.junit.Assert\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass DeserializationTest : GsonBaseTest() {\n\n    data class User(var name: String, var age: Int = 0)\n\n    @Test\n    fun listDeserializationTest() {\n        val json = \"[{\\\"age\\\"=\\\"0\\\", \\\"name\\\"=\\\"Name0\\\"}, {\\\"age\\\"=\\\"1\\\", \\\"name\\\"=\\\"Name1\\\"}, {\\\"age\\\"=\\\"2\\\", \\\"name\\\"=\\\"Name2\\\"}]\"\n        val users = GsonSerializer(Gson()).deserialize(json, object : TypeToken<List<User>>() {}.type)\n        val expected = List(3) { i -> User(\"Name$i\", i) }\n        Assert.assertEquals(expected, users)\n    }\n}\n"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/GsonBaseTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport android.support.test.InstrumentationRegistry\nimport com.google.gson.Gson\nimport com.marcinmoskala.kotlinpreferences.collections.CollectionsPref\nimport com.marcinmoskala.kotlinpreferences.gson.GsonSerializer\nimport com.marcinmoskala.kotlinpreferences.objects.ComplexTestPreferences\n\nopen class GsonBaseTest {\n\n    init {\n        PreferenceHolder.setContext(InstrumentationRegistry.getTargetContext())\n        PreferenceHolder.serializer = GsonSerializer(Gson())\n        ComplexTestPreferences.clear()\n        CollectionsPref.clear()\n    }\n}"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/TestUtills.kt",
    "content": "package com.marcinmoskala.kotlinpreferences\n\nimport org.junit.Assert\nimport kotlin.reflect.KMutableProperty0\n\nfun <T> testValues(property: KMutableProperty0<T>, start: T?, vararg values: T) {\n    Assert.assertEquals(start, property.get())\n    values.forEach {\n        property.set(it)\n        Assert.assertEquals(it, property.get())\n    }\n}"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/collections/CollectionsConfig.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.collections\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.kotlinpreferences.objects.Character\n\nobject CollectionsPref: PreferenceHolder() {\n    var intList: List<Int>? by bindToPreferenceFieldNullable()\n\n    var stringList: List<String> by bindToPreferenceField(listOf())\n    var longList: Map<Int, Long> by bindToPreferenceField(mapOf(0 to 12L, 10 to 143L))\n\n    var propTest: List<Character>? by bindToPreferenceFieldNullable()\n    var elemTest: Set<Elems> by bindToPreferenceField(setOf(Elems.Elem1, Elems.Elem3))\n\n    var multiLevelList: List<List<Int>>? by bindToPreferenceFieldNullable()\n}\n\nenum class Elems {\n    Elem1,\n    Elem2,\n    Elem3,\n    Elem4,\n    Elem5\n}"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/collections/CollectionsTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.collections\n\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.GsonBaseTest\nimport com.marcinmoskala.kotlinpreferences.collections.Elems.*\nimport com.marcinmoskala.kotlinpreferences.objects.Character\nimport com.marcinmoskala.kotlinpreferences.testValues\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass PreferenceFieldNullableTest : GsonBaseTest() {\n\n    @Test\n    fun intListTest() {\n        testValues(CollectionsPref::intList, null, listOf(1, 2, 3, 4), listOf(4, 3, 2, 1), listOf())\n    }\n\n    @Test\n    fun stringListTest() {\n        testValues(CollectionsPref::stringList, listOf(), listOf(\"Test1\", \"Test2\", \"Test3\"), listOf(), listOf(\"Test3\"), listOf(\"Test1\", \"Test2\"))\n    }\n\n    @Test\n    fun longMapTest() {\n        testValues(CollectionsPref::longList, mapOf(0 to 12L, 10 to 143L), mapOf(100 to 1000L), mapOf(), mapOf(0 to 1L, 1 to 2L, 2 to 3L))\n    }\n\n    @Test\n    fun complexListTest() {\n        val character1 = Character(\"Marcin\", \"Human\", \"Wizzard\")\n        val character2 = Character(\"SuperMarcin\", \"SuperHuman\", \"SuperWizzard\")\n        testValues(CollectionsPref::propTest, null, listOf(character1), listOf(character1, character2), listOf(character1))\n    }\n\n    @Test\n    fun enumSetChangeTest() {\n        testValues(CollectionsPref::elemTest, setOf(Elem1, Elem3), setOf(), setOf(Elem4, Elem3), setOf(Elem1, Elem2, Elem3, Elem4, Elem5), setOf())\n    }\n}\n"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/issue2test/Issue2Test.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.issue2test\n\nimport android.support.test.InstrumentationRegistry\nimport android.support.test.runner.AndroidJUnit4\nimport android.util.Log\nimport com.google.gson.Gson\nimport com.google.gson.reflect.TypeToken\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.kotlinpreferences.gson.GsonSerializer\nimport org.junit.Assert\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass Issue2Test {\n\n    data class User(var name: String, var age: Int = 0)\n\n    object AppPreference : PreferenceHolder() {\n        var users: List<User>? by bindToPreferenceFieldNullable()\n    }\n\n    init {\n        PreferenceHolder.setContext(InstrumentationRegistry.getTargetContext())\n        PreferenceHolder.serializer = GsonSerializer(Gson())\n    }\n\n    @Test\n    fun booleanDefaultChangeTest() {\n        val users = List(6) { i -> User(\"Name$i\", i) }\n        AppPreference.users = users\n        AppPreference.clearCache()\n        val readUsers = AppPreference.users\n        Assert.assertEquals(users, readUsers)\n    }\n}\n"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/objects/ObjectConfig.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.objects\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\n\nobject ComplexTestPreferences: PreferenceHolder() {\n    var character: Character? by bindToPreferenceFieldNullable()\n    var savedGame: Game? by bindToPreferenceFieldNullable()\n}\n\ndata class Character(\n        val name: String,\n        val race: String,\n        val clazz: String\n)\n\ndata class Game(\n        val character: Character,\n        val gameMode: GameMode,\n        val level: Int\n)\n\nenum class GameMode {\n    Easy, Normal, Hard\n}"
  },
  {
    "path": "preferenceholder-gson-serializer/src/androidTest/java/com/marcinmoskala/kotlinpreferences/objects/ObjectsTest.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.objects\n\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.GsonBaseTest\nimport com.marcinmoskala.kotlinpreferences.testValues\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass ObjectsTest: GsonBaseTest() {\n\n    @Test\n    fun characterTest() {\n        val character1 = Character(\"Marcin\", \"Human\", \"Wizzard\")\n        val character2 = Character(\"Marcin\", \"SuperHuman\", \"Wizzard\")\n        testValues(ComplexTestPreferences::character, null, character1, character2)\n    }\n\n    @Test\n    fun bigObjectTest() {\n        val game1 = Game(Character(\"Marcin\", \"Human\", \"Wizzard\"), GameMode.Hard, 100)\n        testValues(ComplexTestPreferences::savedGame, null, game1)\n    }\n}"
  },
  {
    "path": "preferenceholder-gson-serializer/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"com.marcinmoskala.kotlinpreferences.gson\" />"
  },
  {
    "path": "preferenceholder-gson-serializer/src/main/java/com/marcinmoskala/kotlinpreferences/gson/GsonSerializer.kt",
    "content": "package com.marcinmoskala.kotlinpreferences.gson\n\nimport com.google.gson.Gson\nimport com.marcinmoskala.kotlinpreferences.Serializer\nimport java.lang.reflect.Type\n\nclass GsonSerializer(val gson: Gson) : Serializer {\n\n    override fun serialize(toSerialize: Any?): String? = gson.toJson(toSerialize)\n\n    override fun deserialize(serialized: String?, type: Type): Any? = try {\n        gson.fromJson<Any>(serialized, type)\n    } catch (e: Throwable) {\n        throw Error(\"Error in parsing to $type. The string to parse: \\\"$this\\\"\", e)\n    }\n}"
  },
  {
    "path": "sample/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "sample/build.gradle",
    "content": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-android-extensions'\n\nandroid {\n    compileSdkVersion 27\n    buildToolsVersion '27.0.1'\n\n    defaultConfig {\n        applicationId \"com.marcinmoskala.testapp\"\n        minSdkVersion 14\n        targetSdkVersion 27\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    compile project(':preferenceholder')\n    compile \"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version\"\n    compile 'com.android.support:appcompat-v7:27.0.1'\n    testCompile 'junit:junit:4.12'\n    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n}"
  },
  {
    "path": "sample/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/marcin/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "sample/src/androidTest/java/com/marcinmoskala/testapp/DefaultChangeTest.kt",
    "content": "package com.marcinmoskala.testapp\n\nimport android.support.test.InstrumentationRegistry\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.testapp.TestPreferences.canEatPie\nimport org.junit.Assert.assertEquals\nimport org.junit.Assert.assertTrue\nimport org.junit.Test\nimport org.junit.runner.RunWith\nimport kotlin.reflect.KMutableProperty0\n\n@RunWith(AndroidJUnit4::class)\nclass DefaultChangeTest {\n\n    init {\n        PreferenceHolder.setContext(InstrumentationRegistry.getTargetContext())\n        TestPreferences.clear()\n    }\n\n    @Test\n    fun booleanDefaultChangeTest() {\n        testBoolean(TestPreferences::canEatPie)\n    }\n\n    private fun testBoolean(property: KMutableProperty0<Boolean>) {\n        assertTrue(property.get())\n        property.set(false)\n        canEatPie = false\n        assertTrue(!canEatPie)\n        canEatPie = true\n        assertTrue(canEatPie)\n    }\n\n    @Test\n    fun intDefaultChangeTest() {\n        assertEquals(0, TestPreferences.pieBaked)\n        TestPreferences.pieBaked = 10\n        assertEquals(10, TestPreferences.pieBaked)\n        TestPreferences.pieBaked += 10\n        assertEquals(20, TestPreferences.pieBaked)\n    }\n\n    @Test\n    fun longDefaultChangeTest() {\n        assertEquals(0L, TestPreferences.allPieInTheWorld)\n        TestPreferences.allPieInTheWorld = 10\n        assertEquals(10L, TestPreferences.allPieInTheWorld)\n        TestPreferences.allPieInTheWorld += 10\n        assertEquals(20L, TestPreferences.allPieInTheWorld)\n    }\n\n    @Test\n    fun floatDefaultChangeTest() {\n        assertEquals(0F, TestPreferences.pieEaten)\n        for (i in 1..10) TestPreferences.pieEaten += 1F\n        assertEquals(10F, TestPreferences.pieEaten)\n        TestPreferences.pieEaten *= 2\n        assertEquals(20F, TestPreferences.pieEaten)\n    }\n\n    @Test\n    fun stringDefaultChangeTest() {\n        assertEquals(\"Pie\", TestPreferences.bestPieName)\n        TestPreferences.bestPieName = \"BlueberryPie\"\n        assertEquals(\"BlueberryPie\", TestPreferences.bestPieName)\n        TestPreferences.bestPieName = \"SuperPie\"\n        assertEquals(\"SuperPie\", TestPreferences.bestPieName)\n    }\n}\n"
  },
  {
    "path": "sample/src/androidTest/java/com/marcinmoskala/testapp/ExampleConfig.kt",
    "content": "package com.marcinmoskala.testapp\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\n\nobject TestPreferences: PreferenceHolder() {\n    var canEatPie: Boolean by bindToPreferenceField(true)\n    var pieBaked: Int by bindToPreferenceField(0)\n    var allPieInTheWorld: Long by bindToPreferenceField(0)\n    var pieEaten: Float by bindToPreferenceField(0.0F)\n    var bestPieName: String by bindToPreferenceField(\"Pie\")\n\n    var isMonsterKiller: Boolean? by bindToPreferenceFieldNullable()\n    var monstersKilled: Int? by bindToPreferenceFieldNullable()\n    var numberOfHahaInLough: Long? by bindToPreferenceFieldNullable()\n    var experience: Float? by bindToPreferenceFieldNullable()\n    var className: String? by bindToPreferenceFieldNullable()\n}\n\nobject ComplexTestPreferences: PreferenceHolder() {\n    var character: Character? by bindToPreferenceFieldNullable()\n    var savedGame: Game? by bindToPreferenceFieldNullable()\n}\n\n\ndata class Character(\n        val name: String,\n        val race: String,\n        val clazz: String\n)\n\nclass Game(\n        val character: Character,\n        val gameMode: GameMode,\n        val level: Int\n)\n\nenum class GameMode {\n    Easy, Normal, Hard\n}"
  },
  {
    "path": "sample/src/androidTest/java/com/marcinmoskala/testapp/NullableChangeTest.kt",
    "content": "package com.marcinmoskala.testapp\n\nimport android.support.test.InstrumentationRegistry\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.testapp.TestPreferences.className\nimport com.marcinmoskala.testapp.TestPreferences.experience\nimport com.marcinmoskala.testapp.TestPreferences.isMonsterKiller\nimport com.marcinmoskala.testapp.TestPreferences.monstersKilled\nimport com.marcinmoskala.testapp.TestPreferences.numberOfHahaInLough\nimport org.junit.Assert.*\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass NullableChangeTest {\n\n    init {\n        PreferenceHolder.setContext(InstrumentationRegistry.getTargetContext())\n        TestPreferences.clear()\n    }\n\n    @Test\n    fun booleanDefaultChangeTest() {\n        assertNull(isMonsterKiller)\n        isMonsterKiller = true\n        assertTrue(isMonsterKiller!!)\n        isMonsterKiller = false\n        assertTrue(!isMonsterKiller!!)\n        isMonsterKiller = null\n        assertNull(isMonsterKiller)\n    }\n\n    @Test\n    fun intDefaultChangeTest() {\n        assertNull(monstersKilled)\n        monstersKilled = 1\n        assertEquals(1, monstersKilled!!)\n        monstersKilled = monstersKilled?.plus(1)\n        assertEquals(2, monstersKilled!!)\n        monstersKilled = null\n        assertNull(monstersKilled)\n\n    }\n\n    @Test\n    fun longDefaultChangeTest() {\n        assertNull(numberOfHahaInLough)\n        numberOfHahaInLough = 10\n        assertEquals(10, numberOfHahaInLough!!)\n        numberOfHahaInLough = 100\n        assertEquals(100, numberOfHahaInLough!!)\n        numberOfHahaInLough = null\n        assertNull(numberOfHahaInLough)\n    }\n\n    @Test\n    fun floatDefaultChangeTest() {\n        assertNull(experience)\n        experience = 0.0F\n        assertEquals(0.0F, experience!!)\n        experience = 10.0F\n        assertEquals(10.0F, experience!!)\n        experience = null\n        assertNull(experience)\n\n    }\n\n    @Test\n    fun stringDefaultChangeTest() {\n        assertNull(className)\n        className = \"Rouge\"\n        assertEquals(\"Rouge\", className!!)\n        className = \"Wizard\"\n        assertEquals(\"Wizard\", className!!)\n        className = null\n        assertNull(className)\n    }\n}\n"
  },
  {
    "path": "sample/src/androidTest/java/com/marcinmoskala/testapp/NullableClassesChangeTest.kt",
    "content": "package com.marcinmoskala.testapp\n\nimport android.support.test.InstrumentationRegistry\nimport android.support.test.runner.AndroidJUnit4\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\nimport com.marcinmoskala.testapp.ComplexTestPreferences.character\nimport com.marcinmoskala.testapp.ComplexTestPreferences.savedGame\nimport org.junit.Assert.assertEquals\nimport org.junit.Assert.assertNull\nimport org.junit.Test\nimport org.junit.runner.RunWith\n\n@RunWith(AndroidJUnit4::class)\nclass NullableClassesChangeTest {\n\n    init {\n        PreferenceHolder.setContext(InstrumentationRegistry.getTargetContext())\n        ComplexTestPreferences.clear()\n    }\n\n    @Test\n    fun characterTest() {\n        assertNull(character)\n        character = Character(\"Marcin\", \"Human\", \"Wizzard\")\n        assertEquals(Character(\"Marcin\", \"Human\", \"Wizzard\"), character!!)\n        character = character!!.copy(race = \"SuperHuman\")\n        assertEquals(\"SuperHuman\", character!!.race)\n        assertEquals(Character(\"Marcin\", \"SuperHuman\", \"Wizzard\"), character!!)\n    }\n\n    @Test\n    fun bigObjectTest() {\n        assertNull(savedGame)\n        savedGame = Game(Character(\"Marcin\", \"Human\", \"Wizzard\"), GameMode.Hard, 100)\n        assertEquals(Character(\"Marcin\", \"Human\", \"Wizzard\"), savedGame!!.character)\n        assertEquals(GameMode.Hard, savedGame!!.gameMode)\n        assertEquals(100, savedGame!!.level)\n    }\n}\n"
  },
  {
    "path": "sample/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.marcinmoskala.testapp\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\"\n        android:name=\"com.marcinmoskala.kotlinpreferences.PreferenceHolderApplication\">\n        <activity android:name=\".MainActivity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "sample/src/main/java/com/marcinmoskala/testapp/MainActivity.kt",
    "content": "package com.marcinmoskala.testapp\n\nimport android.os.Bundle\nimport android.support.v7.app.AppCompatActivity\nimport kotlinx.android.synthetic.main.activity_main.*\n\nclass MainActivity : AppCompatActivity() {\n\n    val text: String\n        get()  = textEditView.text.toString()\n\n    val num: Int\n        get()  = numberEditView.text.toString().toInt()\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n        textEditView.setText(Pref.text)\n        numberEditView.setText(Pref.num.toString())\n        textEditView.setOnKeyListener { v, k, e -> Pref.text = text; true }\n        numberEditView.setOnKeyListener { v, k, e -> Pref.num = num; true }\n        saveObjectButton.setOnClickListener {\n            val newObject = OtherPref.Together(text, num)\n            OtherPref.together = newObject\n            objectMonitor.text = newObject.toString()\n        }\n    }\n}"
  },
  {
    "path": "sample/src/main/java/com/marcinmoskala/testapp/Pref.kt",
    "content": "package com.marcinmoskala.testapp\n\nimport com.marcinmoskala.kotlinpreferences.PreferenceHolder\n\nobject Pref : PreferenceHolder() {\n    var text: String? by bindToPreferenceFieldNullable()\n    var num: Int by bindToPreferenceField(0, \"SomeIntKey\")\n}\n\nobject OtherPref : PreferenceHolder() {\n    var together: Together? by bindToPreferenceFieldNullable(\"SomeOtherKey\")\n\n    data class Together(\n            val text: String,\n            val num: Int?\n    )\n}"
  },
  {
    "path": "sample/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:background=\"@android:color/white\"\n    tools:context=\"com.marcinmoskala.testapp.MainActivity\">\n\n    <LinearLayout\n        android:orientation=\"vertical\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\">\n\n        <EditText\n            android:id=\"@+id/textEditView\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"46dp\"\n            android:layout_margin=\"10dp\"\n            android:textColor=\"@color/colorPrimary\"\n            android:ems=\"10\"\n            android:inputType=\"textPersonName\"/>\n\n        <EditText\n            android:id=\"@+id/numberEditView\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"46dp\"\n            android:layout_margin=\"10dp\"\n            android:textColor=\"@color/colorPrimary\"\n            android:ems=\"10\"\n            android:inputType=\"number\"/>\n\n        <Button\n            android:id=\"@+id/saveObjectButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"46dp\"\n            android:layout_margin=\"10dp\"\n            android:ems=\"10\"\n            android:text=\"Save object\"/>\n\n        <TextView\n            android:id=\"@+id/objectMonitor\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"46dp\"\n            android:layout_margin=\"10dp\"\n            android:ems=\"10\"\n            android:textColor=\"@color/colorPrimary\"\n            android:inputType=\"textPersonName\"\n            android:text=\"Name\"\n            tools:layout_editor_absoluteX=\"16dp\"\n            tools:layout_editor_absoluteY=\"13dp\" />\n\n\n\n    </LinearLayout>\n</ScrollView>\n"
  },
  {
    "path": "sample/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "sample/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">TestApp</string>\n</resources>\n"
  },
  {
    "path": "sample/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':preferenceholder', ':preferenceholder-gson-serializer', ':sample'\n"
  }
]