class UserDataRepository implements UserRepository {

    @Override
    public void getUserById(final int userId, final UserDetailsCallback userCallback) {
        UserDataStore userDataStore;
        if (!this.userCache.isExpired() && this.userCache.isCached(userId)) {
            userDataStore = diskUserDataStore;
        } else {
            userDataStore = cloudUserDataStore;
        }
        userDataStore.getUserEntityDetails(userId, new UserDataStore.UserDetailsCallback() {
            @Override
            public void onUserEntityLoaded(UserEntity userEntity) {
                UserDataRepository.this.putUserEntityInCache(userEntity);
                User user = UserDataRepository.this.userEntityDataMapper.transform(userEntity);
                if (user != null) {
                    userCallback.onUserLoaded(user);
                } else {
                    userCallback.onError(new RepositoryErrorBundle(ErrorBundle.Error.UserNotFound));
                }
            }

            @Override
            public void onError(Exception exception) {
                userCallback.onError(new RepositoryErrorBundle(ErrorBundle.Error.UnexpectedException, exception));
            }
        });
    }

}