class LocalDhisResourceRepositoryTemplate {

    @Nonnull
    public Optional<T> findOneById( @Nonnull String id, @Nonnull Function<String, T> callback )
    {
        final RequestCacheContext context = requestCacheService.getCurrentRequestCacheContext();
        final Optional<LocalDhisResourceRepository<T>> repository = getRepository( context );

        T result = null;

        if ( repository.isPresent() )
        {
            result = repository.get().findOneById( id ).orElse( null );
        }

        if ( result == null )
        {
            result = callback.apply( id );
        }

        return Optional.ofNullable( result );
    }

    public  LocalDhisResourceRepositoryTemplate( @Nonnull Class<T> resourceClass, @Nonnull RequestCacheService requestCacheService,
        @Nonnull LocalDhisRepositoryPersistCallback<T> persistCallback );

}