java.util.List#copyOf ( )源码实例Demo

下面列出了java.util.List#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: vespa   文件: HostSpec.java
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");
}
 
源代码2 项目: presto   文件: PageBuilder.java
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);
        }
    }
}
 
源代码3 项目: Bytecoder   文件: ClassSpecializer.java
/**
 * 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;
}
 
源代码4 项目: VocabHunter   文件: WordModel.java
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);
}
 
源代码5 项目: crate   文件: GroupHashAggregate.java
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;
}
 
源代码6 项目: vespa   文件: SessionPreparer.java
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);
}
 
源代码7 项目: lucene-solr   文件: CustomAnalyzerConfig.java
/**
 * Returns TokenFilters configurations.
 */
List<ComponentConfig> getTokenFilterConfigs() {
  return List.copyOf(tokenFilterConfigs);
}
 
源代码8 项目: VocabHunter   文件: AppenderForTesting.java
public List<String> getMessages() {
    return List.copyOf(messages);
}
 
源代码9 项目: tutorials   文件: CopyListServiceUnitTest.java
@Test(expected = UnsupportedOperationException.class)
public void whenModifyCopyOfList_thenThrowsException() {
    List<Integer> copyList = List.copyOf(Arrays.asList(1, 2, 3, 4));
}
 
源代码10 项目: vespa   文件: RoutingPolicies.java
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;
}
 
源代码11 项目: VocabHunter   文件: AnalysisResult.java
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);
}
 
源代码12 项目: presto   文件: InMemoryRecordSet.java
private Builder(Collection<Type> types)
{
    this.types = List.copyOf(requireNonNull(types, "types is null"));
    checkArgument(!this.types.isEmpty(), "types is empty");
}
 
源代码13 项目: gocd   文件: DefaultPluginRegistry.java
@Override
public List<GoPluginDescriptor> plugins() {
    return List.copyOf(idToDescriptorMap.values());
}
 
源代码14 项目: vespa   文件: LoadBalancerList.java
private LoadBalancerList(Collection<LoadBalancer> loadBalancers) {
    this.loadBalancers = List.copyOf(Objects.requireNonNull(loadBalancers, "loadBalancers must be non-null"));
}
 
源代码15 项目: lucene-solr   文件: Analysis.java
/**
 * Returns attributes of this token.
 */
public List<TokenAttribute> getAttributes() {
  return List.copyOf(attributes);
}
 
源代码16 项目: crate   文件: JoinUsing.java
public JoinUsing(List<String> columns) {
    if (columns.isEmpty()) {
        throw new IllegalArgumentException("columns must not be empty");
    }
    this.columns = List.copyOf(columns);
}
 
源代码17 项目: vespa   文件: ZoneFilterMock.java
@Override
public List<? extends ZoneApi> zones() {
    return List.copyOf(zones);
}
 
源代码18 项目: tutorials   文件: Java10FeaturesUnitTest.java
@Test(expected = UnsupportedOperationException.class)
public void whenModifyCopyOfList_thenThrowsException() {
    List<Integer> copyList = List.copyOf(someIntList);
    copyList.add(4);
}
 
源代码19 项目: vespa   文件: FilterTableLineEditor.java
private FilterTableLineEditor(List<String> wantedRules) {
    this.wantedRules = List.copyOf(wantedRules);
}
 
源代码20 项目: phoenicis   文件: UiSetupWizardImplementation.java
/**
 * 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));
}