public class Signatures
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Signatures.Rover
Helper class to track an index in a string.
|
Constructor and Description |
---|
Signatures() |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
assign(java.util.Map<java.lang.String,java.lang.String> map,
java.lang.String name)
Handles the assignment of type variables to index names so that we have a
normalized name for each type var.
|
private void |
body(java.lang.StringBuilder sb,
java.util.Map<java.lang.String,java.lang.String> map,
Signatures.Rover rover)
Because classes can be nested the body handles the part that can be
nested, the reference handles the enclosing L ...
|
private java.lang.Object |
call(java.lang.Object gd,
java.lang.String string) |
private void |
declaration(java.lang.StringBuilder sb,
java.lang.Object gd)
Classes, Methods, or Constructors can have a declaration that provides
nested a scope for type variables.
|
private void |
declare(java.lang.StringBuilder sb,
java.util.Map<java.lang.String,java.lang.String> map,
Signatures.Rover rover)
Handle the declaration part.
|
java.lang.String |
getSignature(java.lang.Class<?> c)
Calculate the generic signature of a Class.
|
java.lang.String |
getSignature(java.lang.reflect.Constructor<?> c)
Calculate the generic signature of a Constructor.
|
java.lang.String |
getSignature(java.lang.reflect.Field f)
Calculate the generic signature of a Field.
|
java.lang.String |
getSignature(java.lang.reflect.Method m)
Calculate the generic signature of a Method.
|
java.lang.String |
getSignature(java.lang.Object c)
Calculate the generic signature of a Class,Method,Field, or Constructor.
|
boolean |
hasGenerics()
Check if the environment has generics, i.e.
|
private boolean |
isInstance(java.lang.Class<?> type,
java.lang.String string) |
private boolean |
isInterface(java.lang.Object type)
Verify that the type is an interface.
|
java.lang.String |
normalize(java.lang.String signature)
Normalize a signature to make sure the name of the variables are always
the same.
|
private void |
parameterizedType(java.lang.StringBuilder sb,
java.lang.Object pt)
Creates the signature for a Parameterized Type.
|
private char |
primitive(java.lang.Class<?> type)
Handle primitives, these need to be translated to a single char.
|
private void |
reference(java.lang.StringBuilder sb,
java.util.Map<java.lang.String,java.lang.String> map,
Signatures.Rover rover,
boolean primitivesAllowed)
The heart of the routine.
|
private void |
reference(java.lang.StringBuilder sb,
java.lang.Object t)
This is the heart of the signature builder.
|
public boolean hasGenerics() throws java.lang.Exception
java.lang.Exception
public java.lang.String getSignature(java.lang.Object c) throws java.lang.Exception
java.lang.Exception
public java.lang.String getSignature(java.lang.Class<?> c) throws java.lang.Exception
class ::= declaration? reference reference*
java.lang.Exception
public java.lang.String getSignature(java.lang.reflect.Method m) throws java.lang.Exception
method ::= declaration? '(' reference* ')' reference
java.lang.Exception
public java.lang.String getSignature(java.lang.reflect.Constructor<?> c) throws java.lang.Exception
constructor ::= declaration? '(' reference* ')V'
c
- java.lang.Exception
public java.lang.String getSignature(java.lang.reflect.Field f) throws java.lang.Exception
constructor ::= reference
java.lang.Exception
private void declaration(java.lang.StringBuilder sb, java.lang.Object gd) throws java.lang.Exception
declarations ::= '<' declaration ( ',' declaration )* '>' declaration ::= identifier ':' declare declare ::= types | variable types ::= ( 'L' class ';' )? ( ':' 'L' interface ';' )* variable ::= 'T' id ';'
sb
- gd
- java.lang.Exception
private boolean isInterface(java.lang.Object type) throws java.lang.Exception
type
- the type to check.java.lang.Exception
private void reference(java.lang.StringBuilder sb, java.lang.Object t) throws java.lang.Exception
reference ::= array | class | primitive | variable array ::= '[' reference class ::= 'L' body ( '.' body )* ';' body ::= id ( '<' ( wildcard | reference )* '>' )? variable ::= 'T' id ';' primitive ::= PRIMITIVE
sb
- t
- java.lang.Exception
private void parameterizedType(java.lang.StringBuilder sb, java.lang.Object pt) throws java.lang.Exception
sb
- pt
- java.lang.Exception
private char primitive(java.lang.Class<?> type)
type
- the primitive classpublic java.lang.String normalize(java.lang.String signature)
private void reference(java.lang.StringBuilder sb, java.util.Map<java.lang.String,java.lang.String> map, Signatures.Rover rover, boolean primitivesAllowed)
sb
- map
- rover
- primitivesAllowed
- private void body(java.lang.StringBuilder sb, java.util.Map<java.lang.String,java.lang.String> map, Signatures.Rover rover)
sb
- map
- rover
- private void declare(java.lang.StringBuilder sb, java.util.Map<java.lang.String,java.lang.String> map, Signatures.Rover rover)
sb
- map
- rover
- private java.lang.String assign(java.util.Map<java.lang.String,java.lang.String> map, java.lang.String name)
map
- the map with variables.name
- The name of the variableprivate boolean isInstance(java.lang.Class<?> type, java.lang.String string)
private java.lang.Object call(java.lang.Object gd, java.lang.String string) throws java.lang.Exception
java.lang.Exception