You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "David Kron (JIRA)" <ji...@apache.org> on 2017/09/15 23:42:00 UTC

[jira] [Updated] (GROOVY-8320) Support property references in addition to the method references from Java 8

     [ https://issues.apache.org/jira/browse/GROOVY-8320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Kron updated GROOVY-8320:
-------------------------------
    Description: 
It would be great if the method reference syntax from Java (Class::method or obj::method) could also be extended to support Groovy properties. The new parser currently already parses the syntax without error, but it gets treated as a method reference.

Potential example usage:
{code:java}
class Test {
    String property
}

def test = new Test(property: 'Hello')
def boundReference = test::property
def unboundReference = Test::property

// getting/setting property using bound reference
println boundReference.get()
boundReference.set('Hello to you!')

// getting/setting property using unbound reference
println unboundReference.get(test)
unboundReference.set(test, 'Hello to you!')

// retrieving meta information
println boundReference.type
println boundReference.name
println boundReference.target

{code}


  was:
It would be great if the method reference syntax from Java (Class::method or obj::method) could also be extended to support Groovy properties. The new parser currently already parses the syntax without error, but it gets treated as a method reference.

Potential example usage:
{code:java}
class Test {
    String property
}

def test = new Test(property: 'Hello')
def boundReference = test::property
def unboundReference = Test::property

// getting/setting property using bound reference
println boundReference.get()
boundReference.set('Hello to you!')

// getting/setting property using unbound reference
println unboundReference.get(test)
unboundReference.set(test, 'Hello to you!')

{code}



> Support property references in addition to the method references from Java 8
> ----------------------------------------------------------------------------
>
>                 Key: GROOVY-8320
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8320
>             Project: Groovy
>          Issue Type: Improvement
>          Components: parser-antlr
>    Affects Versions: 2.6.0-alpha-1
>            Reporter: David Kron
>            Priority: Minor
>
> It would be great if the method reference syntax from Java (Class::method or obj::method) could also be extended to support Groovy properties. The new parser currently already parses the syntax without error, but it gets treated as a method reference.
> Potential example usage:
> {code:java}
> class Test {
>     String property
> }
> def test = new Test(property: 'Hello')
> def boundReference = test::property
> def unboundReference = Test::property
> // getting/setting property using bound reference
> println boundReference.get()
> boundReference.set('Hello to you!')
> // getting/setting property using unbound reference
> println unboundReference.get(test)
> unboundReference.set(test, 'Hello to you!')
> // retrieving meta information
> println boundReference.type
> println boundReference.name
> println boundReference.target
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)