@Property proposal

key

symbol

meaning

(red star)

private

(star)

protected

(green star)

public

(blue star)

final

Current

code

field

getter

setter

def x

(green star)

 

 

final x

(green star)(blue star)

 

 

public x

(green star)

 

 

protected x

(star)

 

 

private x

(red star)

 

 

public final x

(green star)(blue star)

 

 

@Property x

(red star)

(green star)

(green star)

other permutations?

 

 

 

Proposed

code

field

getter

setter

note

def x

(red star)

(green star)

(green star)

 

final x

(red star)(blue star)

(green star)

 

the field doesn't need to be final IMHO (dk) My view is that the field should be final(tug)

public x

(green star)

 

 

 

protected x

(star)

 

 

 

private x

(red star)

 

 

 

public final x

(green star) (blue star)


 

a public final field like in Java

@Property x

(red star)

(green star)

(green star)

 if it's still supported (MrG) My proposal is to remove it (tug)

other permutations?

 

 

 

 what happens with static? (MrG) Static behave exactly the same(tug)

Migration notes

Basically if you have @Property at the moment then you will need to remove it. If the declaration is typed then you are done. If it's not then you need to replace the @Property with def.

If you have field declarations which have default visibility (def x or String y, for example) then these will become properties. If you are using them from Groovy then you won't *have* to do anything. If they are accesses from Java then you will need to make them fields again. If you want them to still be fields you need to put public in front of the declaration.

Fields which are declared public, protected or private can be left alone.

If you would like to prepare for this then you can start to declare visibility for all your fields. The when we remove @property you can run a sed script which removes all the changes @Property to def and then compile your source. The compiler will than complain about the use of def and a type and you will need to remove all these defs.