Lombok: @Singleton

Created on 17 Feb 2017  路  2Comments  路  Source: projectlombok/lombok

This feature would be very handy.

Most helpful comment

The correct way to declare a singleton is using an enum:

From Effective Java (2nd Edition):

// Enum singleton - the preferred approach
public enum Elvis {
    INSTANCE;

    public void leaveTheBuilding() { ... }
}

All 2 comments

The correct way to declare a singleton is using an enum:

From Effective Java (2nd Edition):

// Enum singleton - the preferred approach
public enum Elvis {
    INSTANCE;

    public void leaveTheBuilding() { ... }
}

https://github.com/peichhorn/lombok-pg/wiki/%40Singleton
un-recommend: no update with long time ago

Was this page helpful?
0 / 5 - 0 ratings