// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.pagetemplates.model; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * A choice between different possible mapping functions of a set of values to a set of placeholder ids. * A resolution of this choice consists of choosing a unique value for each placeholder id * (hence a map choice is valid iff there are at least as many values as placeholder ids). *
* Each unique set of mappings (pairs) from values to placeholder ids is a separate possible
* alternative of this choice. The alternatives are not listed explicitly but are generated as needed.
*
* @author bratseth
*/
public class MapChoice extends AbstractChoice {
private List> values=new ArrayList<>();
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean isChoiceBetween(Class pageTemplateModelElementClass) {
List
> values() { return values; }
@Override
public void freeze() {
if (isFrozen()) return;
super.freeze();
placeholderIds=Collections.unmodifiableList(placeholderIds);
values=Collections.unmodifiableList(values);
}
/** Accepts a visitor to this structure */
@Override
public void accept(PageTemplateVisitor visitor) {
visitor.visit(this);
for (List