Class AnnotationValue.ForConstant<U>
- java.lang.Object
-
- net.bytebuddy.description.annotation.AnnotationValue.AbstractBase<U,U>
-
- net.bytebuddy.description.annotation.AnnotationValue.ForConstant<U>
-
- Type Parameters:
U
- The type where primitive values are represented by their boxed type.
- All Implemented Interfaces:
AnnotationValue<U,U>
- Enclosing interface:
- AnnotationValue<T,S>
public static class AnnotationValue.ForConstant<U> extends AnnotationValue.AbstractBase<U,U>
Represents a primitive value, aString
or an array of the latter types.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AnnotationValue.ForConstant.Loaded<V>
Represents a trivial loaded value.protected static interface
AnnotationValue.ForConstant.PropertyDelegate
A property delegate for a constant annotation value.-
Nested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationValue
AnnotationValue.AbstractBase<U,V>, AnnotationValue.ForAnnotationDescription<U extends java.lang.annotation.Annotation>, AnnotationValue.ForConstant<U>, AnnotationValue.ForDescriptionArray<U,V>, AnnotationValue.ForEnumerationDescription<U extends java.lang.Enum<U>>, AnnotationValue.ForIncompatibleType<U,V>, AnnotationValue.ForMismatchedType<U,V>, AnnotationValue.ForMissingType<U,V>, AnnotationValue.ForMissingValue<U,V>, AnnotationValue.ForTypeDescription<U extends java.lang.Class<U>>, AnnotationValue.RenderingDispatcher, AnnotationValue.State
-
-
Field Summary
Fields Modifier and Type Field Description private AnnotationValue.ForConstant.PropertyDelegate
propertyDelegate
The property delegate for the value's type.private U
value
The represented value.-
Fields inherited from interface net.bytebuddy.description.annotation.AnnotationValue
UNDEFINED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForConstant(U value, AnnotationValue.ForConstant.PropertyDelegate propertyDelegate)
Creates a new constant annotation value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
AnnotationValue<U,U>
filter(MethodDescription.InDefinedShape property, TypeDefinition typeDefinition)
Filters this annotation value as a valid value of the provided property.AnnotationValue.State
getState()
Returns the state of the represented annotation value.int
hashCode()
AnnotationValue.Loaded<U>
load(java.lang.ClassLoader classLoader)
Returns the loaded value of this annotation.static AnnotationValue<java.lang.Boolean,java.lang.Boolean>
of(boolean value)
Creates an annotation value for aboolean
value.static AnnotationValue<boolean[],boolean[]>
of(boolean... value)
Creates an annotation value for aboolean[]
value.static AnnotationValue<java.lang.Byte,java.lang.Byte>
of(byte value)
Creates an annotation value for abyte
value.static AnnotationValue<byte[],byte[]>
of(byte... value)
Creates an annotation value for abyte[]
value.static AnnotationValue<java.lang.Character,java.lang.Character>
of(char value)
Creates an annotation value for achar
value.static AnnotationValue<char[],char[]>
of(char... value)
Creates an annotation value for achar[]
value.static AnnotationValue<java.lang.Double,java.lang.Double>
of(double value)
Creates an annotation value for adouble
value.static AnnotationValue<double[],double[]>
of(double... value)
Creates an annotation value for adouble[]
value.static AnnotationValue<java.lang.Float,java.lang.Float>
of(float value)
Creates an annotation value for afloat
value.static AnnotationValue<float[],float[]>
of(float... value)
Creates an annotation value for afloat[]
value.static AnnotationValue<java.lang.Integer,java.lang.Integer>
of(int value)
Creates an annotation value for aint
value.static AnnotationValue<int[],int[]>
of(int... value)
Creates an annotation value for aint[]
value.static AnnotationValue<java.lang.Long,java.lang.Long>
of(long value)
Creates an annotation value for along
value.static AnnotationValue<long[],long[]>
of(long... value)
Creates an annotation value for along[]
value.static AnnotationValue<java.lang.Short,java.lang.Short>
of(short value)
Creates an annotation value for ashort
value.static AnnotationValue<short[],short[]>
of(short... value)
Creates an annotation value for ashort[]
value.static AnnotationValue<?,?>
of(java.lang.Object value)
Creates an annotation value for any constant value, i.e any primitive (wrapper) type, any primitive array type or anyString
value or array.static AnnotationValue<java.lang.String,java.lang.String>
of(java.lang.String value)
Creates an annotation value for aString
value.static AnnotationValue<java.lang.String[],java.lang.String[]>
of(java.lang.String... value)
Creates an annotation value for aString[]
value.U
resolve()
Resolves the unloaded value of this annotation.java.lang.String
toString()
-
Methods inherited from class net.bytebuddy.description.annotation.AnnotationValue.AbstractBase
filter, resolve
-
-
-
-
Field Detail
-
value
private final U value
The represented value.
-
propertyDelegate
private final AnnotationValue.ForConstant.PropertyDelegate propertyDelegate
The property delegate for the value's type.
-
-
Constructor Detail
-
ForConstant
protected ForConstant(U value, AnnotationValue.ForConstant.PropertyDelegate propertyDelegate)
Creates a new constant annotation value.- Parameters:
value
- The represented value.propertyDelegate
- The property delegate for the value's type.
-
-
Method Detail
-
of
public static AnnotationValue<java.lang.Boolean,java.lang.Boolean> of(boolean value)
Creates an annotation value for aboolean
value.- Parameters:
value
- Theboolean
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Byte,java.lang.Byte> of(byte value)
Creates an annotation value for abyte
value.- Parameters:
value
- Thebyte
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Short,java.lang.Short> of(short value)
Creates an annotation value for ashort
value.- Parameters:
value
- Theshort
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Character,java.lang.Character> of(char value)
Creates an annotation value for achar
value.- Parameters:
value
- Thechar
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Integer,java.lang.Integer> of(int value)
Creates an annotation value for aint
value.- Parameters:
value
- Theint
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Long,java.lang.Long> of(long value)
Creates an annotation value for along
value.- Parameters:
value
- Thelong
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Float,java.lang.Float> of(float value)
Creates an annotation value for afloat
value.- Parameters:
value
- Thefloat
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.Double,java.lang.Double> of(double value)
Creates an annotation value for adouble
value.- Parameters:
value
- Thedouble
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.String,java.lang.String> of(java.lang.String value)
Creates an annotation value for aString
value.- Parameters:
value
- TheString
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<boolean[],boolean[]> of(boolean... value)
Creates an annotation value for aboolean[]
value.- Parameters:
value
- Theboolean[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<byte[],byte[]> of(byte... value)
Creates an annotation value for abyte[]
value.- Parameters:
value
- Thebyte[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<short[],short[]> of(short... value)
Creates an annotation value for ashort[]
value.- Parameters:
value
- Theshort[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<char[],char[]> of(char... value)
Creates an annotation value for achar[]
value.- Parameters:
value
- Thechar[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<int[],int[]> of(int... value)
Creates an annotation value for aint[]
value.- Parameters:
value
- Theint[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<long[],long[]> of(long... value)
Creates an annotation value for along[]
value.- Parameters:
value
- Thelong[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<float[],float[]> of(float... value)
Creates an annotation value for afloat[]
value.- Parameters:
value
- Thefloat[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<double[],double[]> of(double... value)
Creates an annotation value for adouble[]
value.- Parameters:
value
- Thedouble[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<java.lang.String[],java.lang.String[]> of(java.lang.String... value)
Creates an annotation value for aString[]
value.- Parameters:
value
- TheString[]
value to represent.- Returns:
- An appropriate annotation value.
-
of
public static AnnotationValue<?,?> of(java.lang.Object value)
Creates an annotation value for any constant value, i.e any primitive (wrapper) type, any primitive array type or anyString
value or array. If no constant annotation type is provided, a runtime exception is thrown.- Parameters:
value
- The value to represent.- Returns:
- An appropriate annotation value.
-
getState
public AnnotationValue.State getState()
Returns the state of the represented annotation value.- Returns:
- The state represented by this instance.
-
filter
public AnnotationValue<U,U> filter(MethodDescription.InDefinedShape property, TypeDefinition typeDefinition)
Filters this annotation value as a valid value of the provided property.- Parameters:
property
- The property to filter against.typeDefinition
- The expected type.- Returns:
- This annotation value or a new annotation value that describes why this value is not a valid value for the supplied property.
-
resolve
public U resolve()
Resolves the unloaded value of this annotation. The return value of this method is not defined if this annotation value is invalid.- Returns:
- The unloaded value of this annotation.
-
load
public AnnotationValue.Loaded<U> load(java.lang.ClassLoader classLoader)
Returns the loaded value of this annotation.- Parameters:
classLoader
- The class loader for loading this value.- Returns:
- The loaded value of this annotation.
-
hashCode
@Enhance("hashCode") public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-