net.bytebuddy.description.field.FieldList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of byte-buddy Show documentation
Show all versions of byte-buddy Show documentation
Byte Buddy is a Java library for creating Java classes at run time.
This artifact is a build of Byte Buddy with all ASM dependencies repackaged into its own name space.
package net.bytebuddy.description.field;
import net.bytebuddy.matcher.FilterableList;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
/**
* Implementations represent a list of field descriptions.
*/
public interface FieldList extends FilterableList {
/**
* An implementation of a field list for an array of loaded fields.
*/
class ForLoadedField extends AbstractBase implements FieldList {
/**
* The loaded fields this field list represents.
*/
private final List extends Field> fields;
/**
* Creates a new immutable field list that represents an array of loaded field.
*
* @param field An array of fields to be represented by this field list.
*/
public ForLoadedField(Field... field) {
this(Arrays.asList(field));
}
/**
* Creates a new immutable field list that represents an array of loaded field.
*
* @param fields An array of fields to be represented by this field list.
*/
public ForLoadedField(List extends Field> fields) {
this.fields = fields;
}
@Override
public FieldDescription get(int index) {
return new FieldDescription.ForLoadedField(fields.get(index));
}
@Override
public int size() {
return fields.size();
}
@Override
protected FieldList wrap(List values) {
return new Explicit(values);
}
}
/**
* A wrapper implementation of a field list for a given list of field descriptions.
*/
class Explicit extends AbstractBase implements FieldList {
/**
* The list of field descriptions this list represents.
*/
private final List extends FieldDescription> fieldDescriptions;
/**
* Creates a new immutable wrapper field list.
*
* @param fieldDescriptions The list of fields to be represented by this field list.
*/
public Explicit(List extends FieldDescription> fieldDescriptions) {
this.fieldDescriptions = fieldDescriptions;
}
@Override
public FieldDescription get(int index) {
return fieldDescriptions.get(index);
}
@Override
public int size() {
return fieldDescriptions.size();
}
@Override
protected FieldList wrap(List values) {
return new Explicit(values);
}
}
/**
* An implementation of an empty field list.
*/
class Empty extends FilterableList.Empty implements FieldList {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy