Java Code Examples for java.util.List#copyOf()

The following examples show how to use java.util.List#copyOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassSpecializer.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor for this class specializer.
 * @param topClass type mirror for T
 * @param keyType type mirror for K
 * @param metaType type mirror for S
 * @param baseConstructorType principal constructor type
 * @param sdAccessor the method used to get the speciesData
 * @param sdFieldName the name of the species data field, inject the speciesData object
 * @param transformMethods optional list of transformMethods
 */
protected ClassSpecializer(Class<T> topClass,
                           Class<K> keyType,
                           Class<S> metaType,
                           MethodType baseConstructorType,
                           MemberName sdAccessor,
                           String sdFieldName,
                           List<MemberName> transformMethods) {
    this.topClass = topClass;
    this.keyType = keyType;
    this.metaType = metaType;
    this.sdAccessor = sdAccessor;
    this.transformMethods = List.copyOf(transformMethods);
    this.sdFieldName = sdFieldName;
    this.baseConstructorType = baseConstructorType.changeReturnType(void.class);
    this.factory = makeFactory();
    K tsk = topSpeciesKey();
    S topSpecies = null;
    if (tsk != null && topSpecies == null) {
        // if there is a key, build the top species if needed:
        topSpecies = findSpecies(tsk);
    }
    this.topSpecies = topSpecies;
}
 
Example 2
Source File: PageBuilder.java    From presto with Apache License 2.0 6 votes vote down vote up
private PageBuilder(int initialExpectedEntries, int maxPageBytes, List<? extends Type> types, Optional<BlockBuilder[]> templateBlockBuilders)
{
    this.types = List.copyOf(requireNonNull(types, "types is null"));

    pageBuilderStatus = new PageBuilderStatus(maxPageBytes);
    blockBuilders = new BlockBuilder[types.size()];

    if (templateBlockBuilders.isPresent()) {
        BlockBuilder[] templates = templateBlockBuilders.get();
        checkArgument(templates.length == types.size(), "Size of templates and types should match");
        for (int i = 0; i < blockBuilders.length; i++) {
            blockBuilders[i] = templates[i].newBlockBuilderLike(pageBuilderStatus.createBlockBuilderStatus());
        }
    }
    else {
        for (int i = 0; i < blockBuilders.length; i++) {
            blockBuilders[i] = types.get(i).createBlockBuilder(pageBuilderStatus.createBlockBuilderStatus(), initialExpectedEntries);
        }
    }
}
 
Example 3
Source File: HostSpec.java    From vespa with Apache License 2.0 6 votes vote down vote up
private HostSpec(String hostname,
                 List<String> aliases,
                 NodeResources realResources,
                 NodeResources advertisedResurces,
                 NodeResources requestedResources,
                 Optional<ClusterMembership> membership,
                 Optional<Version> version,
                 Optional<NetworkPorts> networkPorts,
                 Optional<DockerImage> dockerImageRepo) {
    if (hostname == null || hostname.isEmpty()) throw new IllegalArgumentException("Hostname must be specified");
    this.hostname = hostname;
    this.aliases = List.copyOf(aliases);
    this.realResources = Objects.requireNonNull(realResources);
    this.advertisedResources = Objects.requireNonNull(advertisedResurces);
    this.requestedResources = Objects.requireNonNull(requestedResources, "RequestedResources cannot be null");
    this.membership = Objects.requireNonNull(membership);
    this.version = Objects.requireNonNull(version, "Version cannot be null but can be empty");
    this.networkPorts = Objects.requireNonNull(networkPorts, "Network ports cannot be null but can be empty");
    this.dockerImageRepo = Objects.requireNonNull(dockerImageRepo, "Docker image repo cannot be null but can be empty");
}
 
Example 4
Source File: WordModel.java    From VocabHunter with Apache License 2.0 5 votes vote down vote up
public WordModel(final int sequenceNo, final String word, final List<Integer> lineNos, final int useCount, final WordState state, final String note) {
    this.lineNos = List.copyOf(lineNos);
    this.useCount = useCount;
    this.identifier = new SimpleStringProperty(word);
    this.sequenceNo = sequenceNo;
    this.state = new SimpleObjectProperty<>(state);
    this.note = new SimpleStringProperty(note);
}
 
Example 5
Source File: GroupHashAggregate.java    From crate with Apache License 2.0 5 votes vote down vote up
public GroupHashAggregate(LogicalPlan source, List<Symbol> groupKeys, List<Function> aggregates, long numExpectedRows) {
    super(source);
    this.numExpectedRows = numExpectedRows;
    this.aggregates = List.copyOf(new LinkedHashSet<>(aggregates));
    this.outputs = Lists2.concat(groupKeys, this.aggregates);
    this.groupKeys = groupKeys;
}
 
