Coder Social home page Coder Social logo

Support for nullable about buildkonfig HOT 9 CLOSED

yshrsmz avatar yshrsmz commented on May 30, 2024
Support for nullable

from buildkonfig.

Comments (9)

MikolajKakol avatar MikolajKakol commented on May 30, 2024 1

I'm using kts. The current method is buildConfigField I was thinking about adding simple buildConfigNullableField.

However, it's a bit more wast problem. Right now we are constrained by Type enum in FieldSpec. I think it maybe could be a sealed class and we should allow a user to enter any primitive supported by the language.

I could help with two PR, one for simple nullable and one that would try to tackle that second matter. It could also provide some type safety before compilation.

    fun <T: Any?> buildConfigField(
        name: String,
        value: T
    ) 

would be a perfect method signature if possible.

from buildkonfig.

yshrsmz avatar yshrsmz commented on May 30, 2024

Could you elaborate on this?
What is the usecase of the null value as a constant?

from buildkonfig.

MikolajKakol avatar MikolajKakol commented on May 30, 2024

I'm using Gradle properties to read some constants. I'd like to model absence of them.

What I do is defining in local.properties proxy address for app and if it's not defined like on CI it's not installed on http client.

from buildkonfig.

yshrsmz avatar yshrsmz commented on May 30, 2024

Thanks for the detail!

Do you really need to distinguish null and empty string?
If not, I'd recommend you to use an empty string as an empty value, rather than using null.

from buildkonfig.

kuuuurt avatar kuuuurt commented on May 30, 2024

What about exposing a getHasKey method?

from buildkonfig.

MikolajKakol avatar MikolajKakol commented on May 30, 2024

With String it's kind of okay... however I also have some int's there and modeling it as -1/0 is just, you know :)

I feel that it would be a good addition to support nullable types since it's very deep in Kotlin roots.

from buildkonfig.

yshrsmz avatar yshrsmz commented on May 30, 2024

That sounds reasonable.
How would you like to configure nullable value? Any idea?

from buildkonfig.

yshrsmz avatar yshrsmz commented on May 30, 2024

buildConfigNullableField

looks nice 👍

Regarding the second suggestion, I'm not sure if it works well but let's see how it goes ;)

from buildkonfig.

yshrsmz avatar yshrsmz commented on May 30, 2024

I've just released 0.5.0 with changes from #21

from buildkonfig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.