Full Code of uchuhimo/konf for AI

master 8aa88358b89f cached
213 files
832.2 KB
199.6k tokens
29 symbols
1 requests
Download .txt
Showing preview only (910K chars total). Download the full file or copy to clipboard to get everything.
Repository: uchuhimo/konf
Branch: master
Commit: 8aa88358b89f
Files: 213
Total size: 832.2 KB

Directory structure:
gitextract_30e7_42m/

├── .gitattributes
├── .github/
│   ├── stale.yml
│   └── workflows/
│       └── gradle.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.gradle.kts
├── buildSrc/
│   ├── build.gradle.kts
│   ├── settings.gradle.kts
│   └── src/
│       └── main/
│           └── kotlin/
│               ├── Dependencies.kt
│               └── Utils.kt
├── config/
│   └── spotless/
│       ├── apache-license-2.0.java
│       └── apache-license-2.0.kt
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── konf-all/
│   ├── build.gradle.kts
│   └── src/
│       ├── snippet/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── snippet/
│       │   │                   ├── ServerInJava.java
│       │   │                   └── ServerSpecInJava.java
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── snippet/
│       │   │                   ├── Config.kt
│       │   │                   ├── Export.kt
│       │   │                   ├── Fork.kt
│       │   │                   ├── Load.kt
│       │   │                   ├── QuickStart.kt
│       │   │                   ├── Serialize.kt
│       │   │                   └── Server.kt
│       │   └── resources/
│       │       └── server.json
│       └── test/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               ├── MergeSourcesWithDifferentFeaturesSpec.kt
│                               ├── MultiLayerConfigToValueSpec.kt
│                               ├── MultipleDefaultLoadersSpec.kt
│                               └── QuickStartSpec.kt
├── konf-core/
│   ├── build.gradle.kts
│   └── src/
│       ├── jmh/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── ConfigBenchmark.kt
│       ├── main/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── Configs.java
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   ├── BaseConfig.kt
│       │                   ├── Config.kt
│       │                   ├── ConfigException.kt
│       │                   ├── ConfigSpec.kt
│       │                   ├── Feature.kt
│       │                   ├── Item.kt
│       │                   ├── ItemContainer.kt
│       │                   ├── MergedConfig.kt
│       │                   ├── MergedMap.kt
│       │                   ├── Prefix.kt
│       │                   ├── SizeInBytes.kt
│       │                   ├── Spec.kt
│       │                   ├── TreeNode.kt
│       │                   ├── Utils.kt
│       │                   ├── annotation/
│       │                   │   └── Annotations.kt
│       │                   └── source/
│       │                       ├── DefaultLoaders.kt
│       │                       ├── DefaultProviders.kt
│       │                       ├── Loader.kt
│       │                       ├── MergedSource.kt
│       │                       ├── Provider.kt
│       │                       ├── Source.kt
│       │                       ├── SourceException.kt
│       │                       ├── SourceNode.kt
│       │                       ├── Utils.kt
│       │                       ├── Writer.kt
│       │                       ├── base/
│       │                       │   ├── FlatSource.kt
│       │                       │   ├── KVSource.kt
│       │                       │   ├── MapSource.kt
│       │                       │   └── ValueSource.kt
│       │                       ├── deserializer/
│       │                       │   ├── DurationDeserializer.kt
│       │                       │   ├── EmptyStringToCollectionDeserializerModifier.kt
│       │                       │   ├── JSR310Deserializer.kt
│       │                       │   ├── OffsetDateTimeDeserializer.kt
│       │                       │   ├── StringDeserializer.kt
│       │                       │   └── ZoneDateTimeDeserializer.kt
│       │                       ├── env/
│       │                       │   └── EnvProvider.kt
│       │                       ├── json/
│       │                       │   ├── JsonProvider.kt
│       │                       │   ├── JsonSource.kt
│       │                       │   └── JsonWriter.kt
│       │                       └── properties/
│       │                           ├── PropertiesProvider.kt
│       │                           └── PropertiesWriter.kt
│       ├── test/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               ├── AnonymousConfigSpec.java
│       │   │               ├── ConfigJavaApiTest.java
│       │   │               └── NetworkBufferInJava.java
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               ├── AdHocConfigItemSpec.kt
│       │   │               ├── AdHocNetworkBuffer.kt
│       │   │               ├── ConfigInJavaSpec.kt
│       │   │               ├── ConfigSpecTestSpec.kt
│       │   │               ├── ConfigTestSpec.kt
│       │   │               ├── FeatureSpec.kt
│       │   │               ├── MergedConfigSpek.kt
│       │   │               ├── MergedMapSpec.kt
│       │   │               ├── MultiLayerConfigSpec.kt
│       │   │               ├── NetworkBuffer.kt
│       │   │               ├── ParseDurationSpec.kt
│       │   │               ├── RelocatedConfigSpec.kt
│       │   │               ├── SizeInBytesSpec.kt
│       │   │               ├── TreeNodeSpec.kt
│       │   │               └── source/
│       │   │                   ├── CustomDeserializerSpec.kt
│       │   │                   ├── DefaultLoadersSpec.kt
│       │   │                   ├── DefaultProvidersSpec.kt
│       │   │                   ├── FacadeSourceSpec.kt
│       │   │                   ├── FallbackSourceSpec.kt
│       │   │                   ├── LoaderSpec.kt
│       │   │                   ├── MergedSourceLoadSpec.kt
│       │   │                   ├── ProviderSpec.kt
│       │   │                   ├── SourceInfoSpec.kt
│       │   │                   ├── SourceLoadSpec.kt
│       │   │                   ├── SourceNodeSpec.kt
│       │   │                   ├── SourceSpec.kt
│       │   │                   ├── WriterSpec.kt
│       │   │                   ├── base/
│       │   │                   │   ├── FlatSourceLoadSpec.kt
│       │   │                   │   ├── FlatSourceSpec.kt
│       │   │                   │   ├── KVSourceSpec.kt
│       │   │                   │   ├── MapSourceLoadSpec.kt
│       │   │                   │   ├── MapSourceSpec.kt
│       │   │                   │   └── ValueSourceSpec.kt
│       │   │                   ├── deserializer/
│       │   │                   │   ├── DurationDeserializerSpec.kt
│       │   │                   │   ├── OffsetDateTimeDeserializerSpec.kt
│       │   │                   │   ├── StringDeserializerSpec.kt
│       │   │                   │   └── ZonedDateTimeDeserializerSpec.kt
│       │   │                   ├── env/
│       │   │                   │   ├── EnvProviderSpec.kt
│       │   │                   │   └── env.properties
│       │   │                   ├── json/
│       │   │                   │   ├── JsonProviderSpec.kt
│       │   │                   │   ├── JsonSourceLoadSpec.kt
│       │   │                   │   ├── JsonSourceSpec.kt
│       │   │                   │   └── JsonWriterSpec.kt
│       │   │                   ├── properties/
│       │   │                   │   ├── PropertiesProviderSpec.kt
│       │   │                   │   └── PropertiesSourceLoadSpec.kt
│       │   │                   └── serializer/
│       │   │                       └── PrimitiveStdSerializerSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           ├── provider.properties
│       │           ├── source.json
│       │           └── source.properties
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           ├── TestUtils.kt
│                           └── source/
│                               ├── ConfigForLoad.kt
│                               ├── SingleThreadDispatcher.kt
│                               ├── SourceLoadBaseSpec.kt
│                               ├── TestUtils.kt
│                               └── base/
│                                   ├── FlatConfigForLoad.kt
│                                   └── FlatSourceLoadBaseSpec.kt
├── konf-git/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultGitLoader.kt
│       │                       ├── DefaultGitProvider.kt
│       │                       ├── GitLoader.kt
│       │                       └── GitProvider.kt
│       └── test/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               ├── DefaultGitLoaderSpec.kt
│                               ├── DefaultGitProviderSpec.kt
│                               ├── GitLoaderSpec.kt
│                               └── GitProviderSpec.kt
├── konf-hocon/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultHoconLoader.kt
│       │                       ├── DefaultHoconProvider.kt
│       │                       └── hocon/
│       │                           ├── HoconProvider.kt
│       │                           ├── HoconSource.kt
│       │                           └── HoconWriter.kt
│       ├── test/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               ├── LoaderJavaApiTest.java
│       │   │               └── NetworkBufferInJava.java
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultHoconLoaderSpec.kt
│       │   │                   ├── DefaultHoconProviderSpec.kt
│       │   │                   └── hocon/
│       │   │                       ├── HoconProviderSpec.kt
│       │   │                       ├── HoconSourceLoadSpec.kt
│       │   │                       ├── HoconSourceSpec.kt
│       │   │                       ├── HoconValueSourceSpec.kt
│       │   │                       └── HoconWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.conf
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── HoconTestUtils.kt
├── konf-js/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultJsLoader.kt
│       │                       ├── DefaultJsProvider.kt
│       │                       └── js/
│       │                           ├── JsProvider.kt
│       │                           └── JsWriter.kt
│       └── test/
│           ├── kotlin/
│           │   └── com/
│           │       └── uchuhimo/
│           │           └── konf/
│           │               └── source/
│           │                   ├── DefaultJsLoaderSpec.kt
│           │                   ├── DefaultJsProviderSpec.kt
│           │                   └── js/
│           │                       ├── JsProviderSpec.kt
│           │                       ├── JsSourceLoadSpec.kt
│           │                       └── JsWriterSpec.kt
│           └── resources/
│               └── source/
│                   └── source.js
├── konf-toml/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           ├── moandjiezana/
│       │           │   └── toml/
│       │           │       └── Toml4jWriter.kt
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultTomlLoader.kt
│       │                       ├── DefaultTomlProvider.kt
│       │                       └── toml/
│       │                           ├── TomlProvider.kt
│       │                           └── TomlWriter.kt
│       ├── test/
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultTomlLoaderSpec.kt
│       │   │                   ├── DefaultTomlProviderSpec.kt
│       │   │                   └── toml/
│       │   │                       ├── TomlProviderSpec.kt
│       │   │                       ├── TomlSourceLoadSpec.kt
│       │   │                       ├── TomlValueSourceSpec.kt
│       │   │                       └── TomlWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.toml
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── TomlTestUtils.kt
├── konf-xml/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultXmlLoader.kt
│       │                       ├── DefaultXmlProvider.kt
│       │                       └── xml/
│       │                           ├── XmlProvider.kt
│       │                           └── XmlWriter.kt
│       ├── test/
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultXmlLoaderSpec.kt
│       │   │                   ├── DefaultXmlProviderSpec.kt
│       │   │                   └── xml/
│       │   │                       ├── XmlProviderSpec.kt
│       │   │                       ├── XmlSourceLoadSpec.kt
│       │   │                       └── XmlWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.xml
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── XmlTestUtils.kt
├── konf-yaml/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultYamlLoader.kt
│       │                       ├── DefaultYamlProvider.kt
│       │                       └── yaml/
│       │                           ├── YamlProvider.kt
│       │                           └── YamlWriter.kt
│       ├── test/
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultYamlLoaderSpec.kt
│       │   │                   ├── DefaultYamlProviderSpec.kt
│       │   │                   └── yaml/
│       │   │                       ├── YamlProviderSpec.kt
│       │   │                       ├── YamlSourceLoadSpec.kt
│       │   │                       └── YamlWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.yaml
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── YamlTestUtils.kt
└── settings.gradle.kts

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitattributes
================================================
# text stuff
* text=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.java text eol=lf
*.kt text eol=lf
*.md text eol=lf
*.properties text eol=lf
*.scala text eol=lf
*.sh text eol=lf
.gitattributes text eol=lf
.gitignore text eol=lf
build.gradle text eol=lf
gradlew text eol=lf
gradlew.bat text eol=crlf
gradle/wrapper/gradle-wrapper.properties text eol=lf

#binary
*.jar binary


================================================
FILE: .github/stale.yml
================================================
# Configuration for probot-stale - https://github.com/probot/stale

# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 90
# Number of days of inactivity before a stale Issue or Pull Request is closed
daysUntilClose: false
# Issues or Pull Requests with these labels will never be considered stale
exemptLabels:
- bug
- Announcement
- help wanted
- To investigate
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
  This issue has been automatically marked as stale because it has not had
  recent activity. It will be closed after 30 days if no further activity
  occurs, but feel free to re-open a closed issue if needed.

================================================
FILE: .github/workflows/gradle.yml
================================================
name: Konf CI

on: [push]

jobs:
  build:
    name: Build on JDK ${{ matrix.java_version }} and ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        java_version: [8, 11, 16]
        os: [ubuntu-latest, windows-latest, macOS-latest]

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK ${{ matrix.java_version }}
      uses: actions/setup-java@v1
      with:
        java-version: ${{ matrix.java_version }}
    - name: Build with Gradle
      run: ./gradlew build


================================================
FILE: .gitignore
================================================
# Created by .ignore support plugin (hsz.mobi)
### Java template
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Eclipse template
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath

# Eclipse Core
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Java annotation processor (APT)
.factorypath

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Windows template
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk
### Vim template
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
### SublimeText template
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# sftp configuration file
sftp-config.json
### OSX template
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk



### Gradle template
.gradle
build/
build-eclipse/
*/gradle*

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle/wrapper/gradle-wrapper.jar

private.properties
.vscode
.java-version
act
*.log

================================================
FILE: .travis.yml
================================================
language: java

jdk:
  - oraclejdk11
  - openjdk8
  - openjdk11
  - openjdk15

