
org.jboss.weld.annotated.slim.unbacked.UnbackedAnnotatedField Maven / Gradle / Ivy
package org.jboss.weld.annotated.slim.unbacked;
import static org.jboss.weld.util.reflection.Reflections.cast;
import java.io.ObjectInputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.Set;
import jakarta.enterprise.inject.spi.AnnotatedField;
import org.jboss.weld.exceptions.InvalidObjectException;
import org.jboss.weld.logging.BeanLogger;
import org.jboss.weld.resources.SharedObjectCache;
import org.jboss.weld.util.AnnotatedTypes;
import org.jboss.weld.util.reflection.Formats;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@SuppressFBWarnings(value = { "SE_BAD_FIELD", "SE_NO_SUITABLE_CONSTRUCTOR",
"SE_NO_SERIALVERSIONID" }, justification = "False positive from FindBugs - serialization is handled by SerializationProxy.")
public class UnbackedAnnotatedField extends UnbackedAnnotatedMember implements AnnotatedField, Serializable {
public static AnnotatedField of(AnnotatedField originalField, UnbackedAnnotatedType declaringType,
SharedObjectCache cache) {
UnbackedAnnotatedType downcastDeclaringType = cast(declaringType);
return new UnbackedAnnotatedField(originalField.getBaseType(), originalField.getTypeClosure(),
cache.getSharedSet(originalField.getAnnotations()), originalField.getJavaMember(),
downcastDeclaringType);
}
private final Field field;
public UnbackedAnnotatedField(Type baseType, Set typeClosure, Set annotations, Field field,
UnbackedAnnotatedType declaringType) {
super(baseType, typeClosure, annotations, declaringType);
this.field = field;
}
public Field getJavaMember() {
return field;
}
@Override
public String toString() {
return Formats.formatAnnotatedField(this);
}
// Serialization
private Object writeReplace() throws ObjectStreamException {
return new UnbackedMemberIdentifier(getDeclaringType(), AnnotatedTypes.createFieldId(this));
}
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw BeanLogger.LOG.serializationProxyRequired();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy