class ImmutableTopicPathPlaceholder implements TopicPathPlaceholder {

    @Override
    public Optional<String> resolve(final TopicPath topicPath, final String placeholder) {
        ConditionChecker.argumentNotEmpty(placeholder, "placeholder");
        switch (placeholder) {
            case NAMESPACE_PLACEHOLDER:
                return Optional.of(topicPath.getNamespace());
            case ENTITYID_PLACEHOLDER:
                return Optional.of(topicPath.getId());
            case GROUP_PLACEHOLDER:
                return Optional.of(topicPath.getGroup().getName());
            case CHANNEL_PLACEHOLDER:
                return Optional.of(topicPath.getChannel().getName());
            case CRITERION_PLACEHOLDER:
                return Optional.of(topicPath.getCriterion().getName());
            case ACTION_PLACEHOLDER:
                return topicPath.getAction().map(TopicPath.Action::getName);
            case SUBJECT_PLACEHOLDER:
                return topicPath.getSubject();
            case ACTION_OR_SUBJECT_PLACEHOLDER:
                // treat action-subject as synonyms:
                return Optional.ofNullable(
                        topicPath.getSubject()
                                .orElseGet(() ->
                                        topicPath.getAction().map(TopicPath.Action::getName).orElse(null)
                                )
                );
            case FULL_PLACEHOLDER:
                return Optional.of(topicPath.getPath());
            default:
                return Optional.empty();
        }
    }

    private  ImmutableTopicPathPlaceholder();

}