Skip to content

Commit

Permalink
Added further documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Jan 5, 2016
1 parent d6e9aa1 commit c03c27e
Show file tree
Hide file tree
Showing 37 changed files with 1,227 additions and 118 deletions.
4 changes: 2 additions & 2 deletions byte-buddy-dep/src/main/java/net/bytebuddy/ByteBuddy.java
Expand Up @@ -520,7 +520,7 @@ public <T> DynamicType.Builder<T> redefine(Class<T> type, ClassFileLocator class
* @return A type builder for redefining the provided type.
*/
public <T> DynamicType.Builder<T> redefine(TypeDescription type, ClassFileLocator classFileLocator) {
return new RedefinitionDynamicTypeBuilder<T>(InstrumentedType.Default.represent(type),
return new RedefinitionDynamicTypeBuilder<T>(InstrumentedType.Default.of(type),
classFileVersion,
auxiliaryTypeNamingStrategy,
annotationValueFilterFactory,
Expand Down Expand Up @@ -620,7 +620,7 @@ public <T> DynamicType.Builder<T> rebase(TypeDescription type, ClassFileLocator
* @return A type builder for rebasing the provided type.
*/
public <T> DynamicType.Builder<T> rebase(TypeDescription type, ClassFileLocator classFileLocator, MethodNameTransformer methodNameTransformer) {
return new RebaseDynamicTypeBuilder<T>(InstrumentedType.Default.represent(type),
return new RebaseDynamicTypeBuilder<T>(InstrumentedType.Default.of(type),
classFileVersion,
auxiliaryTypeNamingStrategy,
annotationValueFilterFactory,
Expand Down
Expand Up @@ -199,6 +199,12 @@ public String toString() {
*/
public interface BaseNameResolver {

/**
* Resolves the base name for a given type description.
*
* @param typeDescription The type for which the base name is resolved.
* @return The base name for the given type.
*/
String resolve(TypeDescription typeDescription);

/**
Expand Down
Expand Up @@ -17,7 +17,6 @@
*/
public interface AnnotationList extends FilterableList<AnnotationDescription, AnnotationList> {


/**
* Checks if this list contains an annotation of the given type.
*
Expand Down Expand Up @@ -60,6 +59,11 @@ public interface AnnotationList extends FilterableList<AnnotationDescription, An
*/
AnnotationList visibility(ElementMatcher<? super RetentionPolicy> matcher);

/**
* Returns a list of the annotation types of this list.
*
* @return A list of the annotation types of this list.
*/
TypeList asTypeList();

/**
Expand Down Expand Up @@ -197,6 +201,11 @@ class Explicit extends AbstractBase {
*/
private final List<? extends AnnotationDescription> annotationDescriptions;

/**
* Creates a new list of annotation descriptions.
*
* @param annotationDescription The list of represented annotation descriptions.
*/
public Explicit(AnnotationDescription... annotationDescription) {
this(Arrays.asList(annotationDescription));
}
Expand Down
Expand Up @@ -37,6 +37,9 @@ public interface FieldDescription extends ByteCodeElement,
*/
TypeDescription.Generic getType();

/**
* Represents a field description in its generic shape, i.e. in the shape it is defined by a generic or raw type.
*/
interface InGenericShape extends FieldDescription {

@Override
Expand Down Expand Up @@ -360,6 +363,9 @@ public InDefinedShape asDefined() {
}
}

/**
* A token representing a field's properties detached from a type.
*/
class Token implements ByteCodeElement.Token<Token> {

/**
Expand Down
Expand Up @@ -255,6 +255,8 @@ public int size() {

/**
* An implementation of an empty field list.
*
* @param <S> The type of parameter descriptions represented by this list.
*/
class Empty<S extends FieldDescription> extends FilterableList.Empty<S, FieldList<S>> implements FieldList<S> {

Expand Down
Expand Up @@ -227,6 +227,11 @@ public interface MethodDescription extends TypeVariableSource,
*/
boolean isDefaultValue(Object value);

/**
* Returns a signature token representing this method.
*
* @return A signature token representing this method.
*/
SignatureToken asSignatureToken();

/**
Expand All @@ -236,6 +241,9 @@ public interface MethodDescription extends TypeVariableSource,
*/
TypeToken asTypeToken();

/**
* Represents a method description in its generic shape, i.e. in the shape it is defined by a generic or raw type.
*/
interface InGenericShape extends MethodDescription {

@Override
Expand Down Expand Up @@ -919,6 +927,11 @@ class Latent extends InDefinedShape.AbstractBase {
*/
private final int modifiers;

/**
* Returns the type variables of this method token.
*
* @return A mapping of a type variable's symbol to a list of its bounds.
*/
Map<String, ? extends TypeList.Generic> typeVariables;

/**
Expand Down Expand Up @@ -1303,6 +1316,9 @@ public String getSymbol() {
}
}

/**
* A token representing a method's properties detached from a type.
*/
class Token implements ByteCodeElement.Token<Token> {

/**
Expand All @@ -1315,6 +1331,9 @@ class Token implements ByteCodeElement.Token<Token> {
*/
private final int modifiers;

/**
* A mapping of a type variable's symbol to a list of its bounds.
*/
private final Map<String, ? extends TypeList.Generic> typeVariables;

/**
Expand Down Expand Up @@ -1342,18 +1361,30 @@ class Token implements ByteCodeElement.Token<Token> {
*/
private final Object defaultValue;

/**
* Creates a new method token representing a constructor without any parameters, exception types, type variables or annotations.
*
* @param modifiers The constructor's modifiers.
*/
public Token(int modifiers) {
this(MethodDescription.CONSTRUCTOR_INTERNAL_NAME, modifiers, TypeDescription.Generic.VOID);
}

/**
* Creates a new method token representing a method without any parameters, exception types, type variables or annotations.
*
* @param name The name of the method.
* @param modifiers The modifiers of the method.
* @param returnType The return type of the method.
*/
public Token(String name, int modifiers, TypeDescription.Generic returnType) {
this(name, modifiers, returnType, Collections.<TypeDescription.Generic>emptyList());
}

/**
* Creates a new method token with simple values.
*
* @param name The internal name of the represented method.
* @param name The internal name of the represented method.
* @param modifiers The modifiers of the represented method.
* @param returnType The return type of the represented method.
* @param parameterTypes The parameter types of this method.
Expand All @@ -1372,7 +1403,7 @@ public Token(String name, int modifiers, TypeDescription.Generic returnType, Lis
/**
* Creates a new token for a method description.
*
* @param name The internal name of the represented method.
* @param name The internal name of the represented method.
* @param modifiers The modifiers of the represented method.
* @param typeVariables The type variables of the the represented method.
* @param returnType The return type of the represented method.
Expand Down Expand Up @@ -1417,6 +1448,11 @@ public int getModifiers() {
return modifiers;
}

/**
* Returns the type variables of this method token.
*
* @return A mapping of a type variable's symbol to a list of its bounds.
*/
public Map<String, TypeList.Generic> getTypeVariables() {
return new LinkedHashMap<String, TypeList.Generic>(typeVariables);
}
Expand Down Expand Up @@ -1525,8 +1561,14 @@ public String toString() {
}
}

/**
* A token representing a method's name and raw return and parameter types.
*/
class SignatureToken {

/**
* The internal name of the represented method.
*/
private final String name;

/**
Expand All @@ -1542,6 +1584,7 @@ class SignatureToken {
/**
* Creates a new type token.
*
* @param name The internal name of the represented method.
* @param returnType The represented method's raw return type.
* @param parameterTypes The represented method's raw parameter types.
*/
Expand All @@ -1551,6 +1594,11 @@ public SignatureToken(String name, TypeDescription returnType, List<? extends Ty
this.parameterTypes = parameterTypes;
}

/**
* Returns the internal name of the represented method.
*
* @return The internal name of the represented method.
*/
public String getName() {
return name;
}
Expand All @@ -1573,6 +1621,11 @@ public List<TypeDescription> getParameterTypes() {
return new ArrayList<TypeDescription>(parameterTypes);
}

/**
* Returns this signature token as a type token.
*
* @return This signature token as a type token.
*/
public TypeToken asTypeToken() {
return new TypeToken(returnType, parameterTypes);
}
Expand Down
Expand Up @@ -279,6 +279,8 @@ public int size() {

/**
* An implementation of an empty method list.
*
* @param <S> The type of parameter descriptions represented by this list.
*/
class Empty<S extends MethodDescription> extends FilterableList.Empty<S, MethodList<S>> implements MethodList<S> {

Expand Down
Expand Up @@ -77,6 +77,9 @@ public interface ParameterDescription extends AnnotatedCodeElement,
*/
int getOffset();

/**
* Represents a parameter description in its generic shape, i.e. in the shape it is defined by a generic or raw type.
*/
interface InGenericShape extends ParameterDescription {

@Override
Expand Down Expand Up @@ -910,8 +913,7 @@ public InDefinedShape asDefined() {
}

/**
* A token that describes the shape of a method parameter. A parameter token is equal to another parameter token if
* their explicit names are explicitly defined and equal or if the token is of the same identity.
* A token representing a parameter's properties detached from a type.
*/
class Token implements ByteCodeElement.Token<Token> {

Expand Down Expand Up @@ -964,6 +966,13 @@ public Token(TypeDescription.Generic typeDescription, List<? extends AnnotationD
this(typeDescription, annotationDescriptions, NO_NAME, NO_MODIFIERS);
}

/**
* Creates a parameter token without annotations.
*
* @param typeDescription The type of the represented parameter.
* @param name The name of the parameter or {@code null} if no explicit name is defined.
* @param modifiers The modifiers of the parameter or {@code null} if no explicit modifiers is defined.
*/
public Token(TypeDescription.Generic typeDescription, String name, Integer modifiers) {
this(typeDescription, Collections.<AnnotationDescription>emptyList(), name, modifiers);
}
Expand Down
Expand Up @@ -442,6 +442,11 @@ class Explicit<S extends ParameterDescription> extends AbstractBase<S> {
*/
private final List<? extends S> parameterDescriptions;

/**
* Creates a new list of explicit parameter descriptions.
*
* @param parameterDescription The list of parameter descriptions that are represented by this list.
*/
@SuppressWarnings("unchecked")
public Explicit(S... parameterDescription) {
this(Arrays.asList(parameterDescription));
Expand Down Expand Up @@ -597,6 +602,8 @@ public int size() {

/**
* An empty list of parameters.
*
* @param <S> The type of parameter descriptions represented by this list.
*/
class Empty<S extends ParameterDescription> extends FilterableList.Empty<S, ParameterList<S>> implements ParameterList<S> {

Expand Down

0 comments on commit c03c27e

Please sign in to comment.