Rahul Sharma
Rahul Sharma

Reputation: 5834

Spring YAML how a property can refer another property of object type

I have a YAML file where a property has reference of another property.

E.g.:

sidh:
    sftp:
        profile1:
            host: xxxx.com
            local:
                directory:
                    download: localDownload
            user: abctest
            password: Team334


    sf:
      mf:
        clientId: 2324
        clientSecret: sd23
        refreshToken: 23sds
        url: test.salesforce.com

    feeds:
        mf_company:
          processor: com.xxxx.ABC
          pattern: ABC_*
          sf: mf   # How to reference sidh.sf.mf
          sft: profile1 # How to reference sidh.sftp.profile1 

I am using Spring and I couldn't find any out of the box library/examples about how a property (sidh.feeds.mf_company.sf or sft) can refer another object type property (sidh.sf.mf, sidh.sftp.profile1). I can write custom code to represent this YAML and create references.

My question is: are there any out of the box library available to handle this scenario?

Upvotes: 3

Views: 5024

Answers (1)

Stempler
Stempler

Reputation: 2699

There is no out of the box solution for your scenario. YAML only supports a simple key-value dictionary without any object implementation.

If you wish to wish to use your configuration as an object, you need to create your own implementation like you said in your code.

Upvotes: 3

Related Questions