Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10655

Add extension method for coercing AtomicBoolean to boolean value

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-1
    • groovy-jdk
    • None

    Description

      AtomicInteger and the other number atomics extend Number and so they support conversion to boolean through extension method asBoolean(Number). However, AtomicBoolean requires a separate extension method for this.

       // you can omit ".asBoolean()"
       assert  new AtomicBoolean(true).asBoolean()
       assert !new AtomicBoolean(false).asBoolean()
       assert !new AtomicBoolean(true).tap{set(false)}
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: