use of net.bytebuddy.description.field.FieldDescription in project byte-buddy by raphw.
the class ElementMatchersTest method testAnyOfFieldDefinedShape.
@Test
public void testAnyOfFieldDefinedShape() throws Exception {
Field field = GenericFieldType.class.getDeclaredField(FOO);
FieldDescription fieldDescription = new TypeDescription.ForLoadedType(GenericFieldType.Inner.class).getSuperClass().getDeclaredFields().filter(named(FOO)).getOnly();
assertThat(ElementMatchers.anyOf(field).matches(fieldDescription), is(true));
assertThat(ElementMatchers.definedField(ElementMatchers.anyOf(fieldDescription.asDefined())).matches(fieldDescription), is(true));
assertThat(ElementMatchers.anyOf(fieldDescription.asDefined()).matches(fieldDescription.asDefined()), is(true));
assertThat(ElementMatchers.anyOf(fieldDescription.asDefined()).matches(fieldDescription), is(false));
assertThat(ElementMatchers.anyOf(fieldDescription).matches(fieldDescription.asDefined()), is(false));
}
use of net.bytebuddy.description.field.FieldDescription in project byte-buddy by raphw.
the class ElementMatchersTest method testIsFieldDefinedShape.
@Test
public void testIsFieldDefinedShape() throws Exception {
Field field = GenericFieldType.class.getDeclaredField(FOO);
FieldDescription fieldDescription = new TypeDescription.ForLoadedType(GenericFieldType.Inner.class).getSuperClass().getDeclaredFields().filter(named(FOO)).getOnly();
assertThat(ElementMatchers.is(field).matches(fieldDescription), is(true));
assertThat(ElementMatchers.definedField(ElementMatchers.is(fieldDescription.asDefined())).matches(fieldDescription), is(true));
assertThat(ElementMatchers.is(fieldDescription.asDefined()).matches(fieldDescription.asDefined()), is(true));
assertThat(ElementMatchers.is(fieldDescription.asDefined()).matches(fieldDescription), is(true));
assertThat(ElementMatchers.is(fieldDescription).matches(fieldDescription.asDefined()), is(false));
}
use of net.bytebuddy.description.field.FieldDescription in project byte-buddy by raphw.
the class ElementMatchersTest method testNoneOfFieldDefinedShape.
@Test
public void testNoneOfFieldDefinedShape() throws Exception {
Field field = GenericFieldType.class.getDeclaredField(FOO);
FieldDescription fieldDescription = new TypeDescription.ForLoadedType(GenericFieldType.Inner.class).getSuperClass().getDeclaredFields().filter(named(FOO)).getOnly();
assertThat(ElementMatchers.noneOf(field).matches(fieldDescription), is(false));
assertThat(ElementMatchers.definedField(ElementMatchers.noneOf(fieldDescription.asDefined())).matches(fieldDescription), is(false));
assertThat(ElementMatchers.noneOf(fieldDescription.asDefined()).matches(fieldDescription.asDefined()), is(false));
assertThat(ElementMatchers.noneOf(fieldDescription.asDefined()).matches(fieldDescription), is(true));
assertThat(ElementMatchers.noneOf(fieldDescription).matches(fieldDescription.asDefined()), is(true));
}
use of net.bytebuddy.description.field.FieldDescription in project byte-buddy by raphw.
the class AbstractTypeDescriptionGenericTest method testRawType.
@Test
public void testRawType() throws Exception {
TypeDescription.Generic type = describeType(RawType.class.getDeclaredField(FOO)).getSuperClass().getSuperClass();
FieldDescription fieldDescription = type.getDeclaredFields().filter(named(BAR)).getOnly();
assertThat(fieldDescription.getType().getSort(), is(TypeDefinition.Sort.NON_GENERIC));
assertThat(fieldDescription.getType().asErasure(), is(TypeDescription.OBJECT));
}
use of net.bytebuddy.description.field.FieldDescription in project byte-buddy by raphw.
the class TransformerForFieldTest method testNoChangesUnlessSpecified.
@Test
public void testNoChangesUnlessSpecified() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(Bar.class);
FieldDescription fieldDescription = typeDescription.getSuperClass().getDeclaredFields().filter(named(FOO)).getOnly();
FieldDescription transformed = Transformer.ForField.withModifiers().transform(typeDescription, fieldDescription);
assertThat(transformed, is(fieldDescription));
assertThat(transformed.getModifiers(), is(fieldDescription.getModifiers()));
}
Aggregations