public DynamicComponentSource(ReflectionManager reflectionManager, Component component, XProperty baseProperty) { super( reflectionManager.toXClass( Map.class ), component ); this.baseProperty = baseProperty; } }
public String getTypeName() throws MappingException { return returnedClass == null ? null : returnedClass.getName(); }
public String getPropertyName() throws MappingException { return property.getName(); }
public XClass getPropertyClass() throws MappingException { if ( property.isAnnotationPresent( Target.class ) ) { return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() ); } else { return property.getType(); } }
public XClass getClassOrElement() throws MappingException { if ( property.isAnnotationPresent( Target.class ) ) { return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() ); } else { return property.getClassOrElementClass(); } }
private static boolean hasAnnotationsOnIdClass(XClass idClass) { // if(idClass.getAnnotation(Embeddable.class) != null) // return true; List<XProperty> properties = idClass.getDeclaredProperties( XClass.ACCESS_FIELD ); for ( XProperty property : properties ) { if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( OneToMany.class ) || property.isAnnotationPresent( ManyToOne.class ) || property.isAnnotationPresent( Id.class ) || property.isAnnotationPresent( GeneratedValue.class ) || property.isAnnotationPresent( OneToOne.class ) || property.isAnnotationPresent( ManyToMany.class ) ) { return true; } } List<XMethod> methods = idClass.getDeclaredMethods(); for ( XMethod method : methods ) { if ( method.isAnnotationPresent( Column.class ) || method.isAnnotationPresent( OneToMany.class ) || method.isAnnotationPresent( ManyToOne.class ) || method.isAnnotationPresent( Id.class ) || method.isAnnotationPresent( GeneratedValue.class ) || method.isAnnotationPresent( OneToOne.class ) || method.isAnnotationPresent( ManyToMany.class ) ) { return true; } } return false; }
private void insertMappedSuperclasses(List<XClass> original, List<XClass> copy) { for ( XClass clazz : original ) { XClass superClass = clazz.getSuperclass(); while ( superClass != null && !reflectionManager.equals( superClass, Object.class ) && !copy.contains( superClass ) ) { if ( superClass.isAnnotationPresent( Entity.class ) || superClass.isAnnotationPresent( javax.persistence.MappedSuperclass.class ) ) { copy.add( superClass ); } superClass = superClass.getSuperclass(); } } }
private static boolean mustBeSkipped(XProperty property) { //TODO make those hardcoded tests more portable (through the bytecode provider?) return property.isAnnotationPresent( Transient.class ) || "net.sf.cglib.transform.impl.InterceptFieldCallback".equals( property.getType().getName() ) || "org.hibernate.bytecode.internal.javassist.FieldHandler".equals( property.getType().getName() ); } }
private void assertTypesAreResolvable() { for ( XProperty xProperty : persistentAttributeMap.values() ) { if ( !xProperty.isTypeResolved() && !discoverTypeWithoutReflection( xProperty ) ) { String msg = "Property " + StringHelper.qualify( xClass.getName(), xProperty.getName() ) + " has an unbound type and no explicit target entity. Resolve this Generic usage issue" + " or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type"; throw new AnnotationException( msg ); } } } //
/** * Checks whether one class is assignable from another. If not {@link MappingException} is thrown. * * @param child Subclass. * @param parent Superclass. */ private void checkSuperclass(XClass child, XClass parent) { if ( !parent.isAssignableFrom( child ) ) { throw new MappingException( "Class " + parent.getName() + " is not assignable from " + child.getName() + ". " + "Please revise Envers annotations applied to " + child.getName() + " type." ); } }
private void orderHierarchy(List<XClass> copy, List<XClass> newList, List<XClass> original, XClass clazz) { if ( clazz == null || reflectionManager.equals( clazz, Object.class ) ) { return; } //process superclass first orderHierarchy( copy, newList, original, clazz.getSuperclass() ); if ( original.contains( clazz ) ) { if ( !newList.contains( clazz ) ) { newList.add( clazz ); } copy.remove( clazz ); } }
/** * @param clazz Source class. * @param propertyName Property name. * @param accessType Expected access type. Legal values are <i>field</i> and <i>property</i>. * * @return Property object or {@code null} if none with expected name and access type has been found. */ public static XProperty getProperty(XClass clazz, String propertyName, String accessType) { for ( XProperty property : clazz.getDeclaredProperties( accessType ) ) { if ( propertyName.equals( property.getName() ) ) { return property; } } return null; }
private ModificationStore getDefaultAudited(XClass clazz) { final Audited defaultAudited = clazz.getAnnotation( Audited.class ); if ( defaultAudited != null ) { return defaultAudited.modStore(); } else { return null; } }
private static AssociationOverride[] buildAssociationOverrides(XAnnotatedElement element, String path) { AssociationOverride singleOverride = element.getAnnotation( AssociationOverride.class ); AssociationOverrides pluralOverrides = element.getAnnotation( AssociationOverrides.class ); AssociationOverride[] overrides; if ( singleOverride != null ) { overrides = new AssociationOverride[] { singleOverride }; } else if ( pluralOverrides != null ) { overrides = pluralOverrides.value(); } else { overrides = null; } return overrides; }
@SuppressWarnings("deprecation") private XClass toXClass(String className, ReflectionManager reflectionManager) { try { return reflectionManager.classForName( className ); } catch ( ClassLoadingException e ) { throw new AnnotationException( "Unable to load class defined in XML: " + className, e ); } }
public String getTypeName() throws MappingException { return getPropertyClass().getName(); }
@Override protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) { final String propertyName = property.getName(); // conversions on parent would have precedence AttributeConversionInfo conversion = locateAttributeConversionInfo( propertyName ); if ( conversion != null ) { return conversion; } return null; }
public String getClassOrElementName() throws MappingException { return getClassOrElement().getName(); }
@Override protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) { return locateAttributeConversionInfo( property.getName() ); }