package com.backend.unifier.title.service; import java.util.Optional; import java.util.UUID; import com.backend.unifier.title.model.ContentDetailEntry; import com.backend.unifier.title.model.ContentIdentifier; import com.backend.unifier.title.model.ContentProviderSource; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Instance; @ApplicationScoped public class GeneralDetailService { private final IdentifierMaskService maskService; private final Instance detailServices; public GeneralDetailService(IdentifierMaskService maskService, Instance detailServices) { this.maskService = maskService; this.detailServices = detailServices; } public Optional details(UUID id) { ContentIdentifier realIdentifier = maskService.realIdentifier(id); if (realIdentifier == null) throw new IllegalStateException("content identifier not found for id '" + id + "'"); ContentProviderSource source = ContentProviderSource.valueOf(realIdentifier.source()); for (DetailService detailService : detailServices) { if (detailService.source() == source) return detailService.details(realIdentifier.id()); } return Optional.empty(); } }