private AutoApplicableConverterDescriptor resolveAutoApplicableDescriptor( Class<? extends AttributeConverter> converterClass, Boolean forceAutoApply) { final boolean autoApply; if ( forceAutoApply != null ) { // if the caller explicitly specified whether to auto-apply, honor that autoApply = forceAutoApply; } else { // otherwise, look at the converter's @Converter annotation final Converter annotation = converterClass.getAnnotation( Converter.class ); autoApply = annotation != null && annotation.autoApply(); } return autoApply ? new AutoApplicableConverterDescriptorStandardImpl( this ) : AutoApplicableConverterDescriptorBypassedImpl.INSTANCE; }
/** * Build an AttributeConverterDefinition from an AttributeConverter instance. The * converter is searched for a {@link Converter} annotation to determine whether it should * be treated as auto-apply. If the annotation is present, {@link Converter#autoApply()} is * used to make that determination. If the annotation is not present, {@code false} is assumed. * * @param attributeConverter The AttributeConverter instance * * @return The constructed definition */ public static AttributeConverterDefinition from(AttributeConverter attributeConverter) { boolean autoApply = false; Converter converterAnnotation = attributeConverter.getClass().getAnnotation( Converter.class ); if ( converterAnnotation != null ) { autoApply = converterAnnotation.autoApply(); } return new AttributeConverterDefinition( attributeConverter, autoApply ); }
private AutoApplicableConverterDescriptor resolveAutoApplicableDescriptor( Class<? extends AttributeConverter> converterClass, Boolean forceAutoApply) { final boolean autoApply; if ( forceAutoApply != null ) { // if the caller explicitly specified whether to auto-apply, honor that autoApply = forceAutoApply; } else { // otherwise, look at the converter's @Converter annotation final Converter annotation = converterClass.getAnnotation( Converter.class ); autoApply = annotation != null && annotation.autoApply(); } return autoApply ? new AutoApplicableConverterDescriptorStandardImpl( this ) : AutoApplicableConverterDescriptorBypassedImpl.INSTANCE; }