Groovy 2.2.0

groovy.lang
[Java] Annotation Type Singleton

java.lang.Object
  groovy.lang.Singleton

@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE})
@GroovyASTTransformationClass("org.codehaus.groovy.transform.SingletonASTTransformation")
public @interface Singleton

Class annotation to make class singleton. Singleton can be initialized in static initialization of the class or lazily (on first access) To make singleton lazy it is enough to use @Singleton(lazy=true) Lazy singletons implemented with double check locking and volatile field

Authors:
Alex Tkachman


 
Optional Element Summary
boolean lazy

@default false

Returns:
if this singleton should be lazy

java.lang.String property

@default "instance"

Returns:
the singleton property name

 
Method Summary
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Element Detail

lazy

public boolean lazy
@default false
Returns:
if this singleton should be lazy


property

public String property
@default "instance"
Returns:
the singleton property name


 

Copyright © 2003-2013 The Codehaus. All rights reserved.