-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classGeneric.BoundTypeRepresents the bound type of this generic.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Genericadd(Type upperBound)Adds an upper bound to this generic.TypeasType()Parses aTypefrom the lower bound of this generic.Generic.BoundTypegetBoundType()Returns the current bound type of this generic.Optional<String>getLowerBound()Returns the lower bound of this generic if it exists.List<Type>getUpperBounds()Returns a modifiable list of all upper bounds to this generic.static Genericof()Creates a new instance implementing this interface by using the default implementation.static Genericof(Type upperBound)Creates a new instance implementing this interface by using the default implementation.static Genericof(String lowerBound)Creates a new instance implementing this interface by using the default implementation.GenericsetBoundType(Generic.BoundType type)Sets the bound type of this generic.GenericsetLowerBound(String lowerBound)Sets the lower bound of this generic.
-
-
-
Method Detail
-
setLowerBound
Generic setLowerBound(String lowerBound)
Sets the lower bound of this generic.In the following example,
Tis the lower bound:T extends List<String>If the lower bound is anonymous, the special type
DefaultType.WILDCARDcan be used.- Parameters:
lowerBound- the new lower bound- Returns:
- a reference to this model
-
getLowerBound
Optional<String> getLowerBound()
Returns the lower bound of this generic if it exists.In the following example,
Tis the lower bound:T extends List<String>If the lower bound is anonymous, the special type
DefaultType.WILDCARDcan be used.- Returns:
- the lower bound if such exists
-
add
default Generic add(Type upperBound)
Adds an upper bound to this generic.In the following example,
List<String>andSerializableare upper bounds:T extends List<String>&Serializable- Parameters:
upperBound- the new upper bound- Returns:
- a reference to this model
-
getUpperBounds
List<Type> getUpperBounds()
Returns a modifiable list of all upper bounds to this generic.In the following example,
List<String>andSerializableare upper bounds:T extends List<String>&Serializable- Returns:
- the list of upper bounds
-
setBoundType
Generic setBoundType(Generic.BoundType type)
Sets the bound type of this generic. If the generic is bound using theextendskeyword it means that the lower bound is a descendant of the upper bound. If thesuperkeyword is used it means that the lower bound is an ancestor of the upper bound. Both bound types also accept identical types.Valid input:
- Parameters:
type- the new bound type- Returns:
- a reference to this model
-
getBoundType
Generic.BoundType getBoundType()
Returns the current bound type of this generic. Note that the bound type is irrelevant when there are no upper bounds!- Returns:
- the bound type
-
asType
Type asType()
Parses aTypefrom the lower bound of this generic. This can be used to reference the generic variable from other contexts.- Returns:
- a
Typerepresenting this generic variable
-
of
static Generic of()
Creates a new instance implementing this interface by using the default implementation.- Returns:
- the new instance
-
of
static Generic of(String lowerBound)
Creates a new instance implementing this interface by using the default implementation.- Parameters:
lowerBound- the lower bound, example:"T"- Returns:
- the new instance
-
-