下面列出了javax.persistence.Embedded#net.bytebuddy.description.field.FieldDescription 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Creates a new default implementation context.
*
* @param instrumentedType The description of the type that is currently subject of creation.
* @param classFileVersion The class file version of the created class.
* @param auxiliaryTypeNamingStrategy The naming strategy for naming an auxiliary type.
* @param typeInitializer The type initializer of the created instrumented type.
* @param auxiliaryClassFileVersion The class file version to use for auxiliary classes.
*/
protected Default(TypeDescription instrumentedType,
ClassFileVersion classFileVersion,
AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
TypeInitializer typeInitializer,
ClassFileVersion auxiliaryClassFileVersion) {
super(instrumentedType, classFileVersion);
this.auxiliaryTypeNamingStrategy = auxiliaryTypeNamingStrategy;
this.typeInitializer = typeInitializer;
this.auxiliaryClassFileVersion = auxiliaryClassFileVersion;
registeredAccessorMethods = new HashMap<SpecialMethodInvocation, DelegationRecord>();
registeredGetters = new HashMap<FieldDescription, DelegationRecord>();
registeredSetters = new HashMap<FieldDescription, DelegationRecord>();
auxiliaryTypes = new HashMap<AuxiliaryType, DynamicType>();
registeredFieldCacheEntries = new HashMap<FieldCacheEntry, FieldDescription.InDefinedShape>();
registeredFieldCacheFields = new HashSet<FieldDescription.InDefinedShape>();
suffix = RandomString.make();
fieldCacheCanAppendEntries = true;
}
@Test
public void testInstrumentationLegacyClassFileArrayType() throws Exception {
ClassVisitor classVisitor = TypeConstantAdjustment.INSTANCE.wrap(mock(TypeDescription.class),
this.classVisitor,
mock(Implementation.Context.class),
mock(TypePool.class),
new FieldList.Empty<FieldDescription.InDefinedShape>(),
new MethodList.Empty<MethodDescription>(),
IGNORED,
IGNORED);
classVisitor.visit(ClassFileVersion.JAVA_V4.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
MethodVisitor methodVisitor = classVisitor.visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
assertThat(methodVisitor, not(this.methodVisitor));
methodVisitor.visitLdcInsn(Type.getType(Object[].class));
verify(this.classVisitor).visit(ClassFileVersion.JAVA_V4.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
verify(this.classVisitor).visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
verifyNoMoreInteractions(this.classVisitor);
verify(this.methodVisitor).visitLdcInsn(Type.getType(Object[].class).getInternalName().replace('/', '.'));
verify(this.methodVisitor).visitMethodInsn(Opcodes.INVOKESTATIC,
Type.getType(Class.class).getInternalName(),
"forName",
Type.getType(Class.class.getDeclaredMethod("forName", String.class)).getDescriptor(),
false);
verifyNoMoreInteractions(this.methodVisitor);
}
@Test
@SuppressWarnings("unchecked")
public void testAccessorIsValid() throws Exception {
TypeProxy typeProxy = new TypeProxy(mock(TypeDescription.class),
mock(Implementation.Target.class),
mock(TypeProxy.InvocationFactory.class),
false,
false);
TypeProxy.MethodCall methodCall = typeProxy.new MethodCall(mock(MethodAccessorFactory.class));
TypeDescription instrumentedType = mock(TypeDescription.class);
FieldList<FieldDescription.InDefinedShape> fieldList = mock(FieldList.class);
when(fieldList.filter(any(ElementMatcher.class))).thenReturn(fieldList);
when(fieldList.getOnly()).thenReturn(mock(FieldDescription.InDefinedShape.class));
when(instrumentedType.getDeclaredFields()).thenReturn(fieldList);
TypeProxy.MethodCall.Appender appender = methodCall.new Appender(instrumentedType);
Implementation.SpecialMethodInvocation specialMethodInvocation = mock(Implementation.SpecialMethodInvocation.class);
when(specialMethodInvocation.isValid()).thenReturn(true);
StackManipulation stackManipulation = appender.new AccessorMethodInvocation(mock(MethodDescription.class), specialMethodInvocation);
assertThat(stackManipulation.isValid(), is(true));
verify(specialMethodInvocation).isValid();
verifyNoMoreInteractions(specialMethodInvocation);
}
private List<FieldDescription> collectCollectionFields(TypeDescription managedCtClass) {
List<FieldDescription> collectionList = new ArrayList<>();
for ( FieldDescription ctField : managedCtClass.getDeclaredFields() ) {
// skip static fields and skip fields added by enhancement
if ( Modifier.isStatic( ctField.getModifiers() ) || ctField.getName().startsWith( "$$_hibernate_" ) ) {
continue;
}
if ( enhancementContext.isPersistentField( ctField ) && !enhancementContext.isMappedCollection( ctField ) ) {
if ( ctField.getType().asErasure().isAssignableTo( Collection.class ) || ctField.getType().asErasure().isAssignableTo( Map.class ) ) {
collectionList.add( ctField );
}
}
}
// HHH-10646 Add fields inherited from @MappedSuperclass
// HHH-10981 There is no need to do it for @MappedSuperclass
if ( !enhancementContext.isMappedSuperclassClass( managedCtClass ) ) {
collectionList.addAll( collectInheritCollectionFields( managedCtClass ) );
}
return collectionList;
}
private Collection<FieldDescription> collectInheritCollectionFields(TypeDefinition managedCtClass) {
TypeDefinition managedCtSuperclass = managedCtClass.getSuperClass();
if ( managedCtSuperclass == null || managedCtSuperclass.represents( Object.class ) ) {
return Collections.emptyList();
}
if ( !enhancementContext.isMappedSuperclassClass( managedCtSuperclass.asErasure() ) ) {
return collectInheritCollectionFields( managedCtSuperclass.asErasure() );
}
List<FieldDescription> collectionList = new ArrayList<FieldDescription>();
for ( FieldDescription ctField : managedCtSuperclass.getDeclaredFields() ) {
if ( !Modifier.isStatic( ctField.getModifiers() ) ) {
if ( enhancementContext.isPersistentField( ctField ) && !enhancementContext.isMappedCollection( ctField ) ) {
if ( ctField.getType().asErasure().isAssignableTo( Collection.class ) || ctField.getType().asErasure().isAssignableTo( Map.class ) ) {
collectionList.add( ctField );
}
}
}
}
collectionList.addAll( collectInheritCollectionFields( managedCtSuperclass ) );
return collectionList;
}
private static Collection<FieldDescription> collectInheritPersistentFields(
TypeDefinition managedCtClass,
ByteBuddyEnhancementContext enhancementContext) {
if ( managedCtClass == null || managedCtClass.represents( Object.class ) ) {
return Collections.emptyList();
}
TypeDefinition managedCtSuperclass = managedCtClass.getSuperClass();
if ( !enhancementContext.isMappedSuperclassClass( managedCtSuperclass.asErasure() ) ) {
return collectInheritPersistentFields( managedCtSuperclass, enhancementContext );
}
log.debugf( "Found @MappedSuperclass %s to collectPersistenceFields", managedCtSuperclass );
List<FieldDescription> persistentFieldList = new ArrayList<FieldDescription>();
for ( FieldDescription ctField : managedCtSuperclass.getDeclaredFields() ) {
if ( ctField.getName().startsWith( "$$_hibernate_" ) || "this$0".equals( ctField.getName() ) ) {
continue;
}
if ( !ctField.isStatic() && enhancementContext.isPersistentField( ctField ) ) {
persistentFieldList.add( ctField );
}
}
persistentFieldList.addAll( collectInheritPersistentFields( managedCtSuperclass, enhancementContext ) );
return persistentFieldList;
}
/**
* {@inheritDoc}
*/
public InstrumentedType.WithFlexibleName subclass(String name, int modifiers, TypeDescription.Generic superClass) {
return new InstrumentedType.Default(name,
modifiers,
superClass,
Collections.<TypeVariableToken>emptyList(),
Collections.<Generic>emptyList(),
Collections.<FieldDescription.Token>emptyList(),
Collections.<MethodDescription.Token>emptyList(),
Collections.<RecordComponentDescription.Token>emptyList(),
Collections.<AnnotationDescription>emptyList(),
TypeInitializer.None.INSTANCE,
LoadedTypeInitializer.NoOp.INSTANCE,
TypeDescription.UNDEFINED,
MethodDescription.UNDEFINED,
TypeDescription.UNDEFINED,
Collections.<TypeDescription>emptyList(),
false,
false,
false,
TargetType.DESCRIPTION,
Collections.<TypeDescription>emptyList());
}
@Test
public void testIllegalAssignmentNonAssignable() throws Exception {
doReturn(void.class).when(annotation).declaringType();
when(annotation.value()).thenReturn(FOO);
when(instrumentedType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
when(fieldDescription.getActualName()).thenReturn(FOO);
when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
when(stackManipulation.isValid()).thenReturn(false);
MethodDelegationBinder.ParameterBinding<?> binding = FieldValue.Binder.INSTANCE.bind(annotationDescription,
source,
target,
implementationTarget,
assigner,
Assigner.Typing.STATIC);
assertThat(binding.isValid(), is(false));
}
/**
* {@inheritDoc}
*/
public InstrumentedType prepare(InstrumentedType instrumentedType) {
for (RecordComponentDescription.InDefinedShape recordComponent : instrumentedType.getRecordComponents()) {
instrumentedType = instrumentedType
.withField(new FieldDescription.Token(recordComponent.getActualName(),
Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL,
recordComponent.getType(),
recordComponent.getDeclaredAnnotations().filter(targetsElement(ElementType.FIELD))))
.withMethod(new MethodDescription.Token(recordComponent.getActualName(),
Opcodes.ACC_PUBLIC,
Collections.<TypeVariableToken>emptyList(),
recordComponent.getType(),
Collections.<ParameterDescription.Token>emptyList(),
Collections.<TypeDescription.Generic>emptyList(),
recordComponent.getDeclaredAnnotations().filter(targetsElement(ElementType.METHOD)),
AnnotationValue.UNDEFINED,
TypeDescription.Generic.UNDEFINED));
}
return instrumentedType;
}
@Test
public void testInstrumentationLegacyClassFileObjectType() throws Exception {
ClassVisitor classVisitor = TypeConstantAdjustment.INSTANCE.wrap(mock(TypeDescription.class),
this.classVisitor,
mock(Implementation.Context.class),
mock(TypePool.class),
new FieldList.Empty<FieldDescription.InDefinedShape>(),
new MethodList.Empty<MethodDescription>(),
IGNORED,
IGNORED);
classVisitor.visit(ClassFileVersion.JAVA_V4.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
MethodVisitor methodVisitor = classVisitor.visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
assertThat(methodVisitor, not(this.methodVisitor));
methodVisitor.visitLdcInsn(Type.getType(Object.class));
verify(this.classVisitor).visit(ClassFileVersion.JAVA_V4.getMinorMajorVersion(), FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
verify(this.classVisitor).visitMethod(FOOBAR, FOO, BAR, QUX, new String[]{BAZ});
verifyNoMoreInteractions(this.classVisitor);
verify(this.methodVisitor).visitLdcInsn(Type.getType(Object.class).getClassName());
verify(this.methodVisitor).visitMethodInsn(Opcodes.INVOKESTATIC,
Type.getType(Class.class).getInternalName(),
"forName",
Type.getType(Class.class.getDeclaredMethod("forName", String.class)).getDescriptor(),
false);
verifyNoMoreInteractions(this.methodVisitor);
}
@Test
@SuppressWarnings("unchecked")
public void testIllegalAssignmentNonVisible() throws Exception {
doReturn(void.class).when(annotation).declaringType();
when(annotation.value()).thenReturn(FOO);
when(instrumentedType.getDeclaredFields()).thenReturn((FieldList) new FieldList.Explicit<FieldDescription>(fieldDescription));
when(fieldDescription.getActualName()).thenReturn(FOO);
when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(false);
when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
when(stackManipulation.isValid()).thenReturn(true);
MethodDelegationBinder.ParameterBinding<?> binding = FieldValue.Binder.INSTANCE.bind(annotationDescription,
source,
target,
implementationTarget,
assigner,
Assigner.Typing.STATIC);
assertThat(binding.isValid(), is(false));
}
/**
* Creates a new entry.
*
* @param matcher The matcher to identify any field that this definition concerns.
* @param fieldAttributeAppenderFactory The field attribute appender factory to apply on any matched field.
* @param defaultValue The default value to write to the field or {@code null} if no default value is to be set for the field.
* @param transformer The field transformer to apply to any matched field.
*/
protected Entry(LatentMatcher<? super FieldDescription> matcher,
FieldAttributeAppender.Factory fieldAttributeAppenderFactory,
Object defaultValue,
Transformer<FieldDescription> transformer) {
this.matcher = matcher;
this.fieldAttributeAppenderFactory = fieldAttributeAppenderFactory;
this.defaultValue = defaultValue;
this.transformer = transformer;
}
/**
* Creates a new member removing class visitor.
*
* @param classVisitor The class visitor to delegate to.
* @param fieldMatcher The matcher that determines field removal.
* @param methodMatcher The matcher that determines method removal.
* @param fields A mapping of field names and descriptors to their description.
* @param methods A mapping of method names and descriptors to their description.
*/
protected MemberRemovingClassVisitor(ClassVisitor classVisitor,
ElementMatcher.Junction<FieldDescription.InDefinedShape> fieldMatcher,
ElementMatcher.Junction<MethodDescription> methodMatcher,
Map<String, FieldDescription.InDefinedShape> fields,
Map<String, MethodDescription> methods) {
super(OpenedClassReader.ASM_API, classVisitor);
this.fieldMatcher = fieldMatcher;
this.methodMatcher = methodMatcher;
this.fields = fields;
this.methods = methods;
}
@Before
public void setUp() throws Exception {
when(genericField.asDefined()).thenReturn(fieldDescription);
when(genericField.getType()).thenReturn(genericType);
when(fieldDescription.getType()).thenReturn(declaredType);
when(enumerationDescription.getEnumerationType()).thenReturn(enumerationType);
when(enumerationDescription.getValue()).thenReturn(FOO);
when(enumerationType.getDeclaredFields()).thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(fieldDescription));
}
@Test
public void testAnyOfFieldDefinedShape() throws Exception {
Field field = GenericFieldType.class.getDeclaredField(FOO);
FieldDescription fieldDescription = TypeDescription.ForLoadedType.of(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));
}
private static TypeDescription.Generic target(FieldDescription persistentField) {
AnnotationDescription.Loadable<Access> access = persistentField.getDeclaringType().asErasure().getDeclaredAnnotations().ofType( Access.class );
if ( access != null && access.loadSilent().value() == AccessType.FIELD ) {
return persistentField.getType();
}
else {
MethodDescription getter = EnhancerImpl.getterOf( persistentField );
if ( getter == null ) {
return persistentField.getType();
}
else {
return getter.getReturnType();
}
}
}
private static String getMappedBy(FieldDescription target, TypeDescription targetEntity, ByteBuddyEnhancementContext context) {
String mappedBy = getMappedByNotManyToMany( target );
if ( mappedBy == null || mappedBy.isEmpty() ) {
return getMappedByManyToMany( target, targetEntity, context );
}
else {
return mappedBy;
}
}
@Test(expected = IllegalStateException.class)
public void tesFieldDuplicateAnnotation() throws Exception {
makePlainInstrumentedType()
.withField(new FieldDescription.Token(FOO, ModifierContributor.EMPTY_MASK, TypeDescription.Generic.OBJECT, Arrays.asList(
AnnotationDescription.Builder.ofType(SampleAnnotation.class).build(),
AnnotationDescription.Builder.ofType(SampleAnnotation.class).build()
))).validated();
}
@Test
public void testTypeVariableOutOfScopeIsErased() throws Exception {
TypeDescription typeDescription = new InstrumentedType.Default("foo",
Opcodes.ACC_PUBLIC,
TypeDescription.Generic.OfNonGenericType.ForLoadedType.of(AbstractOuter.ExtendedInner.class),
Collections.<TypeVariableToken>emptyList(),
Collections.<TypeDescription.Generic>emptyList(),
Collections.<FieldDescription.Token>emptyList(),
Collections.singletonList(new MethodDescription.Token("foo",
Opcodes.ACC_BRIDGE,
TypeDescription.Generic.VOID,
Collections.<TypeDescription.Generic>emptyList())),
Collections.<RecordComponentDescription.Token>emptyList(),
Collections.<AnnotationDescription>emptyList(),
TypeInitializer.None.INSTANCE,
LoadedTypeInitializer.NoOp.INSTANCE,
TypeDescription.UNDEFINED,
MethodDescription.UNDEFINED,
TypeDescription.UNDEFINED,
Collections.<TypeDescription>emptyList(),
false,
false,
false,
TargetType.DESCRIPTION,
Collections.<TypeDescription>emptyList());
MethodDescription methodDescription = typeDescription.getSuperClass().getSuperClass().getDeclaredMethods().filter(named(FOO)).getOnly();
assertThat(methodDescription.getReturnType(), is(TypeDescription.Generic.OBJECT));
}
/**
* Creates a new equals method implementation.
*
* @param superClassCheck The baseline equality to check.
* @param typeCompatibilityCheck The instance type compatibility check.
* @param ignored A matcher to filter fields that should not be used for a equality resolution.
* @param nonNullable A matcher to determine fields of a reference type that cannot be {@code null}.
* @param comparator The comparator to apply for ordering fields.
*/
private EqualsMethod(SuperClassCheck superClassCheck,
TypeCompatibilityCheck typeCompatibilityCheck,
ElementMatcher.Junction<? super FieldDescription.InDefinedShape> ignored,
ElementMatcher.Junction<? super FieldDescription.InDefinedShape> nonNullable,
Comparator<? super FieldDescription.InDefinedShape> comparator) {
this.superClassCheck = superClassCheck;
this.typeCompatibilityCheck = typeCompatibilityCheck;
this.ignored = ignored;
this.nonNullable = nonNullable;
this.comparator = comparator;
}
@Test
public void testIsFieldDefinedShape() throws Exception {
Field field = GenericFieldType.class.getDeclaredField(FOO);
FieldDescription fieldDescription = TypeDescription.ForLoadedType.of(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));
}
/**
* {@inheritDoc}
*/
public void apply(FieldVisitor fieldVisitor, FieldDescription fieldDescription, AnnotationValueFilter annotationValueFilter) {
AnnotationAppender appender = new AnnotationAppender.Default(new AnnotationAppender.Target.OnField(fieldVisitor));
for (AnnotationDescription annotation : annotations) {
appender = appender.append(annotation, annotationValueFilter);
}
}
static MethodDescription getterOf(FieldDescription persistentField) {
MethodList<?> methodList = MethodGraph.Compiler.DEFAULT.compile( persistentField.getDeclaringType().asErasure() )
.listNodes()
.asMethodList()
.filter( isGetter(persistentField.getName() ) );
if ( methodList.size() == 1 ) {
return methodList.getOnly();
}
else {
return null;
}
}
private PersistentAttributeTransformer(
TypeDescription managedCtClass,
ByteBuddyEnhancementContext enhancementContext,
TypePool classPool,
FieldDescription[] enhancedFields) {
this.managedCtClass = managedCtClass;
this.enhancementContext = enhancementContext;
this.classPool = classPool;
this.enhancedFields = enhancedFields;
}
/**
* {@inheritDoc}
*/
public ClassVisitor wrap(TypeDescription instrumentedType,
ClassVisitor classVisitor,
Implementation.Context implementationContext,
TypePool typePool,
FieldList<FieldDescription.InDefinedShape> fields,
MethodList<?> methods,
int writerFlags,
int readerFlags) {
return classVisitor;
}
@Test
public void testIntermediateRawType() throws Exception {
TypeDescription.Generic type = describeType(IntermediateRaw.class.getDeclaredField(FOO)).getSuperClass().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) TypeDescription.ForLoadedType.of(Integer.class)));
}
private Implementation fieldReader(FieldDescription enhancedField) {
if ( !enhancementContext.hasLazyLoadableAttributes( managedCtClass ) || !enhancementContext.isLazyLoadable( enhancedField ) ) {
if ( enhancedField.getDeclaringType().asErasure().equals( managedCtClass ) ) {
return FieldAccessor.ofField( enhancedField.getName() ).in( enhancedField.getDeclaringType().asErasure() );
}
else {
return new Implementation.Simple( new FieldMethodReader( managedCtClass, enhancedField ) );
}
}
else {
return new Implementation.Simple( FieldReaderAppender.of( managedCtClass, enhancedField ) );
}
}
/**
* {@inheritDoc}
*/
public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) {
FieldDescription fieldDescription = instrumentedType.getDeclaredFields().filter(named(name)).getOnly();
StackManipulation stackManipulation = assigner.assign(fieldDescription.getType(), fieldType.asGenericType(), typing);
if (!stackManipulation.isValid()) {
throw new IllegalStateException("Cannot assign " + fieldDescription + " to " + fieldType);
}
return new Resolved.Simple(new StackManipulation.Compound(FieldAccess.forField(fieldDescription).read(),
stackManipulation), fieldDescription.getType().asErasure());
}
public ClassVisitor wrap(TypeDescription instrumentedType,
ClassVisitor classVisitor,
Implementation.Context implementationContext,
TypePool typePool,
FieldList<FieldDescription.InDefinedShape> fields,
MethodList<?> methods,
int writerFlags,
int readerFlags) {
return new ClassRemapper(OpenedClassReader.ASM_API, classVisitor, new SimpleRemapper(oldName, newName)) {
/* only anonymous to define usage of Byte Buddy specific API version */
};
}
@Test
public void testNoneOfFieldDefinedShape() throws Exception {
Field field = GenericFieldType.class.getDeclaredField(FOO);
FieldDescription fieldDescription = TypeDescription.ForLoadedType.of(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));
}