Search in sources :

Example 1 with FieldDescription

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));
}
Also used : FieldDescription(net.bytebuddy.description.field.FieldDescription) Test(org.junit.Test)

Example 2 with FieldDescription

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));
}
Also used : FieldDescription(net.bytebuddy.description.field.FieldDescription) Test(org.junit.Test)

Example 3 with FieldDescription

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));
}
Also used : FieldDescription(net.bytebuddy.description.field.FieldDescription) Test(org.junit.Test)

Example 4 with FieldDescription

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));
}
Also used : FieldDescription(net.bytebuddy.description.field.FieldDescription) Test(org.junit.Test)

Example 5 with FieldDescription

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()));
}
Also used : TypeDescription(net.bytebuddy.description.type.TypeDescription) FieldDescription(net.bytebuddy.description.field.FieldDescription) Test(org.junit.Test)

Aggregations

FieldDescription (net.bytebuddy.description.field.FieldDescription)15 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)3 TypeDefinition (net.bytebuddy.description.type.TypeDefinition)3 TypeDescription (net.bytebuddy.description.type.TypeDescription)2 Collection (java.util.Collection)1 Map (java.util.Map)1 Embedded (javax.persistence.Embedded)1 Transient (javax.persistence.Transient)1 ByteBuddy (net.bytebuddy.ByteBuddy)1 AsmVisitorWrapper (net.bytebuddy.asm.AsmVisitorWrapper)1 DynamicType (net.bytebuddy.dynamic.DynamicType)1 Implementation (net.bytebuddy.implementation.Implementation)1 ByteCodeAppender (net.bytebuddy.implementation.bytecode.ByteCodeAppender)1 CompositeOwnerTracker (org.hibernate.bytecode.enhance.internal.tracker.CompositeOwnerTracker)1 DirtyTracker (org.hibernate.bytecode.enhance.internal.tracker.DirtyTracker)1 CompositeOwner (org.hibernate.engine.spi.CompositeOwner)1 EntityEntry (org.hibernate.engine.spi.EntityEntry)1 ExtendedSelfDirtinessTracker (org.hibernate.engine.spi.ExtendedSelfDirtinessTracker)1 ManagedEntity (org.hibernate.engine.spi.ManagedEntity)1