@Target(value=METHOD) @Retention(value=CLASS) public @interface GlideOption
GlideExtension
annotated classes that extend
RequestOptions
.
All annotated methods will be added to a single
RequestOptions
implementation generated per application.
Overlapping method names in different extensions may cause errors at compile time.
Static equivalents of annotated methods will also be generated.
Methods with this annotation will only be found if they belong to classes annotated with
GlideExtension
.
Modifier and Type | Fields and Description |
---|---|
static int |
OVERRIDE_EXTEND
Expects to call super and then add additional functionality to an overridden method.
|
static int |
OVERRIDE_NONE
Does not intend to override a method in a super class.
|
static int |
OVERRIDE_REPLACE
Expects to not call super and replace an overridden method.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
memoizeStaticMethod
true to indicate that it's safe to statically memoize the result of this method using
RequestOptions.autoClone() . |
int |
override
Determines how and whether a generated method should extend a method from it's parent.
|
boolean |
skipStaticMethod
true to prevent a static builder method from being generated. |
String |
staticMethodName
Sets the name for the generated static version of this method.
|
public static final int OVERRIDE_NONE
public static final int OVERRIDE_EXTEND
public static final int OVERRIDE_REPLACE
public abstract int override
Must be one of OVERRIDE_NONE
, OVERRIDE_EXTEND
, OVERRIDE_REPLACE
.
The extended method is determined by String and argument matching against methods in the
extended class. If OVERRIDE_NONE
is used and the method and arguments match a method
in the extended class, a compile time error will result. Similarly if any other override type
is used and no method/arguments in the extended class match, a compile time error will result.
public abstract String staticMethodName
If this value is not set, the static method name is just the original method name with "Of" appended.
public abstract boolean memoizeStaticMethod
true
to indicate that it's safe to statically memoize the result of this method using
RequestOptions.autoClone()
.
This method should only be used for no-arg methods where there's only a single possible value.
Memoization can save object allocations for frequently used options.
public abstract boolean skipStaticMethod
true
to prevent a static builder method from being generated.
By default static methods are generated for all methods annotated with
GlideOption
. These static factory methods allow for a cleaner API when used
with RequestBuilder.apply(com.bumptech.glide.request.RequestOptions)
. The static factory method by default
simply creates a new RequestOptions
object, calls the
instance version of the method on it and returns it. For example:
public static GlideOptions noAnimation() {
return new GlideOptions().dontAnimate();
}
memoizeStaticMethod()
,
staticMethodName()