public static ApplicationInstanceReference toApplicationInstanceReference(
            ApplicationId applicationid,
            ServiceMonitor serviceMonitor)
            throws ApplicationIdNotFoundException {

        Set<ApplicationInstanceReference> references = serviceMonitor.getAllApplicationInstanceReferences();
        List<ApplicationInstanceReference> referencesWithId = references.stream()
                .filter(a -> OrchestratorUtil.toApplicationId(a).equals(applicationid))
                .toList();

        if (referencesWithId.size() > 1) {
            String msg = String.format("ApplicationId '%s' was not unique but mapped to '%s'", applicationid, referencesWithId);
            throw new ApplicationIdNotFoundException(msg);
        }

        if (referencesWithId.size() == 0) {
            throw new ApplicationIdNotFoundException();
        }

        return referencesWithId.get(0);
    }
Returns an ApplicationInstanceReference constructed from the serialized format used in the REST API.
orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java