org.springframework.data.domain.Auditable Java Examples
The following examples show how to use
org.springframework.data.domain.Auditable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultAuditableBeanWrapperFactory.java From spring-data-mybatis with Apache License 2.0 | 6 votes |
/** * Returns an {@link AuditableBeanWrapper} if the given object is capable of being * equipped with auditing information. * @param source the auditing candidate. * @return */ @SuppressWarnings("unchecked") public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) { Assert.notNull(source, "Source must not be null!"); return Optional.of(source).map(it -> { if (it instanceof Auditable) { return (AuditableBeanWrapper<T>) new AuditableInterfaceBeanWrapper( (Auditable<Object, ?, TemporalAccessor>) it); } AnnotationAuditingMetadata metadata = AnnotationAuditingMetadata .getMetadata(it.getClass()); if (metadata.isAuditable()) { return new ReflectionAuditingBeanWrapper<T>(it); } return null; }); }
Example #2
Source File: MappingAuditableBeanWrapperFactory.java From spring-data-mybatis with Apache License 2.0 | 6 votes |
@Override public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) { return Optional.of(source).flatMap(it -> { if (it instanceof Auditable) { return super.getBeanWrapperFor(source); } return entities.mapOnContext(it.getClass(), (context, entity) -> { MappingAuditingMetadata metadata = metadataCache.computeIfAbsent( it.getClass(), key -> new MappingAuditingMetadata(context, it.getClass())); return Optional.<AuditableBeanWrapper<T>>ofNullable(metadata.isAuditable() // ? new MappingMetadataAuditableBeanWrapper<T>( entity.getPropertyAccessor(it), metadata) : null); }).orElseGet(() -> super.getBeanWrapperFor(source)); }); }
Example #3
Source File: DefaultAuditableBeanWrapperFactory.java From spring-data-mybatis with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public AuditableInterfaceBeanWrapper( Auditable<Object, ?, TemporalAccessor> auditable) { this.auditable = auditable; this.type = (Class<? extends TemporalAccessor>) ResolvableType .forClass(Auditable.class, auditable.getClass()).getGeneric(2) .resolve(TemporalAccessor.class); }
Example #4
Source File: DefaultAuditableBeanWrapperFactory.java From spring-data-mybatis with Apache License 2.0 | 4 votes |
@Override public Auditable<Object, ?, TemporalAccessor> getBean() { return auditable; }