Package net.bytebuddy.dynamic.scaffold
Class MethodGraph.Compiler.Default<T>
java.lang.Object
net.bytebuddy.dynamic.scaffold.MethodGraph.Compiler.AbstractBase
net.bytebuddy.dynamic.scaffold.MethodGraph.Compiler.Default<T>
- Type Parameters:
T
- The type of the harmonizer token to be used for linking methods of different types.
- All Implemented Interfaces:
MethodGraph.Compiler
- Enclosing interface:
MethodGraph.Compiler
@Enhance
public static class MethodGraph.Compiler.Default<T>
extends MethodGraph.Compiler.AbstractBase
A default implementation of a method graph.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A harmonizer is responsible for creating a token that identifies a method's relevant attributes for considering two methods of being equal or not.protected static class
A key represents a collection of methods within a method graph to later yield a node representing a collection of methods, i.e.static interface
Implementations are responsible for identifying a representative method for aMethodGraph.Node
between several ambiguously resolved methods.Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.MethodGraph.Compiler
MethodGraph.Compiler.AbstractBase, MethodGraph.Compiler.Default<T>, MethodGraph.Compiler.ForDeclaredMethods
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MethodGraph.Compiler.Default.Harmonizer
<T> The harmonizer to be used.private final ElementMatcher
<? super MethodDescription> A matcher to filter methods from the graph.private final MethodGraph.Compiler.Default.Merger
The merger to be used.private final TypeDescription.Generic.Visitor
<? extends TypeDescription.Generic> A visitor to apply to all type descriptions before analyzing their methods or resolving super types.Fields inherited from interface net.bytebuddy.dynamic.scaffold.MethodGraph.Compiler
DEFAULT
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default
(MethodGraph.Compiler.Default.Harmonizer<T> harmonizer, MethodGraph.Compiler.Default.Merger merger, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Creates a new default method graph compiler.Default
(MethodGraph.Compiler.Default.Harmonizer<T> harmonizer, MethodGraph.Compiler.Default.Merger merger, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor, ElementMatcher<? super MethodDescription> matcher) Creates a new default method graph compiler. -
Method Summary
Modifier and TypeMethodDescriptionprotected MethodGraph.Compiler.Default.Key.Store
<T> analyze
(TypeDefinition typeDefinition, TypeDefinition key, Map<TypeDefinition, MethodGraph.Compiler.Default.Key.Store<T>> snapshots, ElementMatcher<? super MethodDescription> relevanceMatcher) Analyzes the given type description without checking if the end of the type hierarchy was reached.protected MethodGraph.Compiler.Default.Key.Store
<T> analyzeNullable
(TypeDescription.Generic typeDescription, Map<TypeDefinition, MethodGraph.Compiler.Default.Key.Store<T>> snapshots, ElementMatcher<? super MethodDescription> relevanceMatcher) Analyzes the given type description.compile
(TypeDefinition typeDefinition, TypeDescription viewPoint) Compiles the given type into a method graph.protected MethodGraph.Compiler.Default.Key.Store
<T> doAnalyze
(TypeDefinition typeDefinition, Map<TypeDefinition, MethodGraph.Compiler.Default.Key.Store<T>> snapshots, ElementMatcher<? super MethodDescription> relevanceMatcher) Analyzes the given type description without checking if it is already presented in the key store.static MethodGraph.Compiler
Creates a default compiler for a method hierarchy following the rules of the Java programming language.static MethodGraph.Compiler
Creates a default compiler for a method hierarchy following the rules of the Java virtual machine.static <S> MethodGraph.Compiler
of
(MethodGraph.Compiler.Default.Harmonizer<S> harmonizer, MethodGraph.Compiler.Default.Merger merger) Creates a default compiler using the given harmonizer and merger.static <S> MethodGraph.Compiler
of
(MethodGraph.Compiler.Default.Harmonizer<S> harmonizer, MethodGraph.Compiler.Default.Merger merger, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Creates a default compiler using the given harmonizer and merger.static <S> MethodGraph.Compiler
of
(MethodGraph.Compiler.Default.Harmonizer<S> harmonizer, MethodGraph.Compiler.Default.Merger merger, ElementMatcher<? super MethodDescription> matcher) Creates a default compiler using the given harmonizer and merger.Methods inherited from class net.bytebuddy.dynamic.scaffold.MethodGraph.Compiler.AbstractBase
compile, compile, compile
-
Field Details
-
harmonizer
The harmonizer to be used. -
merger
The merger to be used. -
visitor
A visitor to apply to all type descriptions before analyzing their methods or resolving super types. -
matcher
A matcher to filter methods from the graph.
-
-
Constructor Details
-
Default
protected Default(MethodGraph.Compiler.Default.Harmonizer<T> harmonizer, MethodGraph.Compiler.Default.Merger merger, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Creates a new default method graph compiler.- Parameters:
harmonizer
- The harmonizer to be used.merger
- The merger to be used.visitor
- A visitor to apply to all type descriptions before analyzing their methods or resolving super types.
-
Default
public Default(MethodGraph.Compiler.Default.Harmonizer<T> harmonizer, MethodGraph.Compiler.Default.Merger merger, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor, ElementMatcher<? super MethodDescription> matcher) Creates a new default method graph compiler.- Parameters:
harmonizer
- The harmonizer to be used.merger
- The merger to be used.visitor
- A visitor to apply to all type descriptions before analyzing their methods or resolving super types.matcher
- A matcher to filter methods from the graph.
-
-
Method Details
-
of
public static <S> MethodGraph.Compiler of(MethodGraph.Compiler.Default.Harmonizer<S> harmonizer, MethodGraph.Compiler.Default.Merger merger) Creates a default compiler using the given harmonizer and merger. All raw types are reified before analyzing their properties.- Type Parameters:
S
- The type of the harmonizer token.- Parameters:
harmonizer
- The harmonizer to be used for creating tokens that uniquely identify a method hierarchy.merger
- The merger to be used for identifying a method to represent an ambiguous method resolution.- Returns:
- A default compiler for the given harmonizer and merger.
-
of
public static <S> MethodGraph.Compiler of(MethodGraph.Compiler.Default.Harmonizer<S> harmonizer, MethodGraph.Compiler.Default.Merger merger, ElementMatcher<? super MethodDescription> matcher) Creates a default compiler using the given harmonizer and merger. All raw types are reified before analyzing their properties.- Type Parameters:
S
- The type of the harmonizer token.- Parameters:
harmonizer
- The harmonizer to be used for creating tokens that uniquely identify a method hierarchy.merger
- The merger to be used for identifying a method to represent an ambiguous method resolution.matcher
- A matcher to filter methods from the graph.- Returns:
- A default compiler for the given harmonizer and merger.
-
of
public static <S> MethodGraph.Compiler of(MethodGraph.Compiler.Default.Harmonizer<S> harmonizer, MethodGraph.Compiler.Default.Merger merger, TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) Creates a default compiler using the given harmonizer and merger.- Type Parameters:
S
- The type of the harmonizer token.- Parameters:
harmonizer
- The harmonizer to be used for creating tokens that uniquely identify a method hierarchy.merger
- The merger to be used for identifying a method to represent an ambiguous method resolution.visitor
- A visitor to apply to all type descriptions before analyzing their methods or resolving super types.- Returns:
- A default compiler for the given harmonizer and merger.
-
forJavaHierarchy
Creates a default compiler for a method hierarchy following the rules of the Java programming language. According to these rules, two methods of the same name are only different if their parameter types represent different raw types. The return type is not considered as a part of the signature.
Ambiguous methods are merged by considering the method that was discovered first.
- Returns:
- A compiler for resolving a method hierarchy following the rules of the Java programming language.
-
forJVMHierarchy
Creates a default compiler for a method hierarchy following the rules of the Java virtual machine. According to these rules, two methods of the same name are different if their parameter types and return types represent different type erasures.
Ambiguous methods are merged by considering the method that was discovered first.
- Returns:
- A compiler for resolving a method hierarchy following the rules of the Java programming language.
-
compile
Compiles the given type into a method graph.- Parameters:
typeDefinition
- The type to be compiled.viewPoint
- The view point that determines the method's visibility.- Returns:
- A linked method graph representing the given type.
-
analyze
protected MethodGraph.Compiler.Default.Key.Store<T> analyze(TypeDefinition typeDefinition, TypeDefinition key, Map<TypeDefinition, MethodGraph.Compiler.Default.Key.Store<T>> snapshots, ElementMatcher<? super MethodDescription> relevanceMatcher) Analyzes the given type description without checking if the end of the type hierarchy was reached.- Parameters:
typeDefinition
- The type to analyze.key
- The type in its original form before applying the visitor.snapshots
- A map containing snapshots of key stores for previously analyzed types.relevanceMatcher
- A matcher for filtering methods that should be included in the graph.- Returns:
- A key store describing the provided type.
-
analyzeNullable
protected MethodGraph.Compiler.Default.Key.Store<T> analyzeNullable(@MaybeNull TypeDescription.Generic typeDescription, Map<TypeDefinition, MethodGraph.Compiler.Default.Key.Store<T>> snapshots, ElementMatcher<? super MethodDescription> relevanceMatcher) Analyzes the given type description.- Parameters:
typeDescription
- The type to analyze.snapshots
- A map containing snapshots of key stores for previously analyzed types.relevanceMatcher
- A matcher for filtering methods that should be included in the graph.- Returns:
- A key store describing the provided type.
-
doAnalyze
protected MethodGraph.Compiler.Default.Key.Store<T> doAnalyze(TypeDefinition typeDefinition, Map<TypeDefinition, MethodGraph.Compiler.Default.Key.Store<T>> snapshots, ElementMatcher<? super MethodDescription> relevanceMatcher) Analyzes the given type description without checking if it is already presented in the key store.- Parameters:
typeDefinition
- The type to analyze.snapshots
- A map containing snapshots of key stores for previously analyzed types.relevanceMatcher
- A matcher for filtering methods that should be included in the graph.- Returns:
- A key store describing the provided type.
-