after_success:
  - bash <(curl -s https://codecov.io/bash)

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/


================================================
FILE: LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# Konf

[![Java 8+](https://img.shields.io/badge/Java-8+-4c7e9f.svg)](http://java.oracle.com)
[![Maven metadata URL](https://img.shields.io/maven-central/v/com.uchuhimo/konf)](https://search.maven.org/artifact/com.uchuhimo/konf)
[![JitPack](https://img.shields.io/jitpack/v/github/uchuhimo/konf)](https://jitpack.io/#uchuhimo/konf)
[![Build Status](https://travis-ci.org/uchuhimo/konf.svg?branch=master)](https://travis-ci.org/uchuhimo/konf)
[![codecov](https://codecov.io/gh/uchuhimo/konf/branch/master/graph/badge.svg)](https://codecov.io/gh/uchuhimo/konf)
[![codebeat badge](https://codebeat.co/badges/f69a1574-9d4c-4da5-be73-56fa7b180d2d)](https://codebeat.co/projects/github-com-uchuhimo-konf-master)
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)

A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats.

## Features

- **Type-safe**. Get/set value in config with type-safe APIs.
- **Thread-safe**. All APIs for config is thread-safe.
- **Batteries included**. Support sources from JSON, XML, YAML, [HOCON](https://github.com/typesafehub/config/blob/master/HOCON.md), [TOML](https://github.com/toml-lang/toml), properties, map, command line and system environment out of box.
- **Cascading**. Config can fork from another config by adding a new layer on it. Each layer of config can be updated independently. This feature is powerful enough to support complicated situation such as configs with different values share common fallback config, which is automatically updated when configuration file changes.
- **Self-documenting**. Document config item with type, default value and description when declaring.
- **Extensible**. Easy to customize new sources for config or expose items in config.

## Contents

- [Konf](#konf)
  - [Features](#features)
  - [Contents](#contents)
  - [Prerequisites](#prerequisites)
  - [Use in your projects](#use-in-your-projects)
    - [Maven](#maven)
    - [Gradle](#gradle)
    - [Gradle Kotlin DSL](#gradle-kotlin-dsl)
    - [Maven (master snapshot)](#maven-master-snapshot)
    - [Gradle (master snapshot)](#gradle-master-snapshot)
    - [Gradle Kotlin DSL (master snapshot)](#gradle-kotlin-dsl-master-snapshot)
  - [Quick start](#quick-start)
  - [Define items](#define-items)
  - [Use config](#use-config)
    - [Create config](#create-config)
    - [Add config spec](#add-config-spec)
    - [Retrieve value from config](#retrieve-value-from-config)
    - [Cast config to value](#cast-config-to-value)
    - [Check whether an item exists in config or not](#check-whether-an-item-exists-in-config-or-not)
    - [Modify value in config](#modify-value-in-config)
    - [Subscribe the update event](#subscribe-the-update-event)
    - [Export value in config as property](#export-value-in-config-as-property)
    - [Fork from another config](#fork-from-another-config)
  - [Load values from source](#load-values-from-source)
    - [Subscribe the update event for load operation](#subscribe-the-update-event-for-load-operation)
    - [Strict parsing when loading](#strict-parsing-when-loading)
    - [Path substitution](#path-substitution)
  - [Prefix/Merge operations for source/config/config spec](#prefixmerge-operations-for-sourceconfigconfig-spec)
  - [Export/Reload values in config](#exportreload-values-in-config)
  - [Supported item types](#supported-item-types)
  - [Optional features](#optional-features)
  - [Build from source](#build-from-source)
  - [Breaking Changes](#breaking-changes)
    - [v0.19.0](#v0190)
    - [v0.17.0](#v0170)
    - [v0.15](#v015)
    - [v0.10](#v010)
- [License](#license)

## Prerequisites

- JDK 8 or higher
- tested on Android SDK 23 or higher

## Use in your projects

This library has been published to [Maven Central](https://search.maven.org/artifact/com.uchuhimo/konf) and [JitPack](https://jitpack.io/#uchuhimo/konf).

Konf is modular, you can use different modules for different sources:

- `konf-core`: for built-in sources (JSON, properties, map, command line and system environment)
- `konf-hocon`: for built-in + [HOCON](https://github.com/typesafehub/config/blob/master/HOCON.md) sources
- `konf-toml`: for built-in + [TOML](https://github.com/toml-lang/toml) sources
- `konf-xml`: for built-in + XML sources
- `konf-yaml`: for built-in + YAML sources
- `konf-git`: for built-in + Git sources
- `konf`: for all sources mentioned above
- `konf-js`: for built-in + JavaScript (use GraalVM JavaScript) sources

### Maven

```xml
<dependency>
  <groupId>com.uchuhimo</groupId>
  <artifactId>konf</artifactId>
  <version>1.1.2</version>
</dependency>
```

### Gradle

```groovy
compile 'com.uchuhimo:konf:1.1.2'
```

### Gradle Kotlin DSL

```kotlin
compile(group = "com.uchuhimo", name = "konf", version = "1.1.2")
```

### Maven (master snapshot)

Add JitPack repository to `<repositories>` section:

```xml
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
```

Add dependencies:

```xml
<dependency>
    <groupId>com.github.uchuhimo</groupId>
    <artifactId>konf</artifactId>
    <version>master-SNAPSHOT</version>
</dependency>
```

### Gradle (master snapshot)

Add JitPack repository:

```groovy
repositories {
    maven { url 'https://jitpack.io' }
}
```

Add dependencies:

```groovy
compile 'com.github.uchuhimo.konf:konf:master-SNAPSHOT'
```

### Gradle Kotlin DSL (master snapshot)

Add JitPack repository:

```kotlin
repositories {
    maven(url = "https://jitpack.io")
}
```

Add dependencies:

```kotlin
compile(group = "com.github.uchuhimo.konf", name = "konf", version = "master-SNAPSHOT")
```

## Quick start

1. Define items in config spec:

    ```kotlin
    object ServerSpec : ConfigSpec() {
        val host by optional("0.0.0.0")
        val tcpPort by required<Int>()
    }
    ```

2. Construct config with items in config spec and values from multiple sources:

    ```kotlin
    val config = Config { addSpec(ServerSpec) }
            .from.yaml.file("server.yml")
            .from.json.resource("server.json")
            .from.env()
            .from.systemProperties()
    ```
   
   or:

    ```kotlin
    val config = Config { addSpec(ServerSpec) }.withSource(
        Source.from.yaml.file("server.yml") +
        Source.from.json.resource("server.json") +
        Source.from.env() +
        Source.from.systemProperties()
    )
    ```

    This config contains all items defined in `ServerSpec`, and load values from 4 different sources. Values in resource file `server.json` will override those in file `server.yml`, values from system environment will override those in `server.json`, and values from system properties will override those from system environment.

    If you want to watch file `server.yml` and reload values when file content is changed, you can use `watchFile` instead of `file`:

    ```kotlin
    val config = Config { addSpec(ServerSpec) }
            .from.yaml.watchFile("server.yml")
            .from.json.resource("server.json")
            .from.env()
            .from.systemProperties()
    ```

3. Define values in source. You can define in any of these sources:
    - in `server.yml`:
        ```yaml
        server:
            host: 0.0.0.0
            tcp_port: 8080
        ```
    - in `server.json`:
        ```json
        {
            "server": {
                "host": "0.0.0.0",
                "tcp_port": 8080
            }
        }
        ```
    - in system environment:
        ```bash
        SERVER_HOST=0.0.0.0
        SERVER_TCPPORT=8080
        ```
    - in command line for system properties:
        ```bash
        -Dserver.host=0.0.0.0 -Dserver.tcp_port=8080
        ```

4. Retrieve values from config with type-safe APIs:
    ```kotlin
    data class Server(val host: String, val tcpPort: Int) {
        fun start() {}
    }
    
    val server = Server(config[ServerSpec.host], config[ServerSpec.tcpPort])
    server.start()
    ```

5. Retrieve values from multiple sources without using config spec:

    ```kotlin
    val server = Config()
            .from.yaml.file("server.yml")
            .from.json.resource("server.json")
            .from.env()
            .from.systemProperties()
            .at("server")
            .toValue<Server>()
    server.start()
    ```

## Define items

Config items is declared in config spec, added to config by `Config#addSpec`. All items in same config spec have same prefix. Define a config spec with prefix `local.server`:

```kotlin
object ServerSpec : ConfigSpec("server") {
}
```

If the config spec is binding with single class, you can declare config spec as companion object of the class:

```kotlin
class Server {
    companion object : ConfigSpec("server") {
        val host by optional("0.0.0.0")
        val tcpPort by required<Int>()
    }
}
```

The config spec prefix can be automatically inferred from the class name, leading to further simplification like:

```kotlin
object ServerSpec : ConfigSpec() {
}
```

or

```kotlin
class Server {
    companion object : ConfigSpec() {
    }
}
```

Here are some examples showing the inference convention: `Uppercase` to `uppercase`, `lowercase` to `lowercase`, `SuffixSpec` to `suffix`, `TCPService` to `tcpService`.

The config spec can also be nested. For example, the path of `Service.Backend.Login.user` in the following example will be inferred as "service.backend.login.user":

```kotlin
object Service : ConfigSpec() {
    object Backend : ConfigSpec() {
        object Login : ConfigSpec() {
            val user by optional("admin")
        }
    }
}
```

There are three kinds of item:

- Required item. Required item doesn't have default value, thus must be set with value before retrieved in config. Define a required item with description:
    ```kotlin
    val tcpPort by required<Int>(description = "port of server")
    ```
    Or omit the description:
    ```kotlin
    val tcpPort by required<Int>()
    ```
- Optional item. Optional item has default value, thus can be safely retrieved before setting. Define an optional item:
    ```kotlin
    val host by optional("0.0.0.0", description = "host IP of server")
    ```
    Description can be omitted.
- Lazy item. Lazy item also has default value, however, the default value is not a constant, it is evaluated from thunk every time when retrieved. Define a lazy item:
    ```kotlin
    val nextPort by lazy { config -> config[tcpPort] + 1 }
    ```

You can also define config spec in Java, with a more verbose API (compared to Kotlin version in "quick start"):

```java
public class ServerSpec {
  public static final ConfigSpec spec = new ConfigSpec("server");

  public static final OptionalItem<String> host =
      new OptionalItem<String>(spec, "host", "0.0.0.0") {};

  public static final RequiredItem<Integer> tcpPort = new RequiredItem<Integer>(spec, "tcpPort") {};
}
```

Notice that the `{}` part in item declaration is necessary to avoid type erasure of item's type information.

## Use config

### Create config

Create an empty new config:

```kotlin
val config = Config()
```

Or an new config with some initial actions:

```kotlin
val config = Config { addSpec(Server) }
```

### Add config spec

Add multiple config specs into config:

```kotlin
config.addSpec(Server)
config.addSpec(Client)
```

### Retrieve value from config

Retrieve associated value with item (type-safe API):

```kotlin
val host = config[Server.host]
```

Retrieve associated value with item name (unsafe API):

```kotlin
val host = config.get<String>("server.host")
```

or:

```kotlin
val host = config<String>("server.host")
```

### Cast config to value

Cast config to a value with the target type:

```kotlin
val server = config.toValue<Server>()
```

### Check whether an item exists in config or not

Check whether an item exists in config or not:

```kotlin
config.contains(Server.host)
// or
Server.host in config
```

Check whether an item name exists in config or not:

```kotlin
config.contains("server.host")
// or
"server.host" in config
```

Check whether all values of required items exist in config or not:

```kotlin
config.containsRequired()
```

Throw exception if some required items in config don't have values:

```kotlin
config.validateRequired()
```

### Modify value in config

Associate item with value (type-safe API):

```kotlin
config[Server.tcpPort] = 80
```

Find item with specified name, and associate it with value (unsafe API):

```kotlin
config["server.tcpPort"] = 80
```

Discard associated value of item:

```kotlin
config.unset(Server.tcpPort)
```

Discard associated value of item with specified name:

```kotlin
config.unset("server.tcpPort")
```

Associate item with lazy thunk (type-safe API):

```kotlin
config.lazySet(Server.tcpPort) { it[basePort] + 1 }
```

Find item with specified name, and associate it with lazy thunk (unsafe API):

```kotlin
config.lazySet("server.tcpPort") { it[basePort] + 1 }
```

### Subscribe the update event

Subscribe the update event of an item:

```kotlin
val handler = Server.host.onSet { value -> println("the host has changed to $value") }
```

Subscribe the update event before every set operation:

```kotlin
val handler = Server.host.beforeSet { config, value -> println("the host will change to $value") }
```

or

```kotlin
val handler = config.beforeSet { item, value -> println("${item.name} will change to $value") }
```

Subscribe the update event after every set operation:

```kotlin
val handler = Server.host.afterSet { config, value -> println("the host has changed to $value") }
```

or

```kotlin
val handler = config.afterSet { item, value -> println("${item.name} has changed to $value") }
```

Cancel the subscription:

```kotlin
handler.cancel()
```

### Export value in config as property

Export a read-write property from value in config:

```kotlin
var port by config.property(Server.tcpPort)
port = 9090
check(port == 9090)
```

Export a read-only property from value in config:

```kotlin
val port by config.property(Server.tcpPort)
check(port == 9090)
```

### Fork from another config

```kotlin
val config = Config { addSpec(Server) }
config[Server.tcpPort] = 1000
// fork from parent config
val childConfig = config.withLayer("child")
// child config inherit values from parent config
check(childConfig[Server.tcpPort] == 1000)
// modifications in parent config affect values in child config
config[Server.tcpPort] = 2000
check(config[Server.tcpPort] == 2000)
check(childConfig[Server.tcpPort] == 2000)
// modifications in child config don't affect values in parent config
childConfig[Server.tcpPort] = 3000
check(config[Server.tcpPort] == 2000)
check(childConfig[Server.tcpPort] == 3000)
```

## Load values from source

Use `from` to load values from source doesn't affect values in config, it will return a new child config by loading all values into new layer in child config:

```kotlin
val config = Config { addSpec(Server) }
// values in source is loaded into new layer in child config
val childConfig = config.from.env()
check(childConfig.parent === config)
```

All out-of-box supported sources are declared in [`DefaultLoaders`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/DefaultLoaders.kt), shown below (the corresponding config spec for these samples is [`ConfigForLoad`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/test/kotlin/com/uchuhimo/konf/source/ConfigForLoad.kt)):

| Type                                                         | Usage                            | Provider                                                     | Sample                                                       |
| ------------------------------------------------------------ | -------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [HOCON](https://github.com/typesafehub/config/blob/master/HOCON.md) | `config.from.hocon`              | [`HoconProvider`](https://github.com/uchuhimo/konf/blob/master/konf-hocon/src/main/kotlin/com/uchuhimo/konf/source/hocon/HoconProvider.kt) | [`source.conf`](https://github.com/uchuhimo/konf/blob/master/konf-hocon/src/test/resources/source/source.conf) |
| JSON                                                         | `config.from.json`               | [`JsonProvider`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/json/JsonProvider.kt) | [`source.json`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/test/resources/source/source.json) |
| properties                                                   | `config.from.properties`         | [`PropertiesProvider`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/properties/PropertiesProvider.kt) | [`source.properties`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/test/resources/source/source.properties) |
| [TOML](https://github.com/toml-lang/toml)                    | `config.from.toml`               | [`TomlProvider`](https://github.com/uchuhimo/konf/blob/master/konf-toml/src/main/kotlin/com/uchuhimo/konf/source/toml/TomlProvider.kt) | [`source.toml`](https://github.com/uchuhimo/konf/blob/master/konf-toml/src/test/resources/source/source.toml) |
| XML                                                          | `config.from.xml`                | [`XmlProvider`](https://github.com/uchuhimo/konf/blob/master/konf-xml/src/main/kotlin/com/uchuhimo/konf/source/xml/XmlProvider.kt) | [`source.xml`](https://github.com/uchuhimo/konf/blob/master/konf-xml/src/test/resources/source/source.xml) |
| YAML                                                         | `config.from.yaml`               | [`YamlProvider`](https://github.com/uchuhimo/konf/blob/master/konf-yaml/src/main/kotlin/com/uchuhimo/konf/source/yaml/YamlProvider.kt) | [`source.yaml`](https://github.com/uchuhimo/konf/blob/master/konf-yaml/src/test/resources/source/source.yaml) |
| JavaScript                                                   | `config.from.js`                 | [`JsProvider`](https://github.com/uchuhimo/konf/blob/master/konf-js/src/main/kotlin/com/uchuhimo/konf/source/js/JsProvider.kt) | [`source.js`](https://github.com/uchuhimo/konf/blob/master/konf-js/src/test/resources/source/source.js) |
| hierarchical map                                             | `config.from.map.hierarchical`   | -                                                            | [`MapSourceLoadSpec`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/MapSourceLoadSpec.kt) |
| map in key-value format                                      | `config.from.map.kv`             | -                                                            | [`KVSourceSpec`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/KVSourceSpec.kt) |
| map in flat format                                           | `config.from.map.flat`           | -                                                            | [`FlatSourceLoadSpec`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/FlatSourceLoadSpec.kt) |
| system environment                                           | `config.from.env()`              | [`EnvProvider`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/env/EnvProvider.kt) | -                                                            |
| system properties                                            | `config.from.systemProperties()` | [`PropertiesProvider`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/properties/PropertiesProvider.kt) | -                                                            |

These sources can also be manually created using their provider, and then loaded into config by `config.withSource(source)`.

All `from` APIs also have their standalone version that return sources without loading them into the config, shown below:

| Type                                                         | Usage                            |
| ------------------------------------------------------------ | -------------------------------- |
| [HOCON](https://github.com/typesafehub/config/blob/master/HOCON.md) | `Source.from.hocon`              |
| JSON                                                         | `Source.from.json`               |
| properties                                                   | `Source.from.properties`         |
| [TOML](https://github.com/toml-lang/toml)                    | `Source.from.toml`               |
| XML                                                          | `Source.from.xml`                |
| YAML                                                         | `Source.from.yaml`               |
| JavaScript                                                   | `Source.from.js`                 |
| hierarchical map                                             | `Source.from.map.hierarchical`   |
| map in key-value format                                      | `Source.from.map.kv`             |
| map in flat format                                           | `Source.from.map.flat`           |
| system environment                                           | `Source.from.env()`              |
| system properties                                            | `Source.from.systemProperties()` |

Format of system properties source is same with that of properties source. System environment source follows the same mapping convention with properties source, but with the following name convention:

- All letters in name are in uppercase
- `.` in name is replaced with `_`

HOCON/JSON/properties/TOML/XML/YAML/JavaScript source can be loaded from a variety of input format. Use properties source as example:

- From file: `config.from.properties.file("/path/to/file")`
- From watched file: `config.from.properties.watchFile("/path/to/file", 100, TimeUnit.MILLISECONDS)`
  - You can re-trigger the setup process every time the updated file is loaded by `watchFile("/path/to/file") { config, source -> setup(config) }`
- From string: `config.from.properties.string("server.port = 8080")`
- From URL: `config.from.properties.url("http://localhost:8080/source.properties")`
- From watched URL: `config.from.properties.watchUrl("http://localhost:8080/source.properties", 1, TimeUnit.MINUTES)`
  - You can re-trigger the setup process every time the URL is loaded by `watchUrl("http://localhost:8080/source.properties") { config, source -> setup(config) }`
- From Git repository: `config.from.properties.git("https://github.com/uchuhimo/konf.git", "/path/to/source.properties", branch = "dev")`
- From watched Git repository: `config.from.properties.watchGit("https://github.com/uchuhimo/konf.git", "/path/to/source.properties", period = 1, unit = TimeUnit.MINUTES)`
  - You can re-trigger the setup process every time the Git file is loaded by `watchGit("https://github.com/uchuhimo/konf.git", "/path/to/source.properties") { config, source -> setup(config) }`
- From resource: `config.from.properties.resource("source.properties")`
- From reader: `config.from.properties.reader(reader)`
- From input stream: `config.from.properties.inputStream(inputStream)`
- From byte array: `config.from.properties.bytes(bytes)`
- From portion of byte array: `config.from.properties.bytes(bytes, 1, 12)`

If source is from file, file extension can be auto detected. Thus, you can use `config.from.file("/path/to/source.json")` instead of `config.from.json.file("/path/to/source.json")`, or use `config.from.watchFile("/path/to/source.json")` instead of `config.from.json.watchFile("/path/to/source.json")`. Source from URL also support auto-detected extension (use `config.from.url` or `config.from.watchUrl`). The following file extensions can be supported:

| Type       | Extension  |
| ---------- | ---------- |
| HOCON      | conf       |
| JSON       | json       |
| Properties | properties |
| TOML       | toml       |
| XML        | xml        |
| YAML       | yml, yaml  |
| JavaScript | js         |

You can also implement [`Source`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/Source.kt) to customize your new source, which can be loaded into config by `config.withSource(source)`.

### Subscribe the update event for load operation

Subscribe the update event before every load operation:

```kotlin
val handler = config.beforeLoad { source -> println("$source will be loaded") }
```

You can re-trigger the setup process by subscribing the update event after every load operation:

```kotlin
val handler = config.afterLoad { source -> setup(config) }
```

Cancel the subscription:

```kotlin
handler.cancel()
```

### Strict parsing when loading

By default, Konf extracts desired paths from sources and ignores other unknown paths in sources. If you want Konf to throws exception when unknown paths are found, you can enable `FAIL_ON_UNKNOWN_PATH` feature:

```kotlin
config.enable(Feature.FAIL_ON_UNKNOWN_PATH)
    .from.properties.file("server.properties")
    .from.json.resource("server.json")
```

Then `config` will validate paths from both the properties file and the JSON resource. Furthermore, If you want to validate the properties file only, you can use:

```kotlin
config.from.enable(Feature.FAIL_ON_UNKNOWN_PATH).properties.file("/path/to/file")
    .from.json.resource("server.json")
```

### Path substitution

Path substitution is a feature that path references in source will be substituted by their values.

Path substitution rules are shown below:

- Only quoted string value will be substituted. It means that Konf's path substitutions will not conflict with HOCON's substitutions.
- The definition of a path variable is `${path}`, e.g., `${java.version}`.
- The path variable is resolved in the context of the current source.
- If the string value only contains the path variable, it will be replaced by the whole sub-tree in the path; otherwise, it will be replaced by the string value in the path.
- Use `${path:-default}` to provide a default value when the path is unresolved, e.g., `${java.version:-8}`.
- Use `$${path}` to escape the path variable, e.g., `$${java.version}` will be resolved to `${java.version}` instead of the value in `java.version`.
- Path substitution works in a recursive way, so nested path variables like `${jre-${java.specification.version}}` are allowed.
- Konf also supports all key prefix of [StringSubstitutor](https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/StringSubstitutor.html)'s default interpolator. 

By default, Konf will perform path substitution for every source (except system environment source) when loading them into the config.
You can disable this behaviour by using `config.disable(Feature.SUBSTITUTE_SOURCE_BEFORE_LOADED)` for the config 
or `source.disabled(Feature.SUBSTITUTE_SOURCE_BEFORE_LOADED)` for a single source.

By default, Konf will throw exception when some path variables are unresolved. You can use `source.substituted(false)` manually to ignore these unresolved variables.

To resolve path variables refer to other sources, you can merge these sources before loading them into the config.
For example, if we have two sources `source1.json` and `source2.properties`,
`source1.json` is:

```json
{ 
  "base" : { "user" : "konf" , "password" : "passwd" }
}
```

`source2.properties` is:

```properties
connection.jdbc=mysql://${base.user}:${base.password}@server:port
```

use:

```kotlin
config.withSource(
    Source.from.file("source1.json") +
    Source.from.file("source2.properties")
)
```

We can resolve `mysql://${base.user}:${base.password}@server:port` as `mysql://konf:passwd@server:port`.

## Prefix/Merge operations for source/config/config spec

All of source/config/config spec support add prefix operation, remove prefix operation and merge operation as shown below:

| Type     | Add Prefix                                                   | Remove Prefix                                               | Merge                                                  |
| -------- | ------------------------------------------------------------ | ----------------------------------------------------------- | ------------------------------------------------------ |
| `Source` | `source.withPrefix(prefix)` or `Prefix(prefix) + source` or `config.from.prefixed(prefix).file(file)` | `source[prefix]` or `config.from.scoped(prefix).file(file)` | `fallback + facade` or `facade.withFallback(fallback)` |
| `Config` | `config.withPrefix(prefix)` or `Prefix(prefix) + config`     | `config.at(prefix)`                                         | `fallback + facade` or `facade.withFallback(fallback)` |
| `Spec`   | `spec.withPrefix(prefix)` or `Prefix(prefix) + spec`         | `spec[prefix]`                                              | `fallback + facade` or `facade.withFallback(fallback)` |

## Export/Reload values in config

Export all values in config as a tree:

```kotlin
val tree = config.toTree()
```

Export all values in config to map in key-value format:

```kotlin
val map = config.toMap()
```

Export all values in config to hierarchical map:

```kotlin
val map = config.toHierarchicalMap()
```

Export all values in config to map in flat format:

```kotlin
val map = config.toFlatMap()
```

Export all values in config to JSON:

```kotlin
val file = createTempFile(suffix = ".json")
config.toJson.toFile(file)
```

Reload values from JSON:

```kotlin
val newConfig = Config {
    addSpec(Server)
}.from.json.file(file)
check(config == newConfig)
```

Config can be saved to a variety of output format in HOCON/JSON/properties/TOML/XML/YAML/JavaScript. Use JSON as example:

- To file: `config.toJson.toFile("/path/to/file")`
- To string: `config.toJson.toText()`
- To writer: `config.toJson.toWriter(writer)`
- To output stream: `config.toJson.toOutputStream(outputStream)`
- To byte array: `config.toJson.toBytes()`

You can also implement [`Writer`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/Writer.kt) to customize your new writer (see [`JsonWriter`](https://github.com/uchuhimo/konf/blob/master/konf-core/src/main/kotlin/com/uchuhimo/konf/source/json/JsonWriter.kt) for how to integrate your writer with config).

## Supported item types

Supported item types include:

- All primitive types
- All primitive array types
- `BigInteger`
- `BigDecimal`
- `String`
- Date and Time
    - `java.util.Date`
    - `OffsetTime`
    - `OffsetDateTime`
    - `ZonedDateTime`
    - `LocalDate`
    - `LocalTime`
    - `LocalDateTime`
    - `Year`
    - `YearMonth`
    - `Instant`
    - `Duration`
- `SizeInBytes`
- Enum
- Array
- Collection
    - `List`
    - `Set`
    - `SortedSet`
    - `Map`
    - `SortedMap`
- Kotlin Built-in classes
    - `Pair`
    - `Triple`
    - `IntRange`
    - `CharRange`
    - `LongRange`
- Data classes
- POJOs supported by Jackson core modules

Konf supports size in bytes format described in [HOCON document](https://github.com/typesafehub/config/blob/master/HOCON.md#size-in-bytes-format) with class `SizeInBytes`.

Konf supports both [ISO-8601 duration format](https://en.wikipedia.org/wiki/ISO_8601#Durations) and [HOCON duration format](https://github.com/typesafehub/config/blob/master/HOCON.md#duration-format) for `Duration`.

Konf uses [Jackson](https://github.com/FasterXML/jackson) to support Kotlin Built-in classes, Data classes and POJOs. You can use `config.mapper` to access `ObjectMapper` instance used by config, and configure it to support more types from third-party Jackson modules. Default modules registered by Konf include:

- Jackson core modules
- `JavaTimeModule` in [jackson-modules-java8](https://github.com/FasterXML/jackson-modules-java8)
- [jackson-module-kotlin](https://github.com/FasterXML/jackson-module-kotlin)

## Optional features

There are some optional features that you can enable/disable in the config scope or the source scope by `Config#enable(Feature)`/`Config#disable(Feature)` or `Source#enabled(Feature)`/`Source#disable(Feature)`. You can use `Config#isEnabled()` or `Source#isEnabled()` to check whether a feature is enabled.

These features include:

- `FAIL_ON_UNKNOWN_PATH`: feature that determines what happens when unknown paths appear in the source. If enabled, an exception is thrown when loading from the source to indicate it contains unknown paths. This feature is disabled by default.
- `LOAD_KEYS_CASE_INSENSITIVELY`: feature that determines whether loading keys from sources case-insensitively. This feature is disabled by default except for system environment.
- `LOAD_KEYS_AS_LITTLE_CAMEL_CASE`: feature that determines whether loading keys from sources as little camel case. This feature is enabled by default.
- `OPTIONAL_SOURCE_BY_DEFAULT`: feature that determines whether sources are optional by default. This feature is disabled by default.
- `SUBSTITUTE_SOURCE_BEFORE_LOADED`: feature that determines whether sources should be substituted before loaded into config. This feature is enabled by default.

## Build from source

Build library with Gradle using the following command:

```
./gradlew clean assemble
```

Test library with Gradle using the following command:

```
./gradlew clean test
```

Since Gradle has excellent incremental build support, you can usually omit executing the `clean` task.

Install library in a local Maven repository for consumption in other projects via the following command:

```
./gradlew clean install
```

## Breaking Changes

### v0.19.0

Since all sources are substituted before loaded into config by default, all path variables will be substituted now. You can use `config.disable(Feature.SUBSTITUTE_SOURCE_BEFORE_LOADED)` to disable this change.

### v0.17.0

After migrated to tree-based source APIs, many deprecated APIs are removed, including:

- `Source`: all `isXXX` and `toXXX` APIs
- `Config`: `layer`, `addSource` and `withSourceFrom`

### v0.15

After modularized Konf, `hocon`/`toml`/`xml`/`yaml`/`git`/`watchGit` in `DefaultLoaders` become extension properties/functions and should be imported explicitly.
For example, you should import `com.uchuhimo.konf.source.hocon` before using `config.from.hocon`; in Java, `config.from().hocon` is unavailable, please use `config.from().source(HoconProvider.INSTANCE)` instead.

If you use JitPack, you should use `com.github.uchuhimo.konf:konf:<version>` instead of `com.github.uchuhimo:konf:<version>` now.

### v0.10

APIs in `ConfigSpec` have been updated to support item name's auto-detection, please migrate to new APIs. Here are some examples:

- `val host = optional("host", "0.0.0.0")` to `val host by optional("0.0.0.0")`
- `val port = required<Int>("port")` to `val port by required<Int>()`
- `val nextPort = lazy("nextPort") { config -> config[port] + 1 }` to `val nextPort by lazy { config -> config[port] + 1 }`

# License

© uchuhimo, 2017-2019. Licensed under an [Apache 2.0](./LICENSE) license.


================================================
FILE: build.gradle.kts
================================================
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
import java.util.Properties

val ossUserToken by extra { getPrivateProperty("ossUserToken") }
val ossUserPassword by extra { getPrivateProperty("ossUserPassword") }
val signPublications by extra { getPrivateProperty("signPublications") }
val useAliyun by extra { shouldUseAliyun() }

tasks.named<Wrapper>("wrapper") {
    gradleVersion = "7.0"
    distributionType = Wrapper.DistributionType.ALL
}

buildscript {
    repositories {
        if (shouldUseAliyun()) {
            aliyunMaven()
        } else {
            mavenCentral()
        }
    }
}

plugins {
    java
    `java-test-fixtures`
    jacoco
    `maven-publish`
    signing
    kotlin("jvm") version Versions.kotlin
    kotlin("plugin.allopen") version Versions.kotlin
    id("com.dorongold.task-tree") version Versions.taskTree
    id("me.champeau.gradle.jmh") version Versions.jmhPlugin
    id("com.diffplug.spotless") version Versions.spotless
    id("com.github.ben-manes.versions") version Versions.dependencyUpdate
    id("org.jetbrains.dokka") version Versions.dokka
}

allprojects {
    apply(plugin = "java")
    apply(plugin = "java-test-fixtures")
    apply(plugin = "jacoco")
    apply(plugin = "maven-publish")
    apply(plugin = "signing")
    apply(plugin = "org.jetbrains.kotlin.jvm")
    apply(plugin = "kotlin-allopen")
    apply(plugin = "com.dorongold.task-tree")
    apply(plugin = "me.champeau.gradle.jmh")
    apply(plugin = "com.diffplug.spotless")
    apply(plugin = "com.github.ben-manes.versions")
    apply(plugin = "org.jetbrains.dokka")

    group = "com.uchuhimo"
    version = "1.1.2"

    repositories {
        if (useAliyun) {
            aliyunMaven()
        } else {
            mavenCentral()
        }
        maven {
            url=uri("https://kotlin.bintray.com/kotlinx")
        }
    }

    val dependencyUpdates by tasks.existing(DependencyUpdatesTask::class)
    dependencyUpdates {
        revision = "release"
        outputFormatter = "plain"
        resolutionStrategy {
            componentSelection {
                all {
                    val rejected = listOf("alpha", "beta", "rc", "cr", "m", "preview", "b", "ea", "eap", "pr", "dev", "mt")
                        .map { qualifier -> Regex("(?i).*[.-]$qualifier[.\\d-+]*") }
                        .any { it.matches(candidate.version) }
                    if (rejected) {
                        reject("Release candidate")
                    }
                }
            }
        }
    }
}

subprojects {
    configurations.testFixturesImplementation.get().extendsFrom(configurations.implementation.get())
    configurations.testImplementation.get().extendsFrom(configurations.testFixturesImplementation.get())

    dependencies {
        api(kotlin("stdlib-jdk8", Versions.kotlin))
        api("org.jetbrains.kotlinx", "kotlinx-coroutines-core", Versions.coroutines)
        implementation(kotlin("reflect", Versions.kotlin))
        implementation("org.reflections", "reflections", Versions.reflections)
        implementation("org.apache.commons", "commons-text", Versions.commonsText)
        arrayOf("core", "annotations", "databind").forEach { name ->
            api(jacksonCore(name, Versions.jackson))
        }
        implementation(jackson("module", "kotlin", Versions.jackson))
        implementation(jackson("datatype", "jsr310", Versions.jackson))

        testFixturesImplementation(kotlin("test", Versions.kotlin))
        testFixturesImplementation("com.natpryce", "hamkrest", Versions.hamkrest)
        testFixturesImplementation("org.hamcrest", "hamcrest-all", Versions.hamcrest)
        testImplementation(junit("jupiter", "api", Versions.junit))
        testImplementation("com.sparkjava", "spark-core", Versions.spark)
        arrayOf("api", "data-driven-extension", "subject-extension").forEach { name ->
            testFixturesImplementation(spek(name, Versions.spek))
        }

        testRuntimeOnly(junit("platform", "launcher", Versions.junitPlatform))
        testRuntimeOnly(junit("jupiter", "engine", Versions.junit))
        testRuntimeOnly(spek("junit-platform-engine", Versions.spek))
        testRuntimeOnly("org.slf4j", "slf4j-simple", Versions.slf4j)
    }

    java {
        sourceCompatibility = Versions.java
        targetCompatibility = Versions.java
    }

    val test by tasks.existing(Test::class)
    test {
        useJUnitPlatform()
        testLogging.apply {
            showStandardStreams = true
            showExceptions = true
            showCauses = true
            showStackTraces = true
        }
        systemProperties["org.slf4j.simpleLogger.defaultLogLevel"] = "warn"
        systemProperties["junit.jupiter.execution.parallel.enabled"] = true
        systemProperties["junit.jupiter.execution.parallel.mode.default"] = "concurrent"
        maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
        val properties = Properties()
        properties.load(rootProject.file("konf-core/src/test/kotlin/com/uchuhimo/konf/source/env/env.properties").inputStream())
        properties.forEach { key, value ->
            environment(key as String, value)
        }
    }

    tasks.withType<JavaCompile> {
        options.encoding = "UTF-8"
    }

    tasks.withType<KotlinCompile> {
        kotlinOptions {
            jvmTarget = Versions.java.toString()
            apiVersion = Versions.kotlinApi
            languageVersion = Versions.kotlinLanguage
        }
    }

    allOpen {
        annotation("org.openjdk.jmh.annotations.BenchmarkMode")
        annotation("org.openjdk.jmh.annotations.State")
    }

    jmh {
        //jvmArgs = ["-Djmh.separateClasspathJAR=true"]
        iterations = 10 // Number of measurement iterations to do.
        //benchmarkMode = ["thrpt"] // Benchmark mode. Available modes are: [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all]
        batchSize = 1
        // Batch size: number of benchmark method calls per operation. (some benchmark modes can ignore this setting)
        fork = 1 // How many times to forks a single benchmark. Use 0 to disable forking altogether
        //operationsPerInvocation = 1 // Operations per invocation.
        timeOnIteration = "1s" // Time to spend at each measurement iteration.
        threads = 4 // Number of worker threads to run with.
        timeout = "10s" // Timeout for benchmark iteration.
        //timeUnit = "ns" // Output time unit. Available time units are: [m, s, ms, us, ns].
        verbosity = "NORMAL" // Verbosity mode. Available modes are: [SILENT, NORMAL, EXTRA]
        warmup = "1s" // Time to spend at each warmup iteration.
        warmupBatchSize = 1 // Warmup batch size: number of benchmark method calls per operation.
        //warmupForks = 0 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks.
        warmupIterations = 10 // Number of warmup iterations to do.
        isZip64 = false // Use ZIP64 format for bigger archives
        jmhVersion = Versions.jmh // Specifies JMH version
    }

    spotless {
        java {
            googleJavaFormat(Versions.googleJavaFormat)
            trimTrailingWhitespace()
            endWithNewline()
            licenseHeaderFile(rootProject.file("config/spotless/apache-license-2.0.java"))
        }
        kotlin {
            ktlint(Versions.ktlint)
            trimTrailingWhitespace()
            endWithNewline()
            licenseHeaderFile(rootProject.file("config/spotless/apache-license-2.0.kt"))
        }
    }

    jacoco {
        toolVersion = Versions.jacoco
    }

    val jacocoTestReport by tasks.existing(JacocoReport::class) {
        reports {
            xml.isEnabled = true
            html.isEnabled = true
        }
    }

    val check by tasks.existing {
        dependsOn(jacocoTestReport)
    }

    tasks.dokkaHtml {
        outputDirectory.set(tasks.javadoc.get().destinationDir)
        dokkaSourceSets {
            configureEach {
                jdkVersion.set(9)
                reportUndocumented.set(false)
                sourceLink {
                    localDirectory.set(file("./"))
                    remoteUrl.set(URL("https://github.com/uchuhimo/konf/blob/v${project.version}/"))
                    remoteLineSuffix.set("#L")
                }
            }
        }
    }

    val sourcesJar by tasks.registering(Jar::class) {
        archiveClassifier.set("sources")
        from(sourceSets.main.get().allSource)
    }

    val javadocJar by tasks.registering(Jar::class) {
        archiveClassifier.set("javadoc")
        from(tasks.dokkaHtml)
    }

    val projectDescription = "A type-safe cascading configuration library for Kotlin/Java, " +
        "supporting most configuration formats"
    val projectGroup = project.group as String
    val projectName = if (project.name == "konf-all") "konf" else project.name
    val projectVersion = project.version as String
    val projectUrl = "https://github.com/uchuhimo/konf"

    publishing {
        publications {
            create<MavenPublication>("maven") {
                from(components["java"])
                artifact(sourcesJar.get())
                artifact(javadocJar.get())

                groupId = projectGroup
                artifactId = projectName
                version = projectVersion

                suppressPomMetadataWarningsFor("testFixturesApiElements")
                suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
                pom {
                    name.set(rootProject.name)
                    description.set(projectDescription)
                    url.set(projectUrl)
                    licenses {
                        license {
                            name.set("The Apache Software License, Version 2.0")
                            url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
                        }
                    }
                    developers {
                        developer {
                            id.set("uchuhimo")
                            name.set("uchuhimo")
                            email.set("uchuhimo@outlook.com")
                        }
                    }
                    scm {
                        url.set(projectUrl)
                    }
                }
            }
        }
        repositories {
            maven {
                url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
                credentials {
                    username = ossUserToken
                    password = ossUserPassword
                }
            }
        }
    }

    signing {
        setRequired({ signPublications == "true" })
        sign(publishing.publications["maven"])
    }

    tasks {
        val install by registering
        afterEvaluate {
            val publishToMavenLocal by existing
            val publish by existing
            install.configure { dependsOn(publishToMavenLocal) }
            publish { dependsOn(check, install) }
        }
    }
}


================================================
FILE: buildSrc/build.gradle.kts
================================================
plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
}

================================================
FILE: buildSrc/settings.gradle.kts
================================================


================================================
FILE: buildSrc/src/main/kotlin/Dependencies.kt
================================================
import org.gradle.api.JavaVersion

object Versions {
    val java = JavaVersion.VERSION_1_8
    const val commonsText = "1.9"
    const val coroutines = "1.4.3"
    const val dependencyUpdate = "0.38.0"
    const val dokka = "1.4.30"
    const val dom4j = "2.1.3"
    const val graal = "21.0.0.2"
    const val hamcrest = "1.3"
    const val hamkrest = "1.8.0.1"
    const val hocon = "1.4.1"
    const val jacksonMinor = "2.12"
    const val jackson = "$jacksonMinor.2"
    const val jacoco = "0.8.6"
    const val jaxen = "1.2.0"
    const val jgit = "5.11.0.202103091610-r"
    const val jmh = "1.25.2"
    const val jmhPlugin = "0.5.3"
    const val junit = "5.7.1"
    const val junitPlatform = "1.7.1"
    const val kotlin = "1.4.32"
    const val kotlinApi = "1.4"
    const val kotlinLanguage = "1.4"
    const val reflections = "0.9.12"
    const val slf4j = "1.7.30"
    const val spark = "2.9.3"
    const val spek = "1.1.5"
    const val spotless = "5.11.1"
    const val taskTree = "1.5"
    const val toml4j = "0.7.2"
    const val yaml = "1.28"

    // Since 1.8, the minimum supported runtime version is JDK 11.
    const val googleJavaFormat = "1.7"
    const val ktlint = "0.41.0"
}


fun String?.withColon() = this?.let { ":$this" } ?: ""

fun kotlin(module: String, version: String? = null) =
    "org.jetbrains.kotlin:kotlin-$module${version.withColon()}"

fun spek(module: String, version: String? = null) =
    "org.jetbrains.spek:spek-$module${version.withColon()}"

fun jackson(scope: String, module: String, version: String? = null) =
    "com.fasterxml.jackson.$scope:jackson-$scope-$module${version.withColon()}"

fun jacksonCore(module: String = "core", version: String? = null) =
    "com.fasterxml.jackson.core:jackson-$module${version.withColon()}"

fun junit(scope: String, module: String, version: String? = null) =
    "org.junit.$scope:junit-$scope-$module${version.withColon()}"


================================================
FILE: buildSrc/src/main/kotlin/Utils.kt
================================================
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.kotlin.dsl.maven
import org.w3c.dom.Element
import java.util.Properties

fun Project.getPrivateProperty(key: String): String {
    return if (file("private.properties").exists()) {
        val properties = Properties()
        properties.load(file("private.properties").inputStream())
        properties.getProperty(key)
    } else {
        ""
    }
}

fun Project.shouldUseAliyun(): Boolean = if (file("private.properties").exists()) {
    val properties = Properties()
    properties.load(file("private.properties").inputStream())
    properties.getProperty("useAliyun")?.toBoolean() ?: false
} else {
    false
}

fun RepositoryHandler.aliyunMaven() = maven(url = "https://maven.aliyun.com/repository/central")

fun RepositoryHandler.aliyunGradlePluginPortal() = maven(url = "https://maven.aliyun.com/repository/gradle-plugin")

fun Element.appendNode(key: String, action: Element.() -> Unit): Element {
    return apply {
        appendChild(ownerDocument.createElement(key).apply {
            action()
        })
    }
}

fun Element.appendNode(key: String, value: String): Element {
    return appendNode(key) {
        appendChild(ownerDocument.createTextNode(value))
    }
}


================================================
FILE: config/spotless/apache-license-2.0.java
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



================================================
FILE: config/spotless/apache-license-2.0.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists


================================================
FILE: gradle.properties
================================================
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en_US
org.gradle.caching=true
org.gradle.vfs.watch=true
#org.gradle.parallel=true
#org.gradle.configureondemand=true


================================================
FILE: gradlew
================================================
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
##  Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
    echo "$*"
}

die () {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
  NONSTOP* )
    nonstop=true
    ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

    JAVACMD=`cygpath --unix "$JAVACMD"`

    # We build the pattern for arguments to be converted via cygpath
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        i=`expr $i + 1`
    done
    case $i in
        0) set -- ;;
        1) set -- "$args0" ;;
        2) set -- "$args0" "$args1" ;;
        3) set -- "$args0" "$args1" "$args2" ;;
        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
    esac
fi

# Escape application args
save () {
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
    echo " "
}
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "$@"


================================================
FILE: gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem      https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega


================================================
FILE: konf-all/build.gradle.kts
================================================
sourceSets {
    register("snippet")
}

val snippetImplementation by configurations
snippetImplementation.extendsFrom(configurations.implementation.get())

dependencies {
    for (name in listOf(
        ":konf-core",
        ":konf-git",
        ":konf-hocon",
        ":konf-toml",
        ":konf-xml",
        ":konf-yaml"
    )) {
        api(project(name))
        testImplementation(testFixtures(project(name)))
    }

    snippetImplementation(sourceSets.main.get().output)
    val snippet by sourceSets
    testImplementation(snippet.output)
}


================================================
FILE: konf-all/src/snippet/java/com/uchuhimo/konf/snippet/ServerInJava.java
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet;

import com.uchuhimo.konf.Config;

public class ServerInJava {
  private String host;
  private Integer tcpPort;

  public ServerInJava(String host, Integer tcpPort) {
    this.host = host;
    this.tcpPort = tcpPort;
  }

  public ServerInJava(Config config) {
    this(config.get(ServerSpecInJava.host), config.get(ServerSpecInJava.tcpPort));
  }

  public String getHost() {
    return host;
  }

  public Integer getTcpPort() {
    return tcpPort;
  }
}


================================================
FILE: konf-all/src/snippet/java/com/uchuhimo/konf/snippet/ServerSpecInJava.java
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet;

import com.uchuhimo.konf.ConfigSpec;
import com.uchuhimo.konf.OptionalItem;
import com.uchuhimo.konf.RequiredItem;

public class ServerSpecInJava {
  public static final ConfigSpec spec = new ConfigSpec("server");

  public static final OptionalItem<String> host =
      new OptionalItem<String>(spec, "host", "0.0.0.0") {};

  public static final RequiredItem<Integer> tcpPort = new RequiredItem<Integer>(spec, "tcpPort") {};
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Config.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.ConfigSpec

fun main(args: Array<String>) {
    val config = Config()
    config.addSpec(Server)
    run {
        val host = config[Server.host]
    }
    run {
        val host = config.get<String>("server.host")
    }
    run {
        val host = config<String>("server.host")
    }
    config.contains(Server.host)
    // or
    Server.host in config
    config.contains("server.host")
    // or
    "server.host" in config
    config[Server.tcpPort] = 80
    config["server.tcpPort"] = 80
    config.containsRequired()
    config.validateRequired()
    config.unset(Server.tcpPort)
    config.unset("server.tcpPort")
    val basePort by ConfigSpec("server").required<Int>()
    config.lazySet(Server.tcpPort) { it[basePort] + 1 }
    config.lazySet("server.tcpPort") { it[basePort] + 1 }
    run {
        val handler = Server.host.onSet { value -> println("the host has changed to $value") }
        handler.cancel()
    }
    run {
        val handler = Server.host.beforeSet { config, value -> println("the host will change to $value") }
        handler.cancel()
    }
    run {
        val handler = config.beforeSet { item, value -> println("${item.name} will change to $value") }
        handler.cancel()
    }
    run {
        val handler = Server.host.afterSet { config, value -> println("the host has changed to $value") }
        handler.cancel()
    }
    run {
        val handler = config.afterSet { item, value -> println("${item.name} has changed to $value") }
        handler.cancel()
    }
    run {
        var port by config.property(Server.tcpPort)
        port = 9090
        check(port == 9090)
    }
    run {
        val port by config.property(Server.tcpPort)
        check(port == 9090)
    }
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Export.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.source.base.toFlatMap
import com.uchuhimo.konf.source.base.toHierarchicalMap
import com.uchuhimo.konf.source.json.toJson
import com.uchuhimo.konf.tempFile

fun main(args: Array<String>) {
    val config = Config { addSpec(Server) }
    config[Server.tcpPort] = 1000
    run {
        val map = config.toMap()
    }
    run {
        val map = config.toHierarchicalMap()
    }
    run {
        val map = config.toFlatMap()
    }
    val file = tempFile(suffix = ".json")
    config.toJson.toFile(file)
    val newConfig = Config {
        addSpec(Server)
    }.from.json.file(file)
    check(config.toMap() == newConfig.toMap())
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Fork.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config

fun main(args: Array<String>) {
    val config = Config { addSpec(Server) }
    config[Server.tcpPort] = 1000
    // fork from parent config
    val childConfig = config.withLayer("child")
    // child config inherit values from parent config
    check(childConfig[Server.tcpPort] == 1000)
    // modifications in parent config affect values in child config
    config[Server.tcpPort] = 2000
    check(config[Server.tcpPort] == 2000)
    check(childConfig[Server.tcpPort] == 2000)
    // modifications in child config don't affect values in parent config
    childConfig[Server.tcpPort] = 3000
    check(config[Server.tcpPort] == 2000)
    check(childConfig[Server.tcpPort] == 3000)
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Load.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config

fun main(args: Array<String>) {
    val config = Config { addSpec(Server) }
    // values in source is loaded into new layer in child config
    val childConfig = config.from.env()
    check(childConfig.parent === config)
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/QuickStart.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.ConfigSpec
import com.uchuhimo.konf.source.Source
import com.uchuhimo.konf.source.toValue
import com.uchuhimo.konf.source.yaml
import com.uchuhimo.konf.toValue
import java.io.File

object ServerSpec : ConfigSpec() {
    val host by optional("0.0.0.0")
    val tcpPort by required<Int>()
}

fun main(args: Array<String>) {
    val file = File("server.yml")
    //language=YAML
    file.writeText(
        """
        server:
            host: 127.0.0.1
            tcp_port: 8080
        """.trimIndent()
    )
    file.deleteOnExit()
    val config = Config { addSpec(ServerSpec) }
        .from.yaml.file("server.yml")
        .from.json.resource("server.json")
        .from.env()
        .from.systemProperties()
    run {
        val config = Config { addSpec(ServerSpec) }.withSource(
            Source.from.yaml.file("server.yml") +
                Source.from.json.resource("server.json") +
                Source.from.env() +
                Source.from.systemProperties()
        )
    }
    run {
        val config = Config { addSpec(ServerSpec) }
            .from.yaml.watchFile("server.yml")
            .from.json.resource("server.json")
            .from.env()
            .from.systemProperties()
    }
    val server = Server(config[ServerSpec.host], config[ServerSpec.tcpPort])
    server.start()
    run {
        val server = Config()
            .from.yaml.file("server.yml")
            .from.json.resource("server.json")
            .from.env()
            .from.systemProperties()
            .at("server")
            .toValue<Server>()
        server.start()
    }
    run {
        val server = (
            Source.from.yaml.file("server.yml") +
                Source.from.json.resource("server.json") +
                Source.from.env() +
                Source.from.systemProperties()
            )["server"]
            .toValue<Server>()
        server.start()
    }
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Serialize.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.tempFile
import java.io.ObjectInputStream
import java.io.ObjectOutputStream

fun main(args: Array<String>) {
    val config = Config { addSpec(Server) }
    config[Server.tcpPort] = 1000
    val map = config.toMap()
    val newMap = tempFile().run {
        ObjectOutputStream(outputStream()).use {
            it.writeObject(map)
        }
        ObjectInputStream(inputStream()).use {
            @Suppress("UNCHECKED_CAST")
            it.readObject() as Map<String, Any>
        }
    }
    val newConfig = Config {
        addSpec(Server)
    }.from.map.kv(newMap)
    check(config.toMap() == newConfig.toMap())
}


================================================
FILE: konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Server.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.snippet

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.ConfigSpec

data class Server(val host: String, val tcpPort: Int) {
    constructor(config: Config) : this(config[Server.host], config[Server.tcpPort])

    fun start() {}

    companion object : ConfigSpec("server") {
        val host by optional("0.0.0.0", description = "host IP of server")
        val tcpPort by required<Int>(description = "port of server")
        val nextPort by lazy { config -> config[tcpPort] + 1 }
    }
}


================================================
FILE: konf-all/src/snippet/resources/server.json
================================================
{
  "server": {
    "host": "127.0.0.1",
    "tcp_port": 8080
  }
}

================================================
FILE: konf-all/src/test/kotlin/com/uchuhimo/konf/source/MergeSourcesWithDifferentFeaturesSpec.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.source

import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import com.uchuhimo.konf.Config
import com.uchuhimo.konf.ConfigSpec
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on

object MergeSourcesWithDifferentFeaturesSpec : Spek({
    on("load from merged sources") {
        val config = Config {
            addSpec(ServicingConfig)
        }.withSource(
            Source.from.hocon.string(content) + Source.from.env()
        )
        it("should contain the item") {
            assertThat(config[ServicingConfig.baseURL], equalTo("https://service/api"))
            assertThat(config[ServicingConfig.url], equalTo("https://service/api/index.html"))
        }
    }
})

object ServicingConfig : ConfigSpec("servicing") {
    val baseURL by required<String>()
    val url by required<String>()
}

val content = """
    servicing {
      baseURL = "https://service/api"
      url = "${'$'}{servicing.baseURL}/index.html"
    }
""".trimIndent()


================================================
FILE: konf-all/src/test/kotlin/com/uchuhimo/konf/source/MultiLayerConfigToValueSpec.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.source

import com.fasterxml.jackson.databind.DeserializationFeature
import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import com.uchuhimo.konf.Config
import com.uchuhimo.konf.toValue
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on

object MultiLayerConfigToValueSpec : Spek({
    val yamlContent = """
db:
  driverClassName: org.h2.Driver
  url: 'jdbc:h2:mem:db;DB_CLOSE_DELAY=-1'
    """.trimIndent()

    val map = mapOf(
        "driverClassName" to "org.h2.Driver",
        "url" to "jdbc:h2:mem:db;DB_CLOSE_DELAY=-1"
    )
    on("load from multiple sources") {
        val config = Config {
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
        }
            .from.yaml.string(yamlContent)
            .from.yaml.file(
                System.getenv("SERVICE_CONFIG")
                    ?: "/opt/legacy-event-service/conf/legacy-event-service.yml",
                true
            )
            .from.systemProperties()
            .from.env()
        it("should cast to value correctly") {
            val db = config.toValue<ConfigTestReport>()
            assertThat(db.db, equalTo(map))
        }
    }
})

data class ConfigTestReport(val db: Map<String, String>)


================================================
FILE: konf-all/src/test/kotlin/com/uchuhimo/konf/source/MultipleDefaultLoadersSpec.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.source

import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import com.uchuhimo.konf.Config
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on

object MultipleDefaultLoadersSpec : Spek({
    on("load from multiple sources") {
        val config = Config {
            addSpec(DefaultLoadersConfig)
        }
        val item = DefaultLoadersConfig.type
        val afterLoadEnv = config.from.env()
        System.setProperty(config.nameOf(DefaultLoadersConfig.type), "system")
        val afterLoadSystemProperties = afterLoadEnv.from.systemProperties()
        val afterLoadHocon = afterLoadSystemProperties.from.hocon.string(hoconContent)
        val afterLoadJson = afterLoadHocon.from.json.string(jsonContent)
        val afterLoadProperties = afterLoadJson.from.properties.string(propertiesContent)
        val afterLoadToml = afterLoadProperties.from.toml.string(tomlContent)
        val afterLoadXml = afterLoadToml.from.xml.string(xmlContent)
        val afterLoadYaml = afterLoadXml.from.yaml.string(yamlContent)
        val afterLoadFlat = afterLoadYaml.from.map.flat(mapOf("source.test.type" to "flat"))
        val afterLoadKv = afterLoadFlat.from.map.kv(mapOf("source.test.type" to "kv"))
        val afterLoadHierarchical = afterLoadKv.from.map.hierarchical(
            mapOf(
                "source" to
                    mapOf(
                        "test" to
                            mapOf("type" to "hierarchical")
                    )
            )
        )
        it("should load the corresponding value in each layer") {
            assertThat(afterLoadEnv[item], equalTo("env"))
            assertThat(afterLoadSystemProperties[item], equalTo("system"))
            assertThat(afterLoadHocon[item], equalTo("conf"))
            assertThat(afterLoadJson[item], equalTo("json"))
            assertThat(afterLoadProperties[item], equalTo("properties"))
            assertThat(afterLoadToml[item], equalTo("toml"))
            assertThat(afterLoadXml[item], equalTo("xml"))
            assertThat(afterLoadYaml[item], equalTo("yaml"))
            assertThat(afterLoadFlat[item], equalTo("flat"))
            assertThat(afterLoadKv[item], equalTo("kv"))
            assertThat(afterLoadHierarchical[item], equalTo("hierarchical"))
        }
    }
})

//language=Json
const val jsonContent =
    """
{
  "source": {
    "test": {
      "type": "json"
    }
  }
}
"""


================================================
FILE: konf-all/src/test/kotlin/com/uchuhimo/konf/source/QuickStartSpec.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf.source

import com.natpryce.hamkrest.assertion.assertThat
import com.natpryce.hamkrest.equalTo
import com.uchuhimo.konf.Config
import com.uchuhimo.konf.snippet.Server
import com.uchuhimo.konf.snippet.ServerSpec
import com.uchuhimo.konf.toValue
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.api.dsl.on
import java.io.File

object QuickStartSpec : Spek({
    on("use default loaders") {
        val config = useFile {
            Config { addSpec(ServerSpec) }
                .from.yaml.file("server.yml")
                .from.json.resource("server.json")
                .from.env()
                .from.systemProperties()
        }
        it("should load all values") {
            assertThat(
                config.toMap(),
                equalTo(mapOf("server.host" to "127.0.0.1", "server.tcpPort" to 8080))
            )
        }
    }
    on("use default providers") {
        val config = useFile {
            Config { addSpec(ServerSpec) }.withSource(
                Source.from.yaml.file("server.yml") +
                    Source.from.json.resource("server.json") +
                    Source.from.env() +
                    Source.from.systemProperties()
            )
        }
        it("should load all values") {
            assertThat(
                config.toMap(),
                equalTo(mapOf("server.host" to "127.0.0.1", "server.tcpPort" to 8080))
            )
        }
    }
    on("watch file") {
        val config = useFile {
            Config { addSpec(ServerSpec) }
                .from.yaml.watchFile("server.yml")
                .from.json.resource("server.json")
                .from.env()
                .from.systemProperties()
        }
        it("should load all values") {
            assertThat(
                config.toMap(),
                equalTo(mapOf("server.host" to "127.0.0.1", "server.tcpPort" to 8080))
            )
        }
    }
    on("cast config to value") {
        val config = useFile {
            Config()
                .from.yaml.file("server.yml")
                .from.json.resource("server.json")
                .from.env()
                .from.systemProperties()
                .at("server")
        }
        val server = config.toValue<Server>()
        it("should load all values") {
            assertThat(server, equalTo(Server(host = "127.0.0.1", tcpPort = 8080)))
        }
    }
    on("cast source to value") {
        val source = useFile {
            (
                Source.from.yaml.file("server.yml") +
                    Source.from.json.resource("server.json") +
                    Source.from.env() +
                    Source.from.systemProperties()
                )["server"]
        }
        val server = source.toValue<Server>()
        it("should load all values") {
            assertThat(server, equalTo(Server(host = "127.0.0.1", tcpPort = 8080)))
        }
    }
})

private fun <T> useFile(block: () -> T): T {
    val file = File("server.yml")
    //language=YAML
    file.writeText(
        """
        server:
            host: 127.0.0.1
            tcp_port: 8080
        """.trimIndent()
    )
    try {
        return block()
    } finally {
        file.delete()
    }
}


================================================
FILE: konf-core/build.gradle.kts
================================================
dependencies {
    jmhImplementation(kotlin("stdlib", Versions.kotlin))
}


================================================
FILE: konf-core/src/jmh/kotlin/com/uchuhimo/konf/ConfigBenchmark.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
import org.openjdk.jmh.annotations.Mode.AverageTime
import org.openjdk.jmh.annotations.OutputTimeUnit
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.State
import java.util.concurrent.TimeUnit.NANOSECONDS

class Buffer {
    companion object : ConfigSpec("network.buffer") {
        val name by optional("buffer", description = "name of buffer")
    }
}

@BenchmarkMode(AverageTime)
@OutputTimeUnit(NANOSECONDS)
class ConfigBenchmark {

    @State(Scope.Thread)
    class ConfigState {
        val config = Config { addSpec(Buffer) }
        val path = Buffer.qualify(Buffer.name)
    }

    @State(Scope.Benchmark)
    class MultiThreadConfigState {
        val config = Config { addSpec(Buffer) }
        val path = Buffer.qualify(Buffer.name)
    }

    @Benchmark
    fun getWithItem(state: ConfigState) = state.config[Buffer.name]

    @Benchmark
    fun getWithItemFromMultiThread(state: MultiThreadConfigState) = state.config[Buffer.name]

    @Benchmark
    fun setWithItem(state: ConfigState) {
        state.config[Buffer.name] = "newName"
    }

    @Benchmark
    fun setWithItemFromMultiThread(state: MultiThreadConfigState) {
        state.config[Buffer.name] = "newName"
    }

    @Benchmark
    fun getWithPath(state: ConfigState) = state.config<String>(state.path)

    @Benchmark
    fun getWithPathFromMultiThread(state: MultiThreadConfigState) = state.config<String>(state.path)

    @Benchmark
    fun setWithPath(state: ConfigState) {
        state.config[state.path] = "newName"
    }

    @Benchmark
    fun setWithPathFromMultiThread(state: MultiThreadConfigState) {
        state.config[state.path] = "newName"
    }
}

@BenchmarkMode(AverageTime)
@OutputTimeUnit(NANOSECONDS)
class MultiLevelConfigBenchmark {

    @State(Scope.Thread)
    class ConfigState {
        val config = Config { addSpec(Buffer) }.withLayer().withLayer().withLayer().withLayer()
        val path = Buffer.qualify(Buffer.name)
    }

    @State(Scope.Benchmark)
    class MultiThreadConfigState {
        val config = Config { addSpec(Buffer) }.withLayer().withLayer().withLayer().withLayer()
        val path = Buffer.qualify(Buffer.name)
    }

    @Benchmark
    fun getWithItem(state: ConfigState) = state.config[Buffer.name]

    @Benchmark
    fun getWithItemFromMultiThread(state: MultiThreadConfigState) = state.config[Buffer.name]

    @Benchmark
    fun setWithItem(state: ConfigState) {
        state.config[Buffer.name] = "newName"
    }

    @Benchmark
    fun setWithItemFromMultiThread(state: MultiThreadConfigState) {
        state.config[Buffer.name] = "newName"
    }

    @Benchmark
    fun getWithPath(state: ConfigState) = state.config<String>(state.path)

    @Benchmark
    fun getWithPathFromMultiThread(state: MultiThreadConfigState) = state.config<String>(state.path)

    @Benchmark
    fun setWithPath(state: ConfigState) {
        state.config[state.path] = "newName"
    }

    @Benchmark
    fun setWithPathFromMultiThread(state: MultiThreadConfigState) {
        state.config[state.path] = "newName"
    }
}


================================================
FILE: konf-core/src/main/java/com/uchuhimo/konf/Configs.java
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf;

import java.util.function.Consumer;

/** Helper class for {@link com.uchuhimo.konf.Config Config}. */
public final class Configs {
  private Configs() {}

  /**
   * Create a new root config.
   *
   * @return a new root config
   */
  public static Config create() {
    return Config.Companion.invoke();
  }

  /**
   * Create a new root config and initiate it.
   *
   * @param init initial action
   * @return a new root config
   */
  public static Config create(Consumer<Config> init) {
    final Config config = create();
    init.accept(config);
    return config;
  }
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/BaseConfig.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.cfg.CoercionAction
import com.fasterxml.jackson.databind.cfg.CoercionInputShape
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.uchuhimo.konf.source.MergedSource
import com.uchuhimo.konf.source.Source
import com.uchuhimo.konf.source.base.EmptyMapSource
import com.uchuhimo.konf.source.deserializer.DurationDeserializer
import com.uchuhimo.konf.source.deserializer.EmptyStringToCollectionDeserializerModifier
import com.uchuhimo.konf.source.deserializer.OffsetDateTimeDeserializer
import com.uchuhimo.konf.source.deserializer.StringDeserializer
import com.uchuhimo.konf.source.deserializer.ZoneDateTimeDeserializer
import com.uchuhimo.konf.source.load
import com.uchuhimo.konf.source.loadItem
import com.uchuhimo.konf.source.toCompatibleValue
import java.time.Duration
import java.time.OffsetDateTime
import java.time.ZonedDateTime
import java.util.WeakHashMap
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.read
import kotlin.concurrent.write
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

/**
 * The default implementation for [Config].
 */
open class BaseConfig(
    override val name: String = "",
    override val parent: BaseConfig? = null,
    override val mapper: ObjectMapper = createDefaultMapper(),
    private val specsInLayer: MutableList<Spec> = mutableListOf(),
    private val featuresInLayer: MutableMap<Feature, Boolean> = mutableMapOf(),
    private val nodeByItem: MutableMap<Item<*>, ItemNode> = mutableMapOf(),
    private val tree: TreeNode = ContainerNode.placeHolder(),
    private val hasChildren: Value<Boolean> = Value(false),
    private val beforeSetFunctions: MutableList<(item: Item<*>, value: Any?) -> Unit> = mutableListOf(),
    private val afterSetFunctions: MutableList<(item: Item<*>, value: Any?) -> Unit> = mutableListOf(),
    private val beforeLoadFunctions: MutableList<(source: Source) -> Unit> = mutableListOf(),
    private val afterLoadFunctions: MutableList<(source: Source) -> Unit> = mutableListOf(),
    private val lock: ReentrantReadWriteLock = ReentrantReadWriteLock()
) : Config {
    private val _source: Value<Source> = Value(EmptyMapSource())
    open val source: Source get() = _source.value
    private val nameByItem: WeakHashMap<Item<*>, String> = WeakHashMap()

    override fun <T> lock(action: () -> T): T = lock.write(action)

    override fun at(path: String): Config {
        if (path.isEmpty()) {
            return this
        } else {
            val originalConfig = this
            return object : BaseConfig(
                name = name,
                parent = parent?.at(path) as BaseConfig?,
                mapper = mapper,
                specsInLayer = specsInLayer,
                featuresInLayer = featuresInLayer,
                nodeByItem = nodeByItem,
                tree = tree.getOrNull(path) ?: ContainerNode.placeHolder().also {
                    lock.write { tree[path] = it }
                },
                hasChildren = hasChildren,
                beforeSetFunctions = beforeSetFunctions,
                afterSetFunctions = afterSetFunctions,
                beforeLoadFunctions = beforeLoadFunctions,
                afterLoadFunctions = afterLoadFunctions,
                lock = lock
            ) {
                override val source: Source
                    get() {
                        if (path !in originalConfig.source) {
                            originalConfig.source.tree[path] = ContainerNode.placeHolder()
                        }
                        return originalConfig.source[path]
                    }
            }
        }
    }

    override fun withPrefix(prefix: String): Config {
        if (prefix.isEmpty()) {
            return this
        } else {
            val originalConfig = this
            return object : BaseConfig(
                name = name,
                parent = parent?.withPrefix(prefix) as BaseConfig?,
                mapper = mapper,
                specsInLayer = specsInLayer,
                featuresInLayer = featuresInLayer,
                nodeByItem = nodeByItem,
                tree = if (prefix.isEmpty()) tree
                else ContainerNode.empty().apply {
                    set(prefix, tree)
                },
                hasChildren = hasChildren,
                beforeSetFunctions = beforeSetFunctions,
                afterSetFunctions = afterSetFunctions,
                beforeLoadFunctions = beforeLoadFunctions,
                afterLoadFunctions = afterLoadFunctions,
                lock = lock
            ) {
                override val source: Source get() = originalConfig.source.withPrefix(prefix)
            }
        }
    }

    override fun iterator(): Iterator<Item<*>> {
        return if (parent != null) {
            (nodeByItem.keys.iterator().asSequence() + parent!!.iterator().asSequence()).iterator()
        } else {
            nodeByItem.keys.iterator()
        }
    }

    override val itemWithNames: List<Pair<Item<*>, String>>
        get() = lock.read { tree.leafByPath }.map { (name, node) ->
            (node as ItemNode).item to name
        } + (parent?.itemWithNames ?: listOf())

    override fun toMap(): Map<String, Any> {
        return lock.read {
            itemWithNames.map { (item, name) ->
                name to try {
                    getOrNull(item, errorWhenNotFound = true).toCompatibleValue(mapper)
                } catch (_: UnsetValueException) {
                    ValueState.Unset
                }
            }.filter { (_, value) -> value != ValueState.Unset }.toMap()
        }
    }

    @Suppress("UNCHECKED_CAST")
    override fun <T> get(item: Item<T>): T = getOrNull(item, errorWhenNotFound = true) as T

    @Suppress("UNCHECKED_CAST")
    override fun <T> get(name: String): T = getOrNull(name, errorWhenNotFound = true) as T

    @Suppress("UNCHECKED_CAST")
    override fun <T> getOrNull(item: Item<T>): T? = getOrNull(item, errorWhenNotFound = false) as T?

    private fun setState(item: Item<*>, state: ValueState) {
        if (item in nodeByItem) {
            nodeByItem[item]!!.value = state
        } else {
            nodeByItem[item] = ItemNode(state, item)
        }
    }

    open fun getOrNull(
        item: Item<*>,
        errorWhenNotFound: Boolean,
        errorWhenGetDefault: Boolean = false,
        lazyContext: ItemContainer = this
    ): Any? {
        val valueState = lock.read { nodeByItem[item]?.value }
        if (valueState != null) {
            @Suppress("UNCHECKED_CAST")
            when (valueState) {
                is ValueState.Unset ->
                    if (errorWhenNotFound) {
                        throw UnsetValueException(item)
                    } else {
                        return null
                    }
                is ValueState.Null -> return null
                is ValueState.Value -> return valueState.value
                is ValueState.Default -> {
                    if (errorWhenGetDefault) {
                        throw GetDefaultValueException(item)
                    } else {
                        return valueState.value
                    }
                }
                is ValueState.Lazy<*> -> {
                    val value = try {
                        valueState.thunk(lazyContext)
                    } catch (exception: ConfigException) {
                        when (exception) {
                            is UnsetValueException, is NoSuchItemException -> {
                                if (errorWhenNotFound) {
                                    throw exception
                                } else {
                                    return null
                                }
                            }
                            else -> throw exception
                        }
                    }
                    if (value == null) {
                        if (item.nullable) {
                            return null
                        } else {
                            throw InvalidLazySetException(
                                "fail to cast null to ${item.type.rawClass}" +
                                    " when getting item ${item.name} in config"
                            )
                        }
                    } else {
                        if (item.type.rawClass.isInstance(value)) {
                            return value
                        } else {
                            throw InvalidLazySetException(
                                "fail to cast $value with ${value::class} to ${item.type.rawClass}" +
                                    " when getting item ${item.name} in config"
                            )
                        }
                    }
                }
            }
        } else {
            if (parent != null) {
                return parent!!.getOrNull(item, errorWhenNotFound, errorWhenGetDefault, lazyContext)
            } else {
                if (errorWhenNotFound) {
                    throw NoSuchItemException(item)
                } else {
                    return null
                }
            }
        }
    }

    open fun getItemOrNull(name: String): Item<*>? {
        val trimmedName = name.trim()
        val item = getItemInLayerOrNull(trimmedName)
        return item ?: parent?.getItemOrNull(trimmedName)
    }

    private fun getItemInLayerOrNull(name: String): Item<*>? {
        return lock.read {
            (tree.getOrNull(name) as? ItemNode)?.item
        }
    }

    @Suppress("UNCHECKED_CAST")
    override fun <T> getOrNull(name: String): T? = getOrNull(name, errorWhenNotFound = false) as T?

    private fun getOrNull(name: String, errorWhenNotFound: Boolean): Any? {
        val item = getItemOrNull(name)
        return if (item != null) {
            getOrNull(item, errorWhenNotFound)
        } else {
            if (errorWhenNotFound) {
                throw NoSuchItemException(name)
            } else {
                null
            }
        }
    }

    private fun containsInLayer(item: Item<*>) = lock.read { nodeByItem.containsKey(item) }

    override fun contains(item: Item<*>): Boolean {
        return if (containsInLayer(item)) {
            true
        } else {
            parent?.contains(item) ?: false
        }
    }

    private fun containsInLayer(name: String): Boolean {
        return containsInLayer(name.toPath())
    }

    override fun contains(name: String): Boolean {
        return if (containsInLayer(name)) {
            true
        } else {
            parent?.contains(name) ?: false
        }
    }

    private fun TreeNode.partialMatch(path: Path): Boolean {
        return if (this is LeafNode) {
            true
        } else if (path.isEmpty()) {
            !isEmpty()
        } else {
            val key = path.first()
            val rest = path.drop(1)
            val result = children[key]
            if (result != null) {
                return result.partialMatch(rest)
            } else {
                return false
            }
        }
    }

    private fun containsInLayer(path: Path): Boolean {
        return lock.read {
            tree.partialMatch(path)
        }
    }

    override fun contains(path: Path): Boolean =
        containsInLayer(path) || (parent?.contains(path) ?: false)

    override fun nameOf(item: Item<*>): String {
        return nameByItem[item] ?: {
            val name = lock.read { tree.firstPath { it is ItemNode && it.item == item } }?.name
            if (name != null) {
                nameByItem[item] = name
                name
            } else {
                parent?.nameOf(item) ?: throw NoSuchItemException(item)
            }
        }()
    }

    open fun addBeforeSetFunction(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        beforeSetFunctions += beforeSetFunction
        parent?.addBeforeSetFunction(beforeSetFunction)
    }

    open fun removeBeforeSetFunction(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        beforeSetFunctions.remove(beforeSetFunction)
        parent?.removeBeforeSetFunction(beforeSetFunction)
    }

    override fun beforeSet(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit): Handler {
        addBeforeSetFunction(beforeSetFunction)
        return object : Handler {
            override fun cancel() {
                removeBeforeSetFunction(beforeSetFunction)
            }
        }
    }

    private fun notifyBeforeSet(item: Item<*>, value: Any?) {
        for (beforeSetFunction in beforeSetFunctions) {
            beforeSetFunction(item, value)
        }
    }

    open fun addAfterSetFunction(afterSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        afterSetFunctions += afterSetFunction
        parent?.addAfterSetFunction(afterSetFunction)
    }

    open fun removeAfterSetFunction(afterSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        afterSetFunctions.remove(afterSetFunction)
        parent?.removeAfterSetFunction(afterSetFunction)
    }

    override fun afterSet(afterSetFunction: (item: Item<*>, value: Any?) -> Unit): Handler {
        addAfterSetFunction(afterSetFunction)
        return object : Handler {
            override fun cancel() {
                removeAfterSetFunction(afterSetFunction)
            }
        }
    }

    private fun notifyAfterSet(item: Item<*>, value: Any?) {
        for (afterSetFunction in afterSetFunctions) {
            afterSetFunction(item, value)
        }
    }

    override fun rawSet(item: Item<*>, value: Any?) {
        if (item in this) {
            if (value == null) {
                if (item.nullable) {
                    item.notifySet(null)
                    item.notifyBeforeSet(this, value)
                    notifyBeforeSet(item, value)
                    lock.write {
                        setState(item, ValueState.Null)
                    }
                    notifyAfterSet(item, value)
                    item.notifyAfterSet(this, value)
                } else {
                    throw ClassCastException(
                        "fail to cast null to ${item.type.rawClass}" +
                            " when setting item ${item.name} in config"
                    )
                }
            } else {
                if (item.type.rawClass.isInstance(value)) {
                    item.notifySet(value)
                    item.notifyBeforeSet(this, value)
                    notifyBeforeSet(item, value)
                    lock.write {
                        setState(item, ValueState.Value(value))
                    }
                    notifyAfterSet(item, value)
                    item.notifyAfterSet(this, value)
                } else {
                    throw ClassCastException(
                        "fail to cast $value with ${value::class} to ${item.type.rawClass}" +
                            " when setting item ${item.name} in config"
                    )
                }
            }
        } else {
            throw NoSuchItemException(item)
        }
    }

    override fun <T> set(item: Item<T>, value: T) {
        rawSet(item, value)
    }

    override fun <T> set(name: String, value: T) {
        val item = getItemOrNull(name)
        if (item != null) {
            @Suppress("UNCHECKED_CAST")
            set(item as Item<T>, value)
        } else {
            throw NoSuchItemException(name)
        }
    }

    override fun <T> lazySet(item: Item<T>, thunk: (config: ItemContainer) -> T) {
        if (item in this) {
            lock.write {
                setState(item, ValueState.Lazy(thunk))
            }
        } else {
            throw NoSuchItemException(item)
        }
    }

    override fun <T> lazySet(name: String, thunk: (config: ItemContainer) -> T) {
        val item = getItemOrNull(name)
        if (item != null) {
            @Suppress("UNCHECKED_CAST")
            lazySet(item as Item<T>, thunk)
        } else {
            throw NoSuchItemException(name)
        }
    }

    override fun unset(item: Item<*>) {
        if (item in this) {
            lock.write {
                setState(item, ValueState.Unset)
            }
        } else {
            throw NoSuchItemException(item)
        }
    }

    override fun unset(name: String) {
        val item = getItemOrNull(name)
        if (item != null) {
            unset(item)
        } else {
            throw NoSuchItemException(name)
        }
    }

    override fun clear() {
        lock.write {
            nodeByItem.clear()
            tree.children.clear()
            if (tree is MapNode) {
                tree.isPlaceHolder = true
            }
        }
    }

    override fun clearAll() {
        clear()
        parent?.clearAll()
    }

    override fun containsRequired(): Boolean = try {
        validateRequired()
        true
    } catch (ex: UnsetValueException) {
        false
    }

    override fun validateRequired(): Config {
        for (item in this) {
            if (item is RequiredItem) {
                getOrNull(item, errorWhenNotFound = true)
            }
        }
        return this
    }

    override fun plus(config: Config): Config {
        return when (config) {
            is BaseConfig -> MergedConfig(this, config)
            else -> config.withFallback(this)
        }
    }

    override fun withFallback(config: Config): Config {
        return config + this
    }

    override fun <T> property(item: Item<T>): ReadWriteProperty<Any?, T> {
        if (!contains(item)) {
            throw NoSuchItemException(item)
        }
        return object : ReadWriteProperty<Any?, T> {
            override fun getValue(thisRef: Any?, property: KProperty<*>): T = get(item)

            override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) =
                set(item, value)
        }
    }

    override fun <T> property(name: String): ReadWriteProperty<Any?, T> {
        if (!contains(name)) {
            throw NoSuchItemException(name)
        }
        return object : ReadWriteProperty<Any?, T> {
            override fun getValue(thisRef: Any?, property: KProperty<*>): T = get(name)

            override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) =
                set(name, value)
        }
    }

    override val specs: List<Spec> get() = lock.read { specsInLayer + (parent?.specs ?: listOf()) }

    override val sources: List<Source>
        get() {
            return lock.read { mutableListOf(source) }.apply {
                for (source in parent?.sources ?: listOf()) {
                    add(source)
                }
            }
        }

    override fun enable(feature: Feature): Config {
        return apply {
            lock.write {
                featuresInLayer[feature] = true
            }
        }
    }

    override fun disable(feature: Feature): Config {
        return apply {
            lock.write {
                featuresInLayer[feature] = false
            }
        }
    }

    override fun isEnabled(feature: Feature): Boolean {
        return lock.read {
            featuresInLayer[feature] ?: parent?.isEnabled(feature) ?: feature.enabledByDefault
        }
    }

    override fun addItem(item: Item<*>, prefix: String) {
        lock.write {
            if (hasChildren.value) {
                throw LayerFrozenException(this)
            }
            val path = prefix.toPath() + item.name.toPath()
            val name = path.name
            if (item !in this) {
                if (path in this) {
                    throw NameConflictException("item $name cannot be added")
                }
                val node = ItemNode(
                    when (item) {
                        is OptionalItem -> ValueState.Default(item.default)
                        is RequiredItem -> ValueState.Unset
                        is LazyItem -> ValueState.Lazy(item.thunk)
                    },
                    item
                )
                tree[name] = node
                nodeByItem[item] = node
                val sources = this.sources
                val mergedSource = if (sources.isNotEmpty()) {
                    sources.reduceRight { source, acc -> MergedSource(source, acc) }
                } else {
                    null
                }
                mergedSource?.let { loadItem(item, path, it) }
            } else {
                throw RepeatedItemException(name)
            }
        }
    }

    override fun addSpec(spec: Spec) {
        lock.write {
            if (hasChildren.value) {
                throw LayerFrozenException(this)
            }
            val sources = this.sources
            val mergedSource = if (sources.isNotEmpty()) {
                sources.reduceRight { source, acc -> MergedSource(source, acc) }
            } else {
                null
            }
            spec.items.forEach { item ->
                val name = spec.qualify(item)
                if (item !in this) {
                    val path = name.toPath()
                    if (path in this) {
                        throw NameConflictException("item $name cannot be added")
                    }
                    val node = ItemNode(
                        when (item) {
                            is OptionalItem -> ValueState.Default(item.default)
                            is RequiredItem -> ValueState.Unset
                            is LazyItem -> ValueState.Lazy(item.thunk)
                        },
                        item
                    )
                    tree[name] = node
                    nodeByItem[item] = node
                    mergedSource?.let { loadItem(item, path, it) }
                } else {
                    throw RepeatedItemException(name)
                }
            }
            spec.innerSpecs.forEach { innerSpec ->
                addSpec(innerSpec.withPrefix(spec.prefix))
            }
            specsInLayer += spec
        }
    }

    override fun withLayer(name: String): BaseConfig {
        lock.write { hasChildren.value = true }
        return BaseConfig(name, this, mapper)
    }

    open fun addBeforeLoadFunction(beforeLoadFunction: (source: Source) -> Unit) {
        beforeLoadFunctions += beforeLoadFunction
        parent?.addBeforeLoadFunction(beforeLoadFunction)
    }

    open fun removeBeforeLoadFunction(beforeLoadFunction: (source: Source) -> Unit) {
        beforeLoadFunctions.remove(beforeLoadFunction)
        parent?.removeBeforeLoadFunction(beforeLoadFunction)
    }

    override fun beforeLoad(beforeLoadFunction: (source: Source) -> Unit): Handler {
        addBeforeLoadFunction(beforeLoadFunction)
        return object : Handler {
            override fun cancel() {
                removeBeforeLoadFunction(beforeLoadFunction)
            }
        }
    }

    private fun notifyBeforeLoad(source: Source) {
        for (beforeLoadFunction in beforeLoadFunctions) {
            beforeLoadFunction(source)
        }
    }

    open fun addAfterLoadFunction(afterLoadFunction: (source: Source) -> Unit) {
        afterLoadFunctions += afterLoadFunction
        parent?.addAfterLoadFunction(afterLoadFunction)
    }

    open fun removeAfterLoadFunction(afterLoadFunction: (source: Source) -> Unit) {
        afterLoadFunctions.remove(afterLoadFunction)
        parent?.removeAfterLoadFunction(afterLoadFunction)
    }

    override fun afterLoad(afterLoadFunction: (source: Source) -> Unit): Handler {
        addAfterLoadFunction(afterLoadFunction)
        return object : Handler {
            override fun cancel() {
                removeAfterLoadFunction(afterLoadFunction)
            }
        }
    }

    private fun notifyAfterLoad(source: Source) {
        for (afterLoadFunction in afterLoadFunctions) {
            afterLoadFunction(source)
        }
    }

    override fun withSource(source: Source): Config {
        return withLayer("source: ${source.description}").also { config ->
            config.lock.write {
                config._source.value = load(config, source)
            }
        }
    }

    override fun withLoadTrigger(
        description: String,
        trigger: (
            config: Config,
            load: (source: Source) -> Unit
        ) -> Unit
    ): Config {
        return withLayer("trigger: $description").apply {
            trigger(this) { source ->
                notifyBeforeLoad(source)
                lock.write {
                    this._source.value = load(this, source)
                }
                notifyAfterLoad(source)
            }
        }
    }

    override fun toString(): String {
        return "Config(items=${toMap()})"
    }

    class ItemNode(override var value: ValueState, val item: Item<*>) : ValueNode

    data class Value<T>(var value: T)

    sealed class ValueState {
        object Unset : ValueState()
        object Null : ValueState()
        data class Lazy<T>(val thunk: (config: ItemContainer) -> T) : ValueState()
        data class Value(val value: Any) : ValueState()
        data class Default(val value: Any?) : ValueState()
    }
}

/**
 * Returns a new default object mapper for config.
 */
fun createDefaultMapper(): ObjectMapper = jacksonObjectMapper()
    .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
    .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
    .enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID)
    .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    .enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
    .apply {
        coercionConfigDefaults().setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty)
    }
    .registerModules(
        SimpleModule()
            .addDeserializer(String::class.java, StringDeserializer)
            .setDeserializerModifier(EmptyStringToCollectionDeserializerModifier),
        JavaTimeModule()
            .addDeserializer(Duration::class.java, DurationDeserializer)
            .addDeserializer(OffsetDateTime::class.java, OffsetDateTimeDeserializer)
            .addDeserializer(ZonedDateTime::class.java, ZoneDateTimeDeserializer)
    )


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/Config.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.type.TypeFactory
import com.uchuhimo.konf.annotation.JavaApi
import com.uchuhimo.konf.source.DefaultLoaders
import com.uchuhimo.konf.source.Source
import com.uchuhimo.konf.source.base.kvToTree
import kotlin.properties.PropertyDelegateProvider
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

/**
 * Config containing items and associated values.
 *
 * Config contains items, which can be loaded with [addSpec].
 * Config contains values, each of which is associated with corresponding item.
 * Values can be loaded from [source][Source] with [withSource] or [from].
 *
 * Config contains read-write access operations for item.
 * Items in config is in one of three states:
 * - Unset. Item has not associated value in this state.
 *   Use [unset] to change item to this state.
 * - Unevaluated. Item is lazy and the associated value will be evaluated when accessing.
 *   Use [lazySet] to change item to this state.
 * - Evaluated.  Item has associated value which is evaluated.
 *   Use [set] to change item to this state.
 *
 * Config is cascading.
 * Config can fork from another config by adding a new layer on it.
 * The forked config is called child config, and the original config is called parent config.
 * A config without parent config is called root config. The new layer added by child config
 * is called facade layer.
 * Config with ancestor configs has multiple layers. All set operation is executed in facade layer
 * of config.
 * Descendant config inherits items and values in ancestor configs, and can override values for
 * items in ancestor configs. Overridden values in config will affect itself and its descendant
 * configs, without affecting its ancestor configs. Loading items in config will not affect its
 * ancestor configs too. [invoke] can be used to create a root config, and [withLayer] can be used
 * to create a child config from specified config.
 *
 * All methods in Config is thread-safe.
 */
interface Config : ItemContainer {
    /**
     * Associate item with specified value without type checking.
     *
     * @param item config item
     * @param value associated value
     */
    fun rawSet(item: Item<*>, value: Any?)

    /**
     * Associate item with specified value.
     *
     * @param item config item
     * @param value associated value
     */
    operator fun <T> set(item: Item<T>, value: T)

    /**
     * Find item with specified name, and associate it with specified value.
     *
     * @param name item name
     * @param value associated value
     */
    operator fun <T> set(name: String, value: T)

    /**
     * Associate item with specified thunk, which can be used to evaluate value for the item.
     *
     * @param item config item
     * @param thunk thunk used to evaluate value for the item
     */
    fun <T> lazySet(item: Item<T>, thunk: (config: ItemContainer) -> T)

    /**
     * Find item with specified name, and associate item with specified thunk,
     * which can be used to evaluate value for the item.
     *
     * @param name item name
     * @param thunk thunk used to evaluate value for the item
     */
    fun <T> lazySet(name: String, thunk: (config: ItemContainer) -> T)

    /**
     * Discard associated value of specified item.
     *
     * @param item config item
     */
    fun unset(item: Item<*>)

    /**
     * Discard associated value of item with specified name.
     *
     * @param name item name
     */
    fun unset(name: String)

    /**
     * Subscribe the update event before every set operation.
     *
     * @param beforeSetFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun beforeSet(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit): Handler

    /**
     * Subscribe the update event after every set operation.
     *
     * @param afterSetFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun afterSet(afterSetFunction: (item: Item<*>, value: Any?) -> Unit): Handler

    /**
     * Remove all values from the facade layer of this config.
     */
    fun clear()

    /**
     * Remove all values from all layers of this config.
     */
    fun clearAll()

    /**
     * Whether all required items have values or not.
     *
     * @return `true` if all required items have values, `false` otherwise
     */
    fun containsRequired(): Boolean

    /**
     * Validate whether all required items have values or not. If not, throws [UnsetValueException].
     *
     * @return the current config
     */
    fun validateRequired(): Config

    /**
     * Returns a property that can read/set associated value for specified item.
     *
     * @param item config item
     * @return a property that can read/set associated value for specified item
     */
    fun <T> property(item: Item<T>): ReadWriteProperty<Any?, T>

    /**
     * Returns a property that can read/set associated value for item with specified name.
     *
     * @param name item name
     * @return a property that can read/set associated value for item with specified name
     */
    fun <T> property(name: String): ReadWriteProperty<Any?, T>

    /**
     * Name of facade layer of config.
     *
     * Layer name provides information for facade layer in a cascading config.
     */
    val name: String

    /**
     * Returns parent of this config, or `null` if this config is a root config.
     */
    val parent: Config?

    /**
     * List of config specs from all layers of this config.
     */
    val specs: List<Spec>

    /**
     * List of sources from all layers of this config.
     */
    val sources: List<Source>

    /**
     * Returns a config overlapped by the specified facade config.
     *
     * All operations will be applied to the facade config first,
     * and then fall back to this config when necessary.
     *
     * @param config the facade config
     * @return a config overlapped by the specified facade config
     */
    operator fun plus(config: Config): Config

    /**
     * Returns a config backing by the specified fallback config.
     *
     * All operations will be applied to this config first,
     * and then fall back to the fallback config when necessary.
     *
     * @param config the fallback config
     * @return a config backing by the specified fallback config
     */
    fun withFallback(config: Config): Config

    /**
     * Returns sub-config in the specified path.
     *
     * @param path the specified path
     * @return sub-config in the specified path
     */
    fun at(path: String): Config

    /**
     * Returns config with the specified additional prefix.
     *
     * @param prefix additional prefix
     * @return config with the specified additional prefix
     */
    fun withPrefix(prefix: String): Config

    /**
     * Load item into facade layer with the specified prefix.
     *
     * Same item cannot be added twice.
     * The item cannot have same qualified name with existed items in config.
     *
     * @param item config item
     * @param prefix prefix for the config item
     */
    fun addItem(item: Item<*>, prefix: String = "")

    /**
     * Load items in specified config spec into facade layer.
     *
     * Same config spec cannot be added twice.
     * All items in specified config spec cannot have same qualified name with existed items in config.
     *
     * @param spec config spec
     */
    fun addSpec(spec: Spec)

    /**
     * Executes the given [action] after locking the facade layer of this config.
     *
     * @param action the given action
     * @return the return value of the action.
     */
    fun <T> lock(action: () -> T): T

    /**
     * Returns a child config of this config with specified name.
     *
     * @param name name of facade layer in child config
     * @return a child config
     */
    fun withLayer(name: String = ""): Config

    /**
     * Returns a child config containing values from specified source.
     *
     * Values from specified source will be loaded into facade layer of the returned child config
     * without affecting this config.
     *
     * @param source config source
     * @return a child config containing value from specified source
     */
    fun withSource(source: Source): Config

    /**
     * Returns a child config containing values loaded by specified trigger.
     *
     * Values loaded by specified trigger will be loaded into facade layer of
     * the returned child config without affecting this config.
     *
     * @param description trigger description
     * @param trigger load trigger
     * @return a child config containing value loaded by specified trigger
     */
    fun withLoadTrigger(
        description: String,
        trigger: (
            config: Config,
            load: (source: Source) -> Unit
        ) -> Unit
    ): Config

    /**
     * Subscribe the update event before every load operation.
     *
     * @param beforeLoadFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun beforeLoad(beforeLoadFunction: (source: Source) -> Unit): Handler

    /**
     * Subscribe the update event after every load operation.
     *
     * @param afterLoadFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun afterLoad(afterLoadFunction: (source: Source) -> Unit): Handler

    /**
     * Returns default loaders for this config.
     *
     * It is a fluent API for loading source from default loaders.
     *
     * @return default loaders for this config
     */
    @JavaApi
    fun from(): DefaultLoaders = from

    /**
     * Returns default loaders for this config.
     *
     * It is a fluent API for loading source from default loaders.
     */
    val from: DefaultLoaders get() = DefaultLoaders(this)

    /**
     * Returns [ObjectMapper] using to map from source to value in config.
     */
    val mapper: ObjectMapper

    /**
     * Returns a map in key-value format for this config.
     *
     * The returned map contains all items in this config, with item name as key and
     * associated value as value.
     * This map can be loaded into config as [com.uchuhimo.konf.source.base.KVSource] using
     * `config.from.map.kv(map)`.
     */
    fun toMap(): Map<String, Any>

    /**
     * Enables the specified feature and returns this config.
     *
     * @param feature the specified feature
     * @return this config
     */
    fun enable(feature: Feature): Config

    /**
     * Disables the specified feature and returns this config.
     *
     * @param feature the specified feature
     * @return this config
     */
    fun disable(feature: Feature): Config

    /**
     * Check whether the specified feature is enabled or not.
     *
     * @param feature the specified feature
     * @return whether the specified feature is enabled or not
     */
    fun isEnabled(feature: Feature): Boolean

    companion object {
        /**
         * Create a new root config.
         *
         * @return a new root config
         */
        operator fun invoke(): Config = BaseConfig()

        /**
         * Create a new root config and initiate it.
         *
         * @param init initial action
         * @return a new root config
         */
        operator fun invoke(init: Config.() -> Unit): Config = Config().apply(init)
    }
}

/**
 * Returns a property that can read/set associated value casted from config.
 *
 * @return a property that can read/set associated value casted from config
 */
inline fun <reified T> Config.cast() =
    object : RequiredConfigProperty<T>(this.withPrefix("root").withLayer(), name = "root") {}

/**
 * Returns a value casted from config.
 *
 * @return a value casted from config
 */
inline fun <reified T> Config.toValue(): T {
    val value by cast<T>()
    return value
}

/**
 * Returns a property that can read/set associated value for specified required item.
 *
 * @param prefix prefix for the config item
 * @param name item name without prefix
 * @param description description for this item
 * @return a property that can read/set associated value for specified required item
 */
inline fun <reified T> Config.required(
    prefix: String = "",
    name: String? = null,
    description: String = ""
) =
    object : RequiredConfigProperty<T>(this, prefix, name, description, null is T) {}

open class RequiredConfigProperty<T>(
    private val config: Config,
    private val prefix: String = "",
    private val name: String? = null,
    private val description: String = "",
    private val nullable: Boolean = false
) : PropertyDelegateProvider<Any?, ReadWriteProperty<Any?, T>> {
    override operator fun provideDelegate(thisRef: Any?, property: KProperty<*>):
        ReadWriteProperty<Any?, T> {
        val type: JavaType = TypeFactory.defaultInstance().constructType(this::class.java)
            .findSuperType(RequiredConfigProperty::class.java).bindings.typeParameters[0]
        val item = object : RequiredItem<T>(
            Spec.dummy,
            name
                ?: property.name,
            description,
            type,
            nullable
        ) {}
        config.addItem(item, prefix)
        return config.property(item)
    }
}

/**
 * Returns a property that can read/set associated value for specified optional item.
 *
 * @param default default value returned before associating this item with specified value
 * @param prefix prefix for the config item
 * @param name item name without prefix
 * @param description description for this item
 * @return a property that can read/set associated value for specified optional item
 */
inline fun <reified T> Config.optional(
    default: T,
    prefix: String = "",
    name: String? = null,
    description: String = ""
) =
    object : OptionalConfigProperty<T>(this, default, prefix, name, description, null is T) {}

open class OptionalConfigProperty<T>(
    private val config: Config,
    private val default: T,
    private val prefix: String = "",
    private val name: String? = null,
    private val description: String = "",
    private val nullable: Boolean = false
) : PropertyDelegateProvider<Any?, ReadWriteProperty<Any?, T>> {
    override operator fun provideDelegate(thisRef: Any?, property: KProperty<*>):
        ReadWriteProperty<Any?, T> {
        val type: JavaType = TypeFactory.defaultInstance().constructType(this::class.java)
            .findSuperType(OptionalConfigProperty::class.java).bindings.typeParameters[0]
        val item = object : OptionalItem<T>(
            Spec.dummy,
            name
                ?: property.name,
            default,
            description,
            type,
            nullable
        ) {}
        config.addItem(item, prefix)
        return config.property(item)
    }
}

/**
 * Returns a property that can read/set associated value for specified lazy item.
 *
 * @param prefix prefix for the config item
 * @param name item name without prefix
 * @param description description for this item
 * @param thunk thunk used to evaluate value for this item
 * @return a property that can read/set associated value for specified lazy item
 */
inline fun <reified T> Config.lazy(
    prefix: String = "",
    name: String? = null,
    description: String = "",
    noinline thunk: (config: ItemContainer) -> T
) =
    object : LazyConfigProperty<T>(this, thunk, prefix, name, description, null is T) {}

open class LazyConfigProperty<T>(
    private val config: Config,
    private val thunk: (config: ItemContainer) -> T,
    private val prefix: String = "",
    private val name: String? = null,
    private val description: String = "",
    private val nullable: Boolean = false
) : PropertyDelegateProvider<Any?, ReadWriteProperty<Any?, T>> {
    override operator fun provideDelegate(thisRef: Any?, property: KProperty<*>):
        ReadWriteProperty<Any?, T> {
        val type: JavaType = TypeFactory.defaultInstance().constructType(this::class.java)
            .findSuperType(LazyConfigProperty::class.java).bindings.typeParameters[0]
        val item = object : LazyItem<T>(
            Spec.dummy,
            name
                ?: property.name,
            thunk,
            description,
            type,
            nullable
        ) {}
        config.addItem(item, prefix)
        return config.property(item)
    }
}

/**
 * Convert the config to a tree node.
 *
 * @return a tree node
 */
fun Config.toTree(): TreeNode {
    return toMap().kvToTree()
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/ConfigException.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

/**
 * Exception for config.
 */
open class ConfigException : RuntimeException {
    constructor(message: String) : super(message)
    constructor(message: String, cause: Throwable) : super(message, cause)
}

/**
 * Exception indicates that there is existed item with same name in config.
 */
class RepeatedItemException(val name: String) : ConfigException("item $name has been added")

/**
 * Exception indicates that there is existed inner spec in config.
 */
class RepeatedInnerSpecException(val spec: Spec) :
    ConfigException("spec ${spec.javaClass.simpleName}(prefix=\"${spec.prefix}\") has been added")

/**
 * Exception indicates that there is existed item with conflicted name in config.
 */
class NameConflictException(message: String) : ConfigException(message)

/**
 * Exception indicates that the evaluated result of lazy thunk is invalid.
 */
class InvalidLazySetException(message: String) : ConfigException(message)

val Item<*>.asName: String get() = "item $name"

/**
 * Exception indicates that the specified item is in unset state.
 */
class UnsetValueException(val name: String) : ConfigException("$name is unset") {
    constructor(item: Item<*>) : this(item.asName)
}

/**
 * Exception indicates that the specified item has default value.
 */
class GetDefaultValueException(val name: String) : ConfigException("$name has default value") {
    constructor(item: Item<*>) : this(item.asName)
}

/**
 * Exception indicates that the specified item is not in this config.
 */
class NoSuchItemException(val name: String) : ConfigException("cannot find $name in config") {
    constructor(item: Item<*>) : this(item.asName)
}

/**
 * Exception indicates that item cannot be added to this config because it has child layer.
 */
class LayerFrozenException(val config: Config) :
    ConfigException("config ${config.name} has child layer, cannot add new item")

/**
 * Exception indicates that expected value in specified path is not existed in the source.
 */
class NoSuchPathException(val path: String) :
    ConfigException("cannot find path \"$path\" in config spec")

/**
 * Exception indicates that the specified path is invalid.
 */
class InvalidPathException(val path: String) :
    ConfigException("\"$path\" is not a valid path")

/**
 * Exception indicates that the specified path conflicts with existed paths in the tree node.
 */
class PathConflictException(val path: String) :
    ConfigException("\"$path\" conflicts with existed paths in the tree node")


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/ConfigSpec.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.fasterxml.jackson.module.kotlin.isKotlinClass

/**
 * The default implementation for [Spec].
 *
 * @param prefix common prefix for items in this config spec
 */
open class ConfigSpec @JvmOverloads constructor(
    prefix: String? = null,
    items: Set<Item<*>> = mutableSetOf(),
    innerSpecs: Set<Spec> = mutableSetOf()
) : Spec {
    final override val prefix: String = prefix ?: {
        if (javaClass == ConfigSpec::class.java || javaClass.isAnonymousClass) {
            ""
        } else {
            javaClass.let { clazz ->
                if (this::class.isCompanion) clazz.declaringClass else clazz
            }.simpleName.let { name ->
                if (name == null || name.contains('$')) {
                    ""
                } else {
                    name.toLittleCase()
                }
            }.let { name ->
                if (name.endsWith("Spec")) {
                    name.removeSuffix("Spec")
                } else {
                    name
                }
            }
        }
    }()

    init {
        checkPath(this.prefix)
    }

    private val _items = items as? MutableSet<Item<*>> ?: items.toMutableSet()

    override val items: Set<Item<*>> = _items

    override fun addItem(item: Item<*>) {
        if (item !in _items) {
            _items += item
        } else {
            throw RepeatedItemException(item.name)
        }
    }

    private val _innerSpecs = innerSpecs as? MutableSet<Spec> ?: innerSpecs.toMutableSet()

    override val innerSpecs: Set<Spec> = _innerSpecs

    override fun addInnerSpec(spec: Spec) {
        if (spec !in _innerSpecs) {
            _innerSpecs += spec
        } else {
            throw RepeatedInnerSpecException(spec)
        }
    }

    init {
        if (javaClass.isKotlinClass()) {
            javaClass.kotlin.nestedClasses.map {
                it.objectInstance
            }.filterIsInstance<Spec>().forEach { spec ->
                addInnerSpec(spec)
            }
        }
    }

    /**
     * Specify a required item in this config spec.
     *
     * @param name item name without prefix
     * @param description description for this item
     * @return a property of a required item with prefix of this config spec
     */
    inline fun <reified T> required(name: String? = null, description: String = "") =
        object : RequiredProperty<T>(this, name, description, null is T) {}

    /**
     * Specify an optional item in this config spec.
     *
     * @param default default value returned before associating this item with specified value
     * @param name item name without prefix
     * @param description description for this item
     *
     * @return a property of an optional item with prefix of this config spec
     */
    inline fun <reified T> optional(default: T, name: String? = null, description: String = "") =
        object : OptionalProperty<T>(this, default, name, description, null is T) {}

    /**
     * Specify a lazy item in this config spec.
     *
     * @param name item name without prefix
     * @param description description for this item
     * @param thunk thunk used to evaluate value for this item
     * @return a property of a lazy item with prefix of this config spec
     */
    inline fun <reified T> lazy(
        name: String? = null,
        description: String = "",
        noinline thunk: (config: ItemContainer) -> T
    ) =
        object : LazyProperty<T>(this, thunk, name, description, null is T) {}
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/Feature.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

/**
 * Enumeration that defines simple on/off features.
 */
enum class Feature(val enabledByDefault: Boolean) {
    /**
     * Feature that determines what happens when unknown paths appear in the source.
     * If enabled, an exception is thrown when loading from the source
     * to indicate it contains unknown paths.
     *
     * Feature is disabled by default.
     */
    FAIL_ON_UNKNOWN_PATH(false),
    /**
     * Feature that determines whether loading keys from sources case-insensitively.
     *
     * Feature is disabled by default.
     */
    LOAD_KEYS_CASE_INSENSITIVELY(false),
    /**
     * Feature that determines whether loading keys from sources as little camel case.
     *
     * Feature is enabled by default.
     */
    LOAD_KEYS_AS_LITTLE_CAMEL_CASE(true),
    /**
     * Feature that determines whether sources are optional by default.
     *
     * Feature is disabled by default.
     */
    OPTIONAL_SOURCE_BY_DEFAULT(false),
    /**
     * Feature that determines whether sources should be substituted before loaded into config.
     *
     * Feature is enabled by default.
     */
    SUBSTITUTE_SOURCE_BEFORE_LOADED(true)
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/Item.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.type.TypeFactory

/**
 * Item that can be contained by config.
 *
 * Item can be associated with value in config, containing metadata for the value.
 * The metadata for value includes name, path, type, description and so on.
 * Item can be used as key to operate value in config, guaranteeing type safety.
 * There are three kinds of item: [required item][RequiredItem], [optional item][OptionalItem]
 * and [lazy item][LazyItem].
 *
 * @param T type of value that can be associated with this item.
 * @param spec config spec that contains this item
 * @param name item name without prefix
 * @param description description for this item
 * @see Config
 */
sealed class Item<T>(
    /**
     * Config spec that contains this item.
     */
    val spec: Spec,
    /**
     * Item name without prefix.
     */
    val name: String,
    /**
     * Description for this item.
     */
    val description: String = "",
    type: JavaType? = null,
    val nullable: Boolean = false
) {
    init {
        checkPath(name)
        @Suppress("LeakingThis")
        spec.addItem(this)
    }

    /**
     * Item path without prefix.
     */
    val path: Path = this.name.toPath()

    /**
     * Type of value that can be associated with this item.
     */
    @Suppress("LeakingThis")
    val type: JavaType = type ?: TypeFactory.defaultInstance().constructType(this::class.java)
        .findSuperType(Item::class.java).bindings.typeParameters[0]

    /**
     * Whether this is a required item or not.
     */
    open val isRequired: Boolean get() = false

    /**
     * Whether this is an optional item or not.
     */
    open val isOptional: Boolean get() = false

    /**
     * Whether this is a lazy item or not.
     */
    open val isLazy: Boolean get() = false

    /**
     * Cast this item to a required item.
     */
    val asRequiredItem: RequiredItem<T> get() = this as RequiredItem<T>

    /**
     * Cast this item to an optional item.
     */
    val asOptionalItem: OptionalItem<T> get() = this as OptionalItem<T>

    /**
     * Cast this item to a lazy item.
     */
    val asLazyItem: LazyItem<T> get() = this as LazyItem<T>

    private val onSetFunctions: MutableList<(value: T) -> Unit> = mutableListOf()
    private val beforeSetFunctions: MutableList<(config: Config, value: T) -> Unit> = mutableListOf()
    private val afterSetFunctions: MutableList<(config: Config, value: T) -> Unit> = mutableListOf()

    /**
     * Subscribe the update event of this item.
     *
     * @param onSetFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun onSet(onSetFunction: (value: T) -> Unit): Handler {
        onSetFunctions += onSetFunction
        return object : Handler {
            override fun cancel() {
                onSetFunctions.remove(onSetFunction)
            }
        }
    }

    /**
     * Subscribe the update event of this item before every set operation.
     *
     * @param beforeSetFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun beforeSet(beforeSetFunction: (config: Config, value: T) -> Unit): Handler {
        beforeSetFunctions += beforeSetFunction
        return object : Handler {
            override fun cancel() {
                beforeSetFunctions.remove(beforeSetFunction)
            }
        }
    }

    /**
     * Subscribe the update event of this item after every set operation.
     *
     * @param afterSetFunction the subscription function
     * @return the handler to cancel this subscription
     */
    fun afterSet(afterSetFunction: (config: Config, value: T) -> Unit): Handler {
        afterSetFunctions += afterSetFunction
        return object : Handler {
            override fun cancel() {
                afterSetFunctions.remove(afterSetFunction)
            }
        }
    }

    fun notifySet(value: Any?) {
        for (onSetFunction in onSetFunctions) {
            @Suppress("UNCHECKED_CAST")
            onSetFunction(value as T)
        }
    }

    fun notifyBeforeSet(config: Config, value: Any?) {
        for (beforeSetFunction in beforeSetFunctions) {
            @Suppress("UNCHECKED_CAST")
            beforeSetFunction(config, value as T)
        }
    }

    fun notifyAfterSet(config: Config, value: Any?) {
        for (afterSetFunction in afterSetFunctions) {
            @Suppress("UNCHECKED_CAST")
            afterSetFunction(config, value as T)
        }
    }
}

interface Handler : AutoCloseable {
    fun cancel()

    override fun close() {
        cancel()
    }
}

/**
 * Type of Item path.
 */
typealias Path = List<String>

/**
 * Returns corresponding item name of the item path.
 *
 * @receiver item path
 * @return item name
 */
val Path.name: String get() = joinToString(".")

/**
 * Returns corresponding item path of the item name.
 *
 * @receiver item name
 * @return item path
 */
fun String.toPath(): Path {
    val name = this.trim()
    return if (name.isEmpty()) {
        listOf()
    } else {
        val path = name.split('.')
        if ("" in path) {
            throw InvalidPathException(this)
        }
        path
    }
}

fun checkPath(path: String) {
    val trimmedPath = path.trim()
    if (trimmedPath.isNotEmpty()) {
        if ("" in trimmedPath.split('.')) {
            throw InvalidPathException(path)
        }
    }
}

/**
 * Required item without default value.
 *
 * Required item must be set with value before retrieved in config.
 */
open class RequiredItem<T> @JvmOverloads constructor(
    spec: Spec,
    name: String,
    description: String = "",
    type: JavaType? = null,
    nullable: Boolean = false
) : Item<T>(spec, name, description, type, nullable) {
    override val isRequired: Boolean = true
}

/**
 * Optional item with default value.
 *
 * Before associated with specified value, default value will be returned when accessing.
 * After associated with specified value, the specified value will be returned when accessing.
 */
open class OptionalItem<T> @JvmOverloads constructor(
    spec: Spec,
    name: String,
    /**
     * Default value returned before associating this item with specified value.
     */
    val default: T,
    description: String = "",
    type: JavaType? = null,
    nullable: Boolean = false
) : Item<T>(spec, name, description, type, nullable) {
    init {
        if (!nullable) {
            requireNotNull<Any>(default)
        }
    }

    override val isOptional: Boolean = true
}

/**
 * Lazy item evaluated value every time from thunk before associated with specified value.
 *
 * Before associated with specified value, value evaluated from thunk will be returned when accessing.
 * After associated with specified value, the specified value will be returned when accessing.
 * Returned value of the thunk will not be cached. The thunk will be evaluated every time
 * when needed to reflect modifying of other values in config.
 */
open class LazyItem<T> @JvmOverloads constructor(
    spec: Spec,
    name: String,
    /**
     * Thunk used to evaluate value for this item.
     *
     * [ItemContainer] is provided as evaluation environment to avoid unexpected modification
     * to config.
     * Thunk will be evaluated every time when needed to reflect modifying of other values in config.
     */
    val thunk: (config: ItemContainer) -> T,
    description: String = "",
    type: JavaType? = null,
    nullable: Boolean = false
) : Item<T>(spec, name, description, type, nullable) {
    override val isLazy: Boolean = true
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/ItemContainer.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

/**
 * Container of items.
 *
 * Item container contains read-only access operations for item.
 *
 * @see Config
 */
interface ItemContainer : Iterable<Item<*>> {
    /**
     * Get associated value with specified item.
     *
     * @param item config item
     * @return associated value
     */
    operator fun <T> get(item: Item<T>): T

    /**
     * Get associated value with specified item name.
     *
     * @param name item name
     * @return associated value
     */
    operator fun <T> get(name: String): T

    /**
     * Returns associated value if specified item exists, `null` otherwise.
     *
     * @param item config item
     * @return associated value if specified item exists, `null` otherwise
     */
    fun <T> getOrNull(item: Item<T>): T?

    /**
     * Returns associated value if specified item name exists, `null` otherwise.
     *
     * @param name item name
     * @return associated value if specified item name exists, `null` otherwise
     */
    fun <T> getOrNull(name: String): T?

    /**
     * Get associated value with specified item name.
     *
     * @param name item name
     * @return associated value
     */
    operator fun <T> invoke(name: String): T = get(name)

    /**
     * Returns iterator of items in this item container.
     *
     * @return iterator of items in this item container
     */
    override operator fun iterator(): Iterator<Item<*>>

    /**
     * Whether this item container contains specified item or not.
     *
     * @param item config item
     * @return `true` if this item container contains specified item, `false` otherwise
     */
    operator fun contains(item: Item<*>): Boolean

    /**
     * Whether this item container contains item with specified name or not.
     *
     * @param name item name
     * @return `true` if this item container contains item with specified name, `false` otherwise
     */
    operator fun contains(name: String): Boolean

    /**
     * Whether this item container contains the specified path or not.
     *
     * @param path the specified path
     * @return `true` if this item container contains the specified path, `false` otherwise
     */
    operator fun contains(path: Path): Boolean

    /**
     * Returns the qualified name of the specified item.
     *
     * @param item the specified item
     * @return the qualified name of the specified item
     */
    fun nameOf(item: Item<*>): String

    /**
     * Returns the qualified path of the specified item.
     *
     * @param item the specified item
     * @return the qualified path of the specified item
     */
    fun pathOf(item: Item<*>): Path = nameOf(item).toPath()

    /**
     * List of items in this item container.
     */
    val items: List<Item<*>>
        get() = mutableListOf<Item<*>>().apply {
            addAll(this@ItemContainer.iterator().asSequence())
        }

    /**
     * List of qualified names of items in this item container.
     */
    val nameOfItems: List<String> get() = itemWithNames.map { it.second }

    /**
     * List of items with the corresponding qualified names in this item container.
     */
    val itemWithNames: List<Pair<Item<*>, String>>
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/MergedConfig.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.uchuhimo.konf.source.Source

/**
 * Config that merge [fallback] and [facade].
 *
 * All operations will be applied to [facade] first, and then fall back to [facade] when necessary.
 */
open class MergedConfig(val fallback: BaseConfig, val facade: BaseConfig) :
    BaseConfig("merged(facade=${facade.name.notEmptyOr("\"\"")}, fallback=${fallback.name.notEmptyOr("\"\"")})") {

    override fun rawSet(item: Item<*>, value: Any?) {
        if (item in facade) {
            facade.rawSet(item, value)
        } else {
            fallback.rawSet(item, value)
        }
    }

    override fun getItemOrNull(name: String): Item<*>? {
        return facade.getItemOrNull(name) ?: fallback.getItemOrNull(name)
    }

    override fun <T> lazySet(item: Item<T>, thunk: (config: ItemContainer) -> T) {
        if (item in facade) {
            facade.lazySet(item, thunk)
        } else {
            fallback.lazySet(item, thunk)
        }
    }

    override fun unset(item: Item<*>) {
        if (item in facade) {
            facade.unset(item)
        } else {
            fallback.unset(item)
        }
    }

    override fun addBeforeLoadFunction(beforeLoadFunction: (source: Source) -> Unit) {
        facade.addBeforeLoadFunction(beforeLoadFunction)
        fallback.addBeforeLoadFunction(beforeLoadFunction)
    }

    override fun removeBeforeLoadFunction(beforeLoadFunction: (source: Source) -> Unit) {
        facade.removeBeforeLoadFunction(beforeLoadFunction)
        fallback.removeBeforeLoadFunction(beforeLoadFunction)
    }

    override fun addAfterLoadFunction(afterLoadFunction: (source: Source) -> Unit) {
        facade.addAfterLoadFunction(afterLoadFunction)
        fallback.addAfterLoadFunction(afterLoadFunction)
    }

    override fun removeAfterLoadFunction(afterLoadFunction: (source: Source) -> Unit) {
        facade.removeAfterLoadFunction(afterLoadFunction)
        fallback.removeAfterLoadFunction(afterLoadFunction)
    }

    override fun addBeforeSetFunction(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        facade.addBeforeSetFunction(beforeSetFunction)
        fallback.addBeforeSetFunction(beforeSetFunction)
    }

    override fun removeBeforeSetFunction(beforeSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        facade.removeBeforeSetFunction(beforeSetFunction)
        fallback.removeBeforeSetFunction(beforeSetFunction)
    }

    override fun addAfterSetFunction(afterSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        facade.addAfterSetFunction(afterSetFunction)
        fallback.addAfterSetFunction(afterSetFunction)
    }

    override fun removeAfterSetFunction(afterSetFunction: (item: Item<*>, value: Any?) -> Unit) {
        facade.removeAfterSetFunction(afterSetFunction)
        fallback.removeAfterSetFunction(afterSetFunction)
    }

    override fun clear() {
        facade.clear()
        fallback.clear()
    }

    override fun clearAll() {
        facade.clearAll()
        fallback.clearAll()
    }

    override val specs: List<Spec>
        get() = facade.specs + fallback.specs

    override val sources: List<Source>
        get() = facade.sources.toMutableList().apply {
            for (source in fallback.sources) {
                add(source)
            }
        }

    override fun addItem(item: Item<*>, prefix: String) {
        val path = prefix.toPath() + item.name.toPath()
        val name = path.name
        if (item !in fallback) {
            if (path in fallback) {
                throw NameConflictException("item $name cannot be added")
            }
        } else {
            throw RepeatedItemException(name)
        }
        facade.addItem(item, prefix)
    }

    override fun addSpec(spec: Spec) {
        spec.items.forEach { item ->
            val name = spec.qualify(item)
            if (item !in fallback) {
                val path = name.toPath()
                if (path in fallback) {
                    throw NameConflictException("item $name cannot be added")
                }
            } else {
                throw RepeatedItemException(name)
            }
        }
        facade.addSpec(spec)
    }

    override fun <T> lock(action: () -> T): T = facade.lock { fallback.lock(action) }

    override fun getOrNull(
        item: Item<*>,
        errorWhenNotFound: Boolean,
        errorWhenGetDefault: Boolean,
        lazyContext: ItemContainer
    ): Any? {
        if (item in facade && item in fallback) {
            try {
                return facade.getOrNull(item, errorWhenNotFound, true, lazyContext)
            } catch (ex: Exception) {
                when (ex) {
                    is UnsetValueException -> {
                        return fallback.getOrNull(item, errorWhenNotFound, errorWhenGetDefault, lazyContext)
                    }
                    is GetDefaultValueException -> {
                        try {
                            return fallback.getOrNull(item, errorWhenNotFound, errorWhenGetDefault, lazyContext)
                        } catch (ex: Exception) {
                            when (ex) {
                                is UnsetValueException -> {
                                    if (errorWhenGetDefault) {
                                        throw GetDefaultValueException(item)
                                    } else {
                                        return (item as OptionalItem).default
                                    }
                                }
                                else -> throw ex
                            }
                        }
                    }
                    else -> throw ex
                }
            }
        } else if (item in facade) {
            return facade.getOrNull(item, errorWhenNotFound, errorWhenGetDefault, lazyContext)
        } else {
            return fallback.getOrNull(item, errorWhenNotFound, errorWhenGetDefault, lazyContext)
        }
    }

    override fun iterator(): Iterator<Item<*>> =
        (facade.iterator().asSequence() + fallback.iterator().asSequence()).iterator()

    override fun contains(item: Item<*>): Boolean = item in facade || item in fallback

    override fun contains(name: String): Boolean = name in facade || name in fallback

    override fun contains(path: Path): Boolean = path in facade || path in fallback

    override fun nameOf(item: Item<*>): String {
        return if (item in facade) {
            facade.nameOf(item)
        } else {
            fallback.nameOf(item)
        }
    }

    override val itemWithNames: List<Pair<Item<*>, String>>
        get() = facade.itemWithNames + fallback.itemWithNames
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/MergedMap.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

class MergedMap<K, V>(val fallback: MutableMap<K, V>, val facade: MutableMap<K, V>) : MutableMap<K, V> {
    override val size: Int
        get() = keys.size

    override fun containsKey(key: K): Boolean {
        return facade.containsKey(key) || fallback.containsKey(key)
    }

    override fun containsValue(value: V): Boolean {
        return facade.containsValue(value) || fallback.containsValue(value)
    }

    override fun get(key: K): V? {
        return facade[key] ?: fallback[key]
    }

    override fun isEmpty(): Boolean {
        return facade.isEmpty() && fallback.isEmpty()
    }

    override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
        get() = keys.map { it to getValue(it) }.toMap(LinkedHashMap()).entries
    override val keys: MutableSet<K>
        get() = facade.keys.union(fallback.keys).toMutableSet()
    override val values: MutableCollection<V>
        get() = keys.map { getValue(it) }.toMutableList()

    override fun clear() {
        facade.clear()
        fallback.clear()
    }

    override fun put(key: K, value: V): V? {
        return facade.put(key, value)
    }

    override fun putAll(from: Map<out K, V>) {
        facade.putAll(from)
    }

    override fun remove(key: K): V? {
        if (key in facade) {
            if (key in fallback) {
                fallback.remove(key)
            }
            return facade.remove(key)
        } else {
            return fallback.remove(key)
        }
    }
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/Prefix.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.uchuhimo.konf.source.Source

/**
 * Convenient class for constructing [Spec]/[Config]/[Source] with prefix.
 */
data class Prefix(
    /**
     * The path of the prefix
     */
    val path: String = ""
) {
    /**
     * Returns a config spec with this prefix.
     *
     * @param spec the base config spec
     * @return a config spec with this prefix
     */
    operator fun plus(spec: Spec): Spec = spec.withPrefix(path)

    /**
     * Returns a config with this prefix.
     *
     * @param config the base config
     * @return a config with this prefix
     */
    operator fun plus(config: Config): Config = config.withPrefix(path)

    /**
     * Returns a source with this prefix.
     *
     * @param source the base source
     * @return a source with this prefix
     */
    operator fun plus(source: Source): Source = source.withPrefix(path)
}


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/SizeInBytes.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonValue
import com.uchuhimo.konf.source.ParseException
import java.io.Serializable
import java.math.BigDecimal
import java.math.BigInteger

/**
 * Represents size in unit of bytes.
 */
data class SizeInBytes(
    /**
     * Number of bytes.
     */
    @JsonValue
    val bytes: Long
) : Serializable {
    init {
        require(bytes >= 0)
    }

    companion object {
        /**
         * Parses a size-in-bytes string. If no units are specified in the string,
         * it is assumed to be in bytes. The returned value is in bytes.
         *
         * @param input the string to parse
         * @return size in bytes
         */
        @JsonCreator
        @JvmStatic
        fun parse(input: String): SizeInBytes {
            val s = input.trim()
            val unitString = getUnits(s)
            val numberString = s.substring(
                0,
                s.length - unitString.length
            ).trim()

            // this would be caught later anyway, but the error message
            // is more helpful if we check it here.
            if (numberString.isEmpty())
                throw ParseException("No number in size-in-bytes value '$input'")

            val units = MemoryUnit.parseUnit(unitString)
                ?: throw ParseException(
                    "Could not parse size-in-bytes unit '$unitString'" +
                        " (try k, K, kB, KiB, kilobytes, kibibytes)"
                )

            try {
                val result: BigInteger
                // if the string is purely digits, parse as an integer to avoid
                // possible precision loss; otherwise as a double.
                result = if (numberString.matches("[0-9]+".toRegex())) {
                    units.bytes.multiply(BigInteger(numberString))
                } else {
                    val resultDecimal = BigDecimal(units.bytes).multiply(BigDecimal(numberString))
                    resultDecimal.toBigInteger()
                }
                return if (result.bitLength() < 64) {
                    SizeInBytes(result.toLong())
                } else {
                    throw ParseException("size-in-bytes value is out of range for a 64-bit long: '$input'")
                }
            } catch (e: NumberFormatException) {
                throw ParseException("Could not parse size-in-bytes number '$numberString'")
            }
        }

        private enum class Radix {
            KILO {
                override fun toInt(): Int = 1000
            },
            KIBI {
                override fun toInt(): Int = 1024
            };

            abstract fun toInt(): Int
        }

        private enum class MemoryUnit(
            private val prefix: String,
            private val radix: Radix,
            private val power: Int
        ) {
            BYTES("", Radix.KIBI, 0),

            KILOBYTES("kilo", Radix.KILO, 1),
            MEGABYTES("mega", Radix.KILO, 2),
            GIGABYTES("giga", Radix.KILO, 3),
            TERABYTES("tera", Radix.KILO, 4),
            PETABYTES("peta", Radix.KILO, 5),
            EXABYTES("exa", Radix.KILO, 6),
            ZETTABYTES("zetta", Radix.KILO, 7),
            YOTTABYTES("yotta", Radix.KILO, 8),

            KIBIBYTES("kibi", Radix.KIBI, 1),
            MEBIBYTES("mebi", Radix.KIBI, 2),
            GIBIBYTES("gibi", Radix.KIBI, 3),
            TEBIBYTES("tebi", Radix.KIBI, 4),
            PEBIBYTES("pebi", Radix.KIBI, 5),
            EXBIBYTES("exbi", Radix.KIBI, 6),
            ZEBIBYTES("zebi", Radix.KIBI, 7),
            YOBIBYTES("yobi", Radix.KIBI, 8);

            internal val bytes: BigInteger = BigInteger.valueOf(radix.toInt().toLong()).pow(power)

            companion object {

                private val unitsMap = mutableMapOf<String, MemoryUnit>().apply {
                    for (unit in MemoryUnit.values()) {
                        put(unit.prefix + "byte", unit)
                        put(unit.prefix + "bytes", unit)
                        if (unit.prefix.isEmpty()) {
                            put("b", unit)
                            put("B", unit)
                            put("", unit) // no unit specified means bytes
                        } else {
                            val first = unit.prefix.substring(0, 1)
                            val firstUpper = first.toUpperCase()
                            when (unit.radix) {
                                Radix.KILO -> {
                                    if (unit.power == 1) {
                                        put(first + "B", unit) // 512kB
                                    } else {
                                        put(firstUpper + "B", unit) // 512MB
                                    }
                                }
                                Radix.KIBI -> {
                                    put(first, unit) // 512m
                                    put(firstUpper, unit) // 512M
                                    put(firstUpper + "i", unit) // 512Mi
                                    put(firstUpper + "iB", unit) // 512MiB
                                }
                            }
                        }
                    }
                }

                internal fun parseUnit(unit: String): MemoryUnit? {
                    return unitsMap[unit]
                }
            }
        }
    }
}

/**
 * Converts a string to [SizeInBytes].
 */
fun String.toSizeInBytes(): SizeInBytes = SizeInBytes.parse(this)


================================================
FILE: konf-core/src/main/kotlin/com/uchuhimo/konf/Spec.kt
================================================
/*
 * Copyright 2017-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uchuhimo.konf

import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.type.TypeFactory
import kotlin.properties.PropertyDelegateProvider
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty

/**
 * Config spec is specification for config.
 *
 * Config spec describes a group of items with common prefix, which can be loaded into config
 * together using [Config.addSpec].
 * Config spec also provides convenient API to specify item in it without hand-written object
 * declaration.
 *
 * @see Config
 */
interface Spec {
    /**
     * Common prefix for items in this config spec.
     *
     * An empty prefix means names of items in this config spec are unqualified.
     */
    val prefix: String

    /**
     * Qualify item name with prefix of this config spec.
     *
     * When prefix is empty, original item name will be returned.
     *
     * @param item the config item
     * @return qualified item name
     */
    fun qualify(item: Item<*>): String = (prefix.toPath() + item.path).name

    /**
     * Add the specified item into this config spec.
     *
     * @param item the specified item
     */
    fun addItem(item: Item<*>)

    /**
     * Set of specified items in this config spec.
     */
    val items: Set<Item<*>>

    /**
     * Add the specified inner spec into this config spec.
     *
     * @param spec the specified spec
     */
    fun addInnerSpec(spec: Spec)

    /**
     * Set of inner specs in this config spec.
     */
    val innerSpecs: Set<Spec>

    /**
     * Returns a config spec overlapped by the specified facade config spec.
     *
     * New items will be added to the facade config spec.
     *
     * @param spec the facade config spec
     * @return a config spec overlapped by the specified facade config spec
     */
    operator fun plus(spec: Spec): Spec {
        return object : Spec by spec {
            override fun addItem(item: Item<*>) {
                if (item !in this@Spec.items) {
                    spec.addItem(item)
                } else {
                    throw RepeatedItemException(item.name)
                }
            }

            override val items: Set<Item<*>>
                get() = this@Spec.items + spec.items

            override fun qualify(item: Item<*>): String {
                return if (item in spec.items) {
                    spec.qualify(item)
                } else {
                    this@Spec.qualify(item)
                }
            }
        }
    }

    /**
     * Returns a config spec backing by the specified fallback config spec.
     *
     * New items will be added to the current config spec.
     *
     * @param spec the fallback config spec
     * @return a config spec backing by the specified fallback config spec
     */
    fun withFallback(spec: Spec): Spec = spec + this

    /**
     * Returns sub-spec in the specified path.
     *
     * @param path the specified path
     * @return sub-source with specified prefix
     */
    operator fun get(path: String): Spec = get(prefix.toPath(), path
Download .txt
gitextract_30e7_42m/

├── .gitattributes
├── .github/
│   ├── stale.yml
│   └── workflows/
│       └── gradle.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.gradle.kts
├── buildSrc/
│   ├── build.gradle.kts
│   ├── settings.gradle.kts
│   └── src/
│       └── main/
│           └── kotlin/
│               ├── Dependencies.kt
│               └── Utils.kt
├── config/
│   └── spotless/
│       ├── apache-license-2.0.java
│       └── apache-license-2.0.kt
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── konf-all/
│   ├── build.gradle.kts
│   └── src/
│       ├── snippet/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── snippet/
│       │   │                   ├── ServerInJava.java
│       │   │                   └── ServerSpecInJava.java
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── snippet/
│       │   │                   ├── Config.kt
│       │   │                   ├── Export.kt
│       │   │                   ├── Fork.kt
│       │   │                   ├── Load.kt
│       │   │                   ├── QuickStart.kt
│       │   │                   ├── Serialize.kt
│       │   │                   └── Server.kt
│       │   └── resources/
│       │       └── server.json
│       └── test/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               ├── MergeSourcesWithDifferentFeaturesSpec.kt
│                               ├── MultiLayerConfigToValueSpec.kt
│                               ├── MultipleDefaultLoadersSpec.kt
│                               └── QuickStartSpec.kt
├── konf-core/
│   ├── build.gradle.kts
│   └── src/
│       ├── jmh/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── ConfigBenchmark.kt
│       ├── main/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── Configs.java
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   ├── BaseConfig.kt
│       │                   ├── Config.kt
│       │                   ├── ConfigException.kt
│       │                   ├── ConfigSpec.kt
│       │                   ├── Feature.kt
│       │                   ├── Item.kt
│       │                   ├── ItemContainer.kt
│       │                   ├── MergedConfig.kt
│       │                   ├── MergedMap.kt
│       │                   ├── Prefix.kt
│       │                   ├── SizeInBytes.kt
│       │                   ├── Spec.kt
│       │                   ├── TreeNode.kt
│       │                   ├── Utils.kt
│       │                   ├── annotation/
│       │                   │   └── Annotations.kt
│       │                   └── source/
│       │                       ├── DefaultLoaders.kt
│       │                       ├── DefaultProviders.kt
│       │                       ├── Loader.kt
│       │                       ├── MergedSource.kt
│       │                       ├── Provider.kt
│       │                       ├── Source.kt
│       │                       ├── SourceException.kt
│       │                       ├── SourceNode.kt
│       │                       ├── Utils.kt
│       │                       ├── Writer.kt
│       │                       ├── base/
│       │                       │   ├── FlatSource.kt
│       │                       │   ├── KVSource.kt
│       │                       │   ├── MapSource.kt
│       │                       │   └── ValueSource.kt
│       │                       ├── deserializer/
│       │                       │   ├── DurationDeserializer.kt
│       │                       │   ├── EmptyStringToCollectionDeserializerModifier.kt
│       │                       │   ├── JSR310Deserializer.kt
│       │                       │   ├── OffsetDateTimeDeserializer.kt
│       │                       │   ├── StringDeserializer.kt
│       │                       │   └── ZoneDateTimeDeserializer.kt
│       │                       ├── env/
│       │                       │   └── EnvProvider.kt
│       │                       ├── json/
│       │                       │   ├── JsonProvider.kt
│       │                       │   ├── JsonSource.kt
│       │                       │   └── JsonWriter.kt
│       │                       └── properties/
│       │                           ├── PropertiesProvider.kt
│       │                           └── PropertiesWriter.kt
│       ├── test/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               ├── AnonymousConfigSpec.java
│       │   │               ├── ConfigJavaApiTest.java
│       │   │               └── NetworkBufferInJava.java
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               ├── AdHocConfigItemSpec.kt
│       │   │               ├── AdHocNetworkBuffer.kt
│       │   │               ├── ConfigInJavaSpec.kt
│       │   │               ├── ConfigSpecTestSpec.kt
│       │   │               ├── ConfigTestSpec.kt
│       │   │               ├── FeatureSpec.kt
│       │   │               ├── MergedConfigSpek.kt
│       │   │               ├── MergedMapSpec.kt
│       │   │               ├── MultiLayerConfigSpec.kt
│       │   │               ├── NetworkBuffer.kt
│       │   │               ├── ParseDurationSpec.kt
│       │   │               ├── RelocatedConfigSpec.kt
│       │   │               ├── SizeInBytesSpec.kt
│       │   │               ├── TreeNodeSpec.kt
│       │   │               └── source/
│       │   │                   ├── CustomDeserializerSpec.kt
│       │   │                   ├── DefaultLoadersSpec.kt
│       │   │                   ├── DefaultProvidersSpec.kt
│       │   │                   ├── FacadeSourceSpec.kt
│       │   │                   ├── FallbackSourceSpec.kt
│       │   │                   ├── LoaderSpec.kt
│       │   │                   ├── MergedSourceLoadSpec.kt
│       │   │                   ├── ProviderSpec.kt
│       │   │                   ├── SourceInfoSpec.kt
│       │   │                   ├── SourceLoadSpec.kt
│       │   │                   ├── SourceNodeSpec.kt
│       │   │                   ├── SourceSpec.kt
│       │   │                   ├── WriterSpec.kt
│       │   │                   ├── base/
│       │   │                   │   ├── FlatSourceLoadSpec.kt
│       │   │                   │   ├── FlatSourceSpec.kt
│       │   │                   │   ├── KVSourceSpec.kt
│       │   │                   │   ├── MapSourceLoadSpec.kt
│       │   │                   │   ├── MapSourceSpec.kt
│       │   │                   │   └── ValueSourceSpec.kt
│       │   │                   ├── deserializer/
│       │   │                   │   ├── DurationDeserializerSpec.kt
│       │   │                   │   ├── OffsetDateTimeDeserializerSpec.kt
│       │   │                   │   ├── StringDeserializerSpec.kt
│       │   │                   │   └── ZonedDateTimeDeserializerSpec.kt
│       │   │                   ├── env/
│       │   │                   │   ├── EnvProviderSpec.kt
│       │   │                   │   └── env.properties
│       │   │                   ├── json/
│       │   │                   │   ├── JsonProviderSpec.kt
│       │   │                   │   ├── JsonSourceLoadSpec.kt
│       │   │                   │   ├── JsonSourceSpec.kt
│       │   │                   │   └── JsonWriterSpec.kt
│       │   │                   ├── properties/
│       │   │                   │   ├── PropertiesProviderSpec.kt
│       │   │                   │   └── PropertiesSourceLoadSpec.kt
│       │   │                   └── serializer/
│       │   │                       └── PrimitiveStdSerializerSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           ├── provider.properties
│       │           ├── source.json
│       │           └── source.properties
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           ├── TestUtils.kt
│                           └── source/
│                               ├── ConfigForLoad.kt
│                               ├── SingleThreadDispatcher.kt
│                               ├── SourceLoadBaseSpec.kt
│                               ├── TestUtils.kt
│                               └── base/
│                                   ├── FlatConfigForLoad.kt
│                                   └── FlatSourceLoadBaseSpec.kt
├── konf-git/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultGitLoader.kt
│       │                       ├── DefaultGitProvider.kt
│       │                       ├── GitLoader.kt
│       │                       └── GitProvider.kt
│       └── test/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               ├── DefaultGitLoaderSpec.kt
│                               ├── DefaultGitProviderSpec.kt
│                               ├── GitLoaderSpec.kt
│                               └── GitProviderSpec.kt
├── konf-hocon/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultHoconLoader.kt
│       │                       ├── DefaultHoconProvider.kt
│       │                       └── hocon/
│       │                           ├── HoconProvider.kt
│       │                           ├── HoconSource.kt
│       │                           └── HoconWriter.kt
│       ├── test/
│       │   ├── java/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               ├── LoaderJavaApiTest.java
│       │   │               └── NetworkBufferInJava.java
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultHoconLoaderSpec.kt
│       │   │                   ├── DefaultHoconProviderSpec.kt
│       │   │                   └── hocon/
│       │   │                       ├── HoconProviderSpec.kt
│       │   │                       ├── HoconSourceLoadSpec.kt
│       │   │                       ├── HoconSourceSpec.kt
│       │   │                       ├── HoconValueSourceSpec.kt
│       │   │                       └── HoconWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.conf
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── HoconTestUtils.kt
├── konf-js/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultJsLoader.kt
│       │                       ├── DefaultJsProvider.kt
│       │                       └── js/
│       │                           ├── JsProvider.kt
│       │                           └── JsWriter.kt
│       └── test/
│           ├── kotlin/
│           │   └── com/
│           │       └── uchuhimo/
│           │           └── konf/
│           │               └── source/
│           │                   ├── DefaultJsLoaderSpec.kt
│           │                   ├── DefaultJsProviderSpec.kt
│           │                   └── js/
│           │                       ├── JsProviderSpec.kt
│           │                       ├── JsSourceLoadSpec.kt
│           │                       └── JsWriterSpec.kt
│           └── resources/
│               └── source/
│                   └── source.js
├── konf-toml/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           ├── moandjiezana/
│       │           │   └── toml/
│       │           │       └── Toml4jWriter.kt
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultTomlLoader.kt
│       │                       ├── DefaultTomlProvider.kt
│       │                       └── toml/
│       │                           ├── TomlProvider.kt
│       │                           └── TomlWriter.kt
│       ├── test/
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultTomlLoaderSpec.kt
│       │   │                   ├── DefaultTomlProviderSpec.kt
│       │   │                   └── toml/
│       │   │                       ├── TomlProviderSpec.kt
│       │   │                       ├── TomlSourceLoadSpec.kt
│       │   │                       ├── TomlValueSourceSpec.kt
│       │   │                       └── TomlWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.toml
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── TomlTestUtils.kt
├── konf-xml/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultXmlLoader.kt
│       │                       ├── DefaultXmlProvider.kt
│       │                       └── xml/
│       │                           ├── XmlProvider.kt
│       │                           └── XmlWriter.kt
│       ├── test/
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultXmlLoaderSpec.kt
│       │   │                   ├── DefaultXmlProviderSpec.kt
│       │   │                   └── xml/
│       │   │                       ├── XmlProviderSpec.kt
│       │   │                       ├── XmlSourceLoadSpec.kt
│       │   │                       └── XmlWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.xml
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── XmlTestUtils.kt
├── konf-yaml/
│   ├── build.gradle.kts
│   └── src/
│       ├── main/
│       │   └── kotlin/
│       │       └── com/
│       │           └── uchuhimo/
│       │               └── konf/
│       │                   └── source/
│       │                       ├── DefaultYamlLoader.kt
│       │                       ├── DefaultYamlProvider.kt
│       │                       └── yaml/
│       │                           ├── YamlProvider.kt
│       │                           └── YamlWriter.kt
│       ├── test/
│       │   ├── kotlin/
│       │   │   └── com/
│       │   │       └── uchuhimo/
│       │   │           └── konf/
│       │   │               └── source/
│       │   │                   ├── DefaultYamlLoaderSpec.kt
│       │   │                   ├── DefaultYamlProviderSpec.kt
│       │   │                   └── yaml/
│       │   │                       ├── YamlProviderSpec.kt
│       │   │                       ├── YamlSourceLoadSpec.kt
│       │   │                       └── YamlWriterSpec.kt
│       │   └── resources/
│       │       └── source/
│       │           └── source.yaml
│       └── testFixtures/
│           └── kotlin/
│               └── com/
│                   └── uchuhimo/
│                       └── konf/
│                           └── source/
│                               └── YamlTestUtils.kt
└── settings.gradle.kts
Download .txt
SYMBOL INDEX (29 symbols across 8 files)

FILE: konf-all/src/snippet/java/com/uchuhimo/konf/snippet/ServerInJava.java
  class ServerInJava (line 21) | public class ServerInJava {
    method ServerInJava (line 25) | public ServerInJava(String host, Integer tcpPort) {
    method ServerInJava (line 30) | public ServerInJava(Config config) {
    method getHost (line 34) | public String getHost() {
    method getTcpPort (line 38) | public Integer getTcpPort() {

FILE: konf-all/src/snippet/java/com/uchuhimo/konf/snippet/ServerSpecInJava.java
  class ServerSpecInJava (line 23) | public class ServerSpecInJava {

FILE: konf-core/src/main/java/com/uchuhimo/konf/Configs.java
  class Configs (line 22) | public final class Configs {
    method Configs (line 23) | private Configs() {}
    method create (line 30) | public static Config create() {
    method create (line 40) | public static Config create(Consumer<Config> init) {

FILE: konf-core/src/test/java/com/uchuhimo/konf/AnonymousConfigSpec.java
  class AnonymousConfigSpec (line 19) | public class AnonymousConfigSpec {

FILE: konf-core/src/test/java/com/uchuhimo/konf/ConfigJavaApiTest.java
  class ConfigJavaApiTest (line 28) | @DisplayName("test Java API of Config")
    method initConfig (line 32) | @BeforeEach
    method create (line 38) | @Test
    method createWithInit (line 45) | @Test
    method loadFromMap (line 52) | @Test
    method loadFromSystem (line 61) | @Test
    method loadFromSource (line 69) | @Test
    method getWithItem (line 78) | @Test
    method getWithName (line 85) | @Test
    method setWithItem (line 92) | @Test
    method setWithName (line 99) | @Test
    method lazySetWithItem (line 106) | @Test
    method lazySetWithName (line 114) | @Test

FILE: konf-core/src/test/java/com/uchuhimo/konf/NetworkBufferInJava.java
  class NetworkBufferInJava (line 19) | public class NetworkBufferInJava {

FILE: konf-hocon/src/test/java/com/uchuhimo/konf/LoaderJavaApiTest.java
  class LoaderJavaApiTest (line 27) | @DisplayName("test Java API of loader")
    method initConfig (line 31) | @BeforeEach
    method loadFromDefaultLoader (line 37) | @Test

FILE: konf-hocon/src/test/java/com/uchuhimo/konf/NetworkBufferInJava.java
  class NetworkBufferInJava (line 19) | public class NetworkBufferInJava {
Condensed preview — 213 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (906K chars).
[
  {
    "path": ".gitattributes",
    "chars": 374,
    "preview": "# text stuff\n* text=lf\n*.bat text eol=crlf\n*.cmd text eol=crlf\n*.java text eol=lf\n*.kt text eol=lf\n*.md text eol=lf\n*.pr"
  },
  {
    "path": ".github/stale.yml",
    "chars": 751,
    "preview": "# Configuration for probot-stale - https://github.com/probot/stale\n\n# Number of days of inactivity before an Issue or Pu"
  },
  {
    "path": ".github/workflows/gradle.yml",
    "chars": 509,
    "preview": "name: Konf CI\n\non: [push]\n\njobs:\n  build:\n    name: Build on JDK ${{ matrix.java_version }} and ${{ matrix.os }}\n    run"
  },
  {
    "path": ".gitignore",
    "chars": 2951,
    "preview": "# Created by .ignore support plugin (hsz.mobi)\n### Java template\n*.class\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Pa"
  },
  {
    "path": ".travis.yml",
    "chars": 342,
    "preview": "language: java\n\njdk:\n  - oraclejdk11\n  - openjdk8\n  - openjdk11\n  - openjdk15\n\nafter_success:\n  - bash <(curl -s https:/"
  },
  {
    "path": "LICENSE",
    "chars": 11357,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "README.md",
    "chars": 35240,
    "preview": "# Konf\n\n[![Java 8+](https://img.shields.io/badge/Java-8+-4c7e9f.svg)](http://java.oracle.com)\n[![Maven metadata URL](htt"
  },
  {
    "path": "build.gradle.kts",
    "chars": 11200,
    "preview": "import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask\nimport org.jetbrains.kotlin.gradle.tasks.Kotlin"
  },
  {
    "path": "buildSrc/build.gradle.kts",
    "chars": 65,
    "preview": "plugins {\n    `kotlin-dsl`\n}\n\nrepositories {\n    mavenCentral()\n}"
  },
  {
    "path": "buildSrc/settings.gradle.kts",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "buildSrc/src/main/kotlin/Dependencies.kt",
    "chars": 1916,
    "preview": "import org.gradle.api.JavaVersion\n\nobject Versions {\n    val java = JavaVersion.VERSION_1_8\n    const val commonsText = "
  },
  {
    "path": "buildSrc/src/main/kotlin/Utils.kt",
    "chars": 1287,
    "preview": "import org.gradle.api.Project\nimport org.gradle.api.artifacts.dsl.RepositoryHandler\nimport org.gradle.kotlin.dsl.maven\ni"
  },
  {
    "path": "config/spotless/apache-license-2.0.java",
    "chars": 621,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "config/spotless/apache-license-2.0.kt",
    "chars": 621,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 200,
    "preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
  },
  {
    "path": "gradle.properties",
    "chars": 192,
    "preview": "org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en_US\norg.gradle.caching=true\norg.gradle.vfs."
  },
  {
    "path": "gradlew",
    "chars": 5766,
    "preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
  },
  {
    "path": "gradlew.bat",
    "chars": 2763,
    "preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
  },
  {
    "path": "konf-all/build.gradle.kts",
    "chars": 552,
    "preview": "sourceSets {\n    register(\"snippet\")\n}\n\nval snippetImplementation by configurations\nsnippetImplementation.extendsFrom(co"
  },
  {
    "path": "konf-all/src/snippet/java/com/uchuhimo/konf/snippet/ServerInJava.java",
    "chars": 1114,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/java/com/uchuhimo/konf/snippet/ServerSpecInJava.java",
    "chars": 1086,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Config.kt",
    "chars": 2440,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Export.kt",
    "chars": 1344,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Fork.kt",
    "chars": 1374,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Load.kt",
    "chars": 913,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/QuickStart.kt",
    "chars": 2617,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Serialize.kt",
    "chars": 1333,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/kotlin/com/uchuhimo/konf/snippet/Server.kt",
    "chars": 1147,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/snippet/resources/server.json",
    "chars": 67,
    "preview": "{\n  \"server\": {\n    \"host\": \"127.0.0.1\",\n    \"tcp_port\": 8080\n  }\n}"
  },
  {
    "path": "konf-all/src/test/kotlin/com/uchuhimo/konf/source/MergeSourcesWithDifferentFeaturesSpec.kt",
    "chars": 1691,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/test/kotlin/com/uchuhimo/konf/source/MultiLayerConfigToValueSpec.kt",
    "chars": 1962,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/test/kotlin/com/uchuhimo/konf/source/MultipleDefaultLoadersSpec.kt",
    "chars": 3134,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-all/src/test/kotlin/com/uchuhimo/konf/source/QuickStartSpec.kt",
    "chars": 3901,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/build.gradle.kts",
    "chars": 74,
    "preview": "dependencies {\n    jmhImplementation(kotlin(\"stdlib\", Versions.kotlin))\n}\n"
  },
  {
    "path": "konf-core/src/jmh/kotlin/com/uchuhimo/konf/ConfigBenchmark.kt",
    "chars": 3814,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/java/com/uchuhimo/konf/Configs.java",
    "chars": 1228,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/BaseConfig.kt",
    "chars": 27249,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/Config.kt",
    "chars": 17370,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/ConfigException.kt",
    "chars": 3132,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/ConfigSpec.kt",
    "chars": 4146,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/Feature.kt",
    "chars": 1809,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/Item.kt",
    "chars": 8281,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/ItemContainer.kt",
    "chars": 3839,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/MergedConfig.kt",
    "chars": 7320,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/MergedMap.kt",
    "chars": 2123,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/Prefix.kt",
    "chars": 1520,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/SizeInBytes.kt",
    "chars": 6242,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/Spec.kt",
    "chars": 9935,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/TreeNode.kt",
    "chars": 11142,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/Utils.kt",
    "chars": 4327,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/annotation/Annotations.kt",
    "chars": 979,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/DefaultLoaders.kt",
    "chars": 15185,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/DefaultProviders.kt",
    "chars": 5992,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/Loader.kt",
    "chars": 13619,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/MergedSource.kt",
    "chars": 4591,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/Provider.kt",
    "chars": 10646,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/Source.kt",
    "chars": 41891,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/SourceException.kt",
    "chars": 4396,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/SourceNode.kt",
    "chars": 1895,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/Utils.kt",
    "chars": 3345,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/Writer.kt",
    "chars": 1816,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/base/FlatSource.kt",
    "chars": 5890,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/base/KVSource.kt",
    "chars": 1367,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/base/MapSource.kt",
    "chars": 2076,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/base/ValueSource.kt",
    "chars": 1143,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/deserializer/DurationDeserializer.kt",
    "chars": 1278,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/deserializer/EmptyStringToCollectionDeserializerModifier.kt",
    "chars": 5397,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/deserializer/JSR310Deserializer.kt",
    "chars": 2285,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/deserializer/OffsetDateTimeDeserializer.kt",
    "chars": 936,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/deserializer/StringDeserializer.kt",
    "chars": 2345,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/deserializer/ZoneDateTimeDeserializer.kt",
    "chars": 928,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/env/EnvProvider.kt",
    "chars": 1876,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/json/JsonProvider.kt",
    "chars": 1232,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/json/JsonSource.kt",
    "chars": 1979,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/json/JsonWriter.kt",
    "chars": 1631,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/properties/PropertiesProvider.kt",
    "chars": 1737,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/main/kotlin/com/uchuhimo/konf/source/properties/PropertiesWriter.kt",
    "chars": 2338,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/java/com/uchuhimo/konf/AnonymousConfigSpec.java",
    "chars": 735,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/java/com/uchuhimo/konf/ConfigJavaApiTest.java",
    "chars": 4031,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/java/com/uchuhimo/konf/NetworkBufferInJava.java",
    "chars": 1700,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/AdHocConfigItemSpec.kt",
    "chars": 4926,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/AdHocNetworkBuffer.kt",
    "chars": 1446,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/ConfigInJavaSpec.kt",
    "chars": 25408,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/ConfigSpecTestSpec.kt",
    "chars": 15536,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/ConfigTestSpec.kt",
    "chars": 38773,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/FeatureSpec.kt",
    "chars": 9272,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/MergedConfigSpek.kt",
    "chars": 3501,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/MergedMapSpec.kt",
    "chars": 5193,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/MultiLayerConfigSpec.kt",
    "chars": 7030,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/NetworkBuffer.kt",
    "chars": 1428,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/ParseDurationSpec.kt",
    "chars": 4806,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/RelocatedConfigSpec.kt",
    "chars": 3138,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/SizeInBytesSpec.kt",
    "chars": 2224,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/TreeNodeSpec.kt",
    "chars": 5088,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/CustomDeserializerSpec.kt",
    "chars": 2807,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/DefaultLoadersSpec.kt",
    "chars": 15953,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/DefaultProvidersSpec.kt",
    "chars": 4810,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/FacadeSourceSpec.kt",
    "chars": 4098,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/FallbackSourceSpec.kt",
    "chars": 4138,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/LoaderSpec.kt",
    "chars": 15432,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/MergedSourceLoadSpec.kt",
    "chars": 8333,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/ProviderSpec.kt",
    "chars": 9618,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/SourceInfoSpec.kt",
    "chars": 1829,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/SourceLoadSpec.kt",
    "chars": 6449,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/SourceNodeSpec.kt",
    "chars": 1422,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/SourceSpec.kt",
    "chars": 37972,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/WriterSpec.kt",
    "chars": 3371,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/FlatSourceLoadSpec.kt",
    "chars": 5310,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/FlatSourceSpec.kt",
    "chars": 5968,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/KVSourceSpec.kt",
    "chars": 2005,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/MapSourceLoadSpec.kt",
    "chars": 7328,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/MapSourceSpec.kt",
    "chars": 2256,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/base/ValueSourceSpec.kt",
    "chars": 1505,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/deserializer/DurationDeserializerSpec.kt",
    "chars": 2744,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/deserializer/OffsetDateTimeDeserializerSpec.kt",
    "chars": 2873,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/deserializer/StringDeserializerSpec.kt",
    "chars": 3634,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/deserializer/ZonedDateTimeDeserializerSpec.kt",
    "chars": 2888,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/env/EnvProviderSpec.kt",
    "chars": 2931,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/env/env.properties",
    "chars": 646,
    "preview": "#\n# Copyright 2017-2019 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/json/JsonProviderSpec.kt",
    "chars": 2543,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/json/JsonSourceLoadSpec.kt",
    "chars": 1541,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/json/JsonSourceSpec.kt",
    "chars": 6541,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/json/JsonWriterSpec.kt",
    "chars": 2188,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/properties/PropertiesProviderSpec.kt",
    "chars": 3033,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/properties/PropertiesSourceLoadSpec.kt",
    "chars": 1714,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/kotlin/com/uchuhimo/konf/source/serializer/PrimitiveStdSerializerSpec.kt",
    "chars": 3346,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/test/resources/source/provider.properties",
    "chars": 13,
    "preview": "type=resource"
  },
  {
    "path": "konf-core/src/test/resources/source/source.json",
    "chars": 3828,
    "preview": "{\n  \"level1\": {\n    \"level2\": {\n      \"empty\": \"null\",\n      \"literalEmpty\": null,\n      \"present\": 1,\n      \"boolean\": "
  },
  {
    "path": "konf-core/src/test/resources/source/source.properties",
    "chars": 3564,
    "preview": "level1.level2.empty=null\nlevel1.level2.literalEmpty=null\nlevel1.level2.present=1\nlevel1.level2.boolean=false\nlevel1.leve"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/TestUtils.kt",
    "chars": 837,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/source/ConfigForLoad.kt",
    "chars": 4645,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/source/SingleThreadDispatcher.kt",
    "chars": 1038,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/source/SourceLoadBaseSpec.kt",
    "chars": 13976,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/source/TestUtils.kt",
    "chars": 1455,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/source/base/FlatConfigForLoad.kt",
    "chars": 1393,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-core/src/testFixtures/kotlin/com/uchuhimo/konf/source/base/FlatSourceLoadBaseSpec.kt",
    "chars": 2504,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/build.gradle.kts",
    "chars": 172,
    "preview": "dependencies {\n    api(project(\":konf-core\"))\n    api(\"org.eclipse.jgit\", \"org.eclipse.jgit\", Versions.jgit)\n\n    testIm"
  },
  {
    "path": "konf-git/src/main/kotlin/com/uchuhimo/konf/source/DefaultGitLoader.kt",
    "chars": 3512,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/main/kotlin/com/uchuhimo/konf/source/DefaultGitProvider.kt",
    "chars": 1679,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/main/kotlin/com/uchuhimo/konf/source/GitLoader.kt",
    "chars": 3565,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/main/kotlin/com/uchuhimo/konf/source/GitProvider.kt",
    "chars": 3055,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/test/kotlin/com/uchuhimo/konf/source/DefaultGitLoaderSpec.kt",
    "chars": 7051,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/test/kotlin/com/uchuhimo/konf/source/DefaultGitProviderSpec.kt",
    "chars": 2044,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/test/kotlin/com/uchuhimo/konf/source/GitLoaderSpec.kt",
    "chars": 7086,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-git/src/test/kotlin/com/uchuhimo/konf/source/GitProviderSpec.kt",
    "chars": 3561,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/build.gradle.kts",
    "chars": 170,
    "preview": "dependencies {\n    api(project(\":konf-core\"))\n    implementation(\"com.typesafe\", \"config\", Versions.hocon)\n\n    testImpl"
  },
  {
    "path": "konf-hocon/src/main/kotlin/com/uchuhimo/konf/source/DefaultHoconLoader.kt",
    "chars": 818,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/main/kotlin/com/uchuhimo/konf/source/DefaultHoconProvider.kt",
    "chars": 795,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/main/kotlin/com/uchuhimo/konf/source/hocon/HoconProvider.kt",
    "chars": 1341,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/main/kotlin/com/uchuhimo/konf/source/hocon/HoconSource.kt",
    "chars": 2113,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/main/kotlin/com/uchuhimo/konf/source/hocon/HoconWriter.kt",
    "chars": 1653,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/java/com/uchuhimo/konf/LoaderJavaApiTest.java",
    "chars": 1490,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/java/com/uchuhimo/konf/NetworkBufferInJava.java",
    "chars": 886,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/DefaultHoconLoaderSpec.kt",
    "chars": 1465,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/DefaultHoconProviderSpec.kt",
    "chars": 1398,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/hocon/HoconProviderSpec.kt",
    "chars": 2506,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/hocon/HoconSourceLoadSpec.kt",
    "chars": 1588,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/hocon/HoconSourceSpec.kt",
    "chars": 3330,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/hocon/HoconValueSourceSpec.kt",
    "chars": 3216,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/kotlin/com/uchuhimo/konf/source/hocon/HoconWriterSpec.kt",
    "chars": 2298,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-hocon/src/test/resources/source/source.conf",
    "chars": 2286,
    "preview": "level1 {\n  level2 {\n    empty = \"null\"\n    literalEmpty = null\n    present = 1\n\n    boolean = false\n\n    int = 1\n    sho"
  },
  {
    "path": "konf-hocon/src/testFixtures/kotlin/com/uchuhimo/konf/source/HoconTestUtils.kt",
    "chars": 706,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/build.gradle.kts",
    "chars": 235,
    "preview": "dependencies {\n    api(project(\":konf-core\"))\n    implementation(\"org.graalvm.sdk\", \"graal-sdk\", Versions.graal)\n    imp"
  },
  {
    "path": "konf-js/src/main/kotlin/com/uchuhimo/konf/source/DefaultJsLoader.kt",
    "chars": 811,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/main/kotlin/com/uchuhimo/konf/source/DefaultJsProvider.kt",
    "chars": 788,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/main/kotlin/com/uchuhimo/konf/source/js/JsProvider.kt",
    "chars": 1827,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/main/kotlin/com/uchuhimo/konf/source/js/JsWriter.kt",
    "chars": 1537,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/test/kotlin/com/uchuhimo/konf/source/DefaultJsLoaderSpec.kt",
    "chars": 1574,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/test/kotlin/com/uchuhimo/konf/source/DefaultJsProviderSpec.kt",
    "chars": 1393,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/test/kotlin/com/uchuhimo/konf/source/js/JsProviderSpec.kt",
    "chars": 2511,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/test/kotlin/com/uchuhimo/konf/source/js/JsSourceLoadSpec.kt",
    "chars": 1554,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/test/kotlin/com/uchuhimo/konf/source/js/JsWriterSpec.kt",
    "chars": 2133,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-js/src/test/resources/source/source.js",
    "chars": 5316,
    "preview": "({\n    level1: {\n        level2: {\n            empty: null,\n            literalEmpty: null,\n            present: 1,\n    "
  },
  {
    "path": "konf-toml/build.gradle.kts",
    "chars": 180,
    "preview": "dependencies {\n    api(project(\":konf-core\"))\n    implementation(\"com.moandjiezana.toml\", \"toml4j\", Versions.toml4j)\n\n  "
  },
  {
    "path": "konf-toml/src/main/kotlin/com/moandjiezana/toml/Toml4jWriter.kt",
    "chars": 7977,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/main/kotlin/com/uchuhimo/konf/source/DefaultTomlLoader.kt",
    "chars": 813,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/main/kotlin/com/uchuhimo/konf/source/DefaultTomlProvider.kt",
    "chars": 790,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/main/kotlin/com/uchuhimo/konf/source/toml/TomlProvider.kt",
    "chars": 1351,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/main/kotlin/com/uchuhimo/konf/source/toml/TomlWriter.kt",
    "chars": 1456,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/kotlin/com/uchuhimo/konf/source/DefaultTomlLoaderSpec.kt",
    "chars": 1462,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/kotlin/com/uchuhimo/konf/source/DefaultTomlProviderSpec.kt",
    "chars": 1394,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/kotlin/com/uchuhimo/konf/source/toml/TomlProviderSpec.kt",
    "chars": 2503,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/kotlin/com/uchuhimo/konf/source/toml/TomlSourceLoadSpec.kt",
    "chars": 1578,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/kotlin/com/uchuhimo/konf/source/toml/TomlValueSourceSpec.kt",
    "chars": 1913,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/kotlin/com/uchuhimo/konf/source/toml/TomlWriterSpec.kt",
    "chars": 2355,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-toml/src/test/resources/source/source.toml",
    "chars": 2213,
    "preview": "[level1.level2]\nempty = \"null\"\nliteralEmpty = \"null\"\npresent = 1\n\nboolean = false\n\nint = 1\nshort = 2\nbyte = 3\nbigInteger"
  },
  {
    "path": "konf-toml/src/testFixtures/kotlin/com/uchuhimo/konf/source/TomlTestUtils.kt",
    "chars": 735,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/build.gradle.kts",
    "chars": 219,
    "preview": "dependencies {\n    api(project(\":konf-core\"))\n    implementation(\"org.dom4j\", \"dom4j\", Versions.dom4j)\n    implementatio"
  },
  {
    "path": "konf-xml/src/main/kotlin/com/uchuhimo/konf/source/DefaultXmlLoader.kt",
    "chars": 808,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/main/kotlin/com/uchuhimo/konf/source/DefaultXmlProvider.kt",
    "chars": 785,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/main/kotlin/com/uchuhimo/konf/source/xml/XmlProvider.kt",
    "chars": 1826,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/main/kotlin/com/uchuhimo/konf/source/xml/XmlWriter.kt",
    "chars": 2084,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/test/kotlin/com/uchuhimo/konf/source/DefaultXmlLoaderSpec.kt",
    "chars": 1457,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/test/kotlin/com/uchuhimo/konf/source/DefaultXmlProviderSpec.kt",
    "chars": 1389,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/test/kotlin/com/uchuhimo/konf/source/xml/XmlProviderSpec.kt",
    "chars": 2894,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/test/kotlin/com/uchuhimo/konf/source/xml/XmlSourceLoadSpec.kt",
    "chars": 1673,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/test/kotlin/com/uchuhimo/konf/source/xml/XmlWriterSpec.kt",
    "chars": 2354,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-xml/src/test/resources/source/source.xml",
    "chars": 11643,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n    <property>\n        <name>level1.level2.empty</name>\n        <"
  },
  {
    "path": "konf-xml/src/testFixtures/kotlin/com/uchuhimo/konf/source/XmlTestUtils.kt",
    "chars": 874,
    "preview": "/*\n * Copyright 2017-2021 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
  },
  {
    "path": "konf-yaml/build.gradle.kts",
    "chars": 168,
    "preview": "dependencies {\n    api(project(\":konf-core\"))\n    implementation(\"org.yaml\", \"snakeyaml\", Versions.yaml)\n\n    testImplem"
  }
]

// ... and 13 more files (download for full content)

About this extraction

This page contains the full source code of the uchuhimo/konf GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 213 files (832.2 KB), approximately 199.6k tokens, and a symbol index with 29 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!