Skip to content

Commit

Permalink
Refactored public API.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Dec 21, 2015
1 parent d75bd3e commit 11501b5
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 141 deletions.
2 changes: 1 addition & 1 deletion byte-buddy-dep/src/main/java/net/bytebuddy/ByteBuddy.java
Expand Up @@ -360,7 +360,7 @@ public DynamicType.Builder<?> makeInterface(Type... type) {
* interfaces.
*/
public DynamicType.Builder<?> makeInterface(Class<?>... type) {
return makeInterface(new TypeList.ForLoadedType(nonNull(type)));
return makeInterface(new TypeList.ForLoadedTypes(nonNull(type)));
}

/**
Expand Down
Expand Up @@ -1580,7 +1580,7 @@ public static Object describe(Object value, TypeDescription typeDescription) {
if (typeDescription.represents(Class.class)) {
value = new TypeDescription.ForLoadedType((Class<?>) value);
} else if (typeDescription.represents(Class[].class)) {
value = new TypeList.ForLoadedType((Class<?>[]) value).toArray(new TypeDescription[((Class<?>[]) value).length]);
value = new TypeList.ForLoadedTypes((Class<?>[]) value).toArray(new TypeDescription[((Class<?>[]) value).length]);
} else if (typeDescription.isAssignableTo(Enum.class)) {
value = new EnumerationDescription.ForLoadedEnumeration((Enum<?>) value);
} else if (typeDescription.isAssignableTo(Enum[].class)) {
Expand Down Expand Up @@ -1992,7 +1992,7 @@ public Builder defineAnnotationArray(String property, TypeDescription annotation
* @return A builder with the additional type array property.
*/
public Builder defineTypeArray(String property, Class<?>... type) {
return defineTypeArray(property, new TypeList.ForLoadedType(nonNull(type)).toArray(new TypeDescription[type.length]));
return defineTypeArray(property, new TypeList.ForLoadedTypes(nonNull(type)).toArray(new TypeDescription[type.length]));
}

/**
Expand Down
Expand Up @@ -6,6 +6,7 @@
import net.bytebuddy.description.annotation.AnnotatedCodeElement;
import net.bytebuddy.description.annotation.AnnotationDescription;
import net.bytebuddy.description.annotation.AnnotationList;
import net.bytebuddy.description.type.TypeDefinition;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.description.type.TypeList;
import net.bytebuddy.description.type.generic.GenericTypeDescription;
Expand Down Expand Up @@ -1074,20 +1075,20 @@ public static class TypeList extends AbstractList<Token> {
/**
* The list of types to represent as parameter tokens.
*/
private final List<? extends GenericTypeDescription> typeDescriptions;
private final List<? extends TypeDefinition> typeDescriptions;

/**
* Creates a new list of types that represent parameters.
*
* @param typeDescriptions The types to represent.
*/
public TypeList(List<? extends GenericTypeDescription> typeDescriptions) {
public TypeList(List<? extends TypeDefinition> typeDescriptions) {
this.typeDescriptions = typeDescriptions;
}

@Override
public Token get(int index) {
return new Token(typeDescriptions.get(index));
return new Token(typeDescriptions.get(index).asGenericType());
}

@Override
Expand Down
Expand Up @@ -784,7 +784,7 @@ public TypeDescription getEnclosingType() {

@Override
public TypeList getDeclaredTypes() {
return new TypeList.ForLoadedType(type.getDeclaredClasses());
return new TypeList.ForLoadedTypes(type.getDeclaredClasses());
}

@Override
Expand Down
@@ -1,13 +1,10 @@
package net.bytebuddy.description.type;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.bytebuddy.description.type.generic.GenericTypeDescription;
import net.bytebuddy.description.type.generic.GenericTypeList;
import net.bytebuddy.implementation.bytecode.StackSize;
import net.bytebuddy.matcher.FilterableList;
import org.objectweb.asm.Type;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -50,7 +47,7 @@ protected TypeList wrap(List<TypeDescription> values) {
/**
* Implementation of a type list for an array of loaded types.
*/
class ForLoadedType extends AbstractBase {
class ForLoadedTypes extends AbstractBase {

/**
* The loaded types this type list represents.
Expand All @@ -62,7 +59,7 @@ class ForLoadedType extends AbstractBase {
*
* @param type The types to be represented by this list.
*/
public ForLoadedType(Class<?>... type) {
public ForLoadedTypes(Class<?>... type) {
this(Arrays.asList(type));
}

Expand All @@ -71,7 +68,7 @@ public ForLoadedType(Class<?>... type) {
*
* @param types The types to be represented by this list.
*/
public ForLoadedType(List<? extends Class<?>> types) {
public ForLoadedTypes(List<? extends Class<?>> types) {
this.types = types;
}

Expand Down
Expand Up @@ -414,7 +414,7 @@ public int size() {

@Override
public TypeList asErasures() {
return new TypeList.ForLoadedType(type.getInterfaces());
return new TypeList.ForLoadedTypes(type.getInterfaces());
}

/**
Expand Down Expand Up @@ -493,7 +493,7 @@ public int size() {

@Override
public TypeList asErasures() {
return new TypeList.ForLoadedType(constructor.getExceptionTypes());
return new TypeList.ForLoadedTypes(constructor.getExceptionTypes());
}

/**
Expand Down Expand Up @@ -572,7 +572,7 @@ public int size() {

@Override
public TypeList asErasures() {
return new TypeList.ForLoadedType(method.getExceptionTypes());
return new TypeList.ForLoadedTypes(method.getExceptionTypes());
}

/**
Expand Down

0 comments on commit 11501b5

Please sign in to comment.