javax.persistence.Converter#autoApply ( )源码实例Demo

下面列出了javax.persistence.Converter#autoApply ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: AbstractConverterDescriptor.java
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;
}
 
源代码2 项目: lams   文件: AttributeConverterDefinition.java
/**
 * 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 );
}
 
 方法所在类
 同类方法