Example 6
Source File: RoutingPolicies.java    From vespa with Apache License 2.0 4 votes vote down vote up
private LoadBalancerAllocation(ApplicationId application, ZoneId zone, List<LoadBalancer> loadBalancers,
                               DeploymentSpec deploymentSpec) {
    this.deployment = new DeploymentId(application, zone);
    this.loadBalancers = List.copyOf(loadBalancers);
    this.deploymentSpec = deploymentSpec;
}
 
Example 7
Source File: AnalysisResult.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public AnalysisResult(final String name, final List<WordUse> orderedUses, final List<String> lines) {
    this.name = name;
    this.orderedUses = List.copyOf(orderedUses);
    this.lines = List.copyOf(lines);
}
 
Example 8
Source File: InMemoryRecordSet.java    From presto with Apache License 2.0 4 votes vote down vote up
private Builder(Collection<Type> types)
{
    this.types = List.copyOf(requireNonNull(types, "types is null"));
    checkArgument(!this.types.isEmpty(), "types is empty");
}
 
Example 9
Source File: DefaultPluginRegistry.java    From gocd with Apache License 2.0 4 votes vote down vote up
@Override
public List<GoPluginDescriptor> plugins() {
    return List.copyOf(idToDescriptorMap.values());
}
 
Example 10
Source File: CopyListServiceUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void whenModifyCopyOfList_thenThrowsException() {
    List<Integer> copyList = List.copyOf(Arrays.asList(1, 2, 3, 4));
}
 
Example 11
Source File: AppenderForTesting.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public List<String> getMessages() {
    return List.copyOf(messages);
}
 
Example 12
Source File: LoadBalancerList.java    From vespa with Apache License 2.0 4 votes vote down vote up
private LoadBalancerList(Collection<LoadBalancer> loadBalancers) {
    this.loadBalancers = List.copyOf(Objects.requireNonNull(loadBalancers, "loadBalancers must be non-null"));
}
 
Example 13
Source File: Analysis.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Returns attributes of this token.
 */
public List<TokenAttribute> getAttributes() {
  return List.copyOf(attributes);
}
 
Example 14
Source File: JoinUsing.java    From crate with Apache License 2.0 4 votes vote down vote up
public JoinUsing(List<String> columns) {
    if (columns.isEmpty()) {
        throw new IllegalArgumentException("columns must not be empty");
    }
    this.columns = List.copyOf(columns);
}
 
Example 15
Source File: ZoneFilterMock.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public List<? extends ZoneApi> zones() {
    return List.copyOf(zones);
}
 
Example 16
Source File: CustomAnalyzerConfig.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Returns TokenFilters configurations.
 */
List<ComponentConfig> getTokenFilterConfigs() {
  return List.copyOf(tokenFilterConfigs);
}
 
Example 17
Source File: Java10FeaturesUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void whenModifyCopyOfList_thenThrowsException() {
    List<Integer> copyList = List.copyOf(someIntList);
    copyList.add(4);
}
 
Example 18
Source File: FilterTableLineEditor.java    From vespa with Apache License 2.0 4 votes vote down vote up
private FilterTableLineEditor(List<String> wantedRules) {
    this.wantedRules = List.copyOf(wantedRules);
}
 
Example 19
Source File: SessionPreparer.java    From vespa with Apache License 2.0 4 votes vote down vote up
private List<ContainerEndpoint> readEndpointsIfNull(List<ContainerEndpoint> endpoints) {
    if (endpoints == null) { // endpoints are only set when prepared via HTTP
        endpoints = this.containerEndpointsCache.read(applicationId);
    }
    return List.copyOf(endpoints);
}
 
Example 20
Source File: UiSetupWizardImplementation.java    From phoenicis with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Displays a showMenuStep so that the user can make a choice
 *
 * @param textToShow a text that will be shown
 * @param menuItems a list containing the elements of the showMenuStep
 * @param defaultValue item which is selected by default
 * @return the value the user entered (as string)
 */
@Override
public MenuItem menu(String textToShow, List<String> menuItems, String defaultValue) {
    final List<String> copiedMenuItems = List.copyOf(menuItems);
    return messageSender
            .runAndWait(message -> setupUi.showMenuStep(message, textToShow, copiedMenuItems, defaultValue));
}