本文整理汇总了Java中java.util.Collections.unmodifiableList方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.unmodifiableList方法的具体用法?Java Collections.unmodifiableList怎么用?Java Collections.unmodifiableList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collections
的用法示例。
在下文中一共展示了Collections.unmodifiableList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkChoices
import java.util.Collections; //导入方法依赖的package包/类
protected Object[] checkChoices(Iterable<T> validChoices, T[] defValueCandidates) {
List<T> lst = new ArrayList<T>();
for (T t : validChoices)
lst.add(t);
T defaultValue = null;
for (T defVal : defValueCandidates) {
if (lst.contains(defVal)) {
defaultValue = defVal;
break;
}
}
if (defaultValue == null) {
defaultValue = lst.get(0);
}
return new Object[] {
Collections.unmodifiableList(lst), defaultValue
};
}
示例2: getAcceptableMediaTypes
import java.util.Collections; //导入方法依赖的package包/类
public static List<MediaType> getAcceptableMediaTypes(Request request)
{
// See: http://docs.oracle.com/javaee/7/api/javax/ws/rs/core/HttpHeaders.html#getAcceptableMediaTypes--
HttpServletRequest rawReq = request.raw();
List<String> values = Collections.list(rawReq.getHeaders("Accept"));
if (values.isEmpty()) {
return Collections.singletonList(MediaType.WILDCARD_TYPE);
}
ArrayList<MediaType> acceptable = new ArrayList();
for (String value : values) {
for (String type : StringUtils.split(value, ',')) {
acceptable.add(MediaType.valueOf(type.trim()));
}
}
MediaTypeHelper.sortByWeight(acceptable);
return Collections.unmodifiableList(acceptable);
}
示例3: getOrderedChildren
import java.util.Collections; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<XMLObject> getOrderedChildren() {
ArrayList<XMLObject> children = new ArrayList<XMLObject>();
if (super.getOrderedChildren() != null) {
children.addAll(super.getOrderedChildren());
}
if (nameID != null) {
children.add(nameID);
}
if (encryptedID != null) {
children.add(encryptedID);
}
if (children.size() == 0) {
return null;
}
return Collections.unmodifiableList(children);
}
示例4: Federation
import java.util.Collections; //导入方法依赖的package包/类
public Federation(List<BtcECKey> publicKeys, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams) {
// Sorting public keys ensures same order of federators for same public keys
// Immutability provides protection unless unwanted modification, thus making the Federation instance
// effectively immutable
this.publicKeys = Collections.unmodifiableList(publicKeys.stream().sorted(BtcECKey.PUBKEY_COMPARATOR).collect(Collectors.toList()));
// using this.publicKeys ensures order in rskPublicKeys
this.rskPublicKeys = Collections.unmodifiableList(this.publicKeys.stream()
.map(BtcECKey::getPubKey)
.map(ECKey::fromPublicOnly)
.collect(Collectors.toList()));
this.creationTime = creationTime;
this.creationBlockNumber = creationBlockNumber;
this.btcParams = btcParams;
// Calculated once on-demand
this.redeemScript = null;
this.p2shScript = null;
this.address = null;
}
示例5: getExtensibleTargets
import java.util.Collections; //导入方法依赖的package包/类
/**
* Get a list of target names in the main build script that are allowed to be
* extended by adding the "depends" attribute definition to them.
* @return list of target names
*/
public List<String> getExtensibleTargets() {
List<String> targets = new ArrayList<String>();
targets.addAll(implementation.getExtensibleTargets());
targets = Collections.unmodifiableList(targets);
return targets;
}
示例6: initialize
import java.util.Collections; //导入方法依赖的package包/类
protected void initialize(Map<String, T> entryMap, Opcodes opcodes) {
if (entryMap == null) throw new NullPointerException("entryMap");
if (this.entryMap != null) throw new IllegalStateException("Already initialized");
this.entryMap = entryMap;
// See: https://github.com/JesusFreke/smali/issues/458
entryNames = Collections.unmodifiableList(new ArrayList<>(entryMap.keySet()));
if (opcodes == null) {
//opcodes = getNewestOpcodes();
for (T entry : entryMap.values()) {
opcodes = OpcodeUtils.getNewestOpcodesNullable(opcodes, entry.getOpcodes());
}
//if (opcodes == null) throw nullOpcodes();
}
resolvedOpcodes = opcodes;
}
示例7: Examples
import java.util.Collections; //导入方法依赖的package包/类
public Examples(Location location, List<Tag> tags, String keyword, String name, String description, TableRow tableHeader, List<TableRow> tableBody) {
super(location);
this.tags = Collections.unmodifiableList(tags);
this.keyword = keyword;
this.name = name;
this.description = description;
this.tableHeader = tableHeader;
this.tableBody = tableBody != null ? Collections.unmodifiableList(tableBody) : null;
}
示例8: add
import java.util.Collections; //导入方法依赖的package包/类
public BlobPath add(String path) {
List<String> paths = new ArrayList<>();
paths.addAll(this.paths);
paths.add(path);
return new BlobPath(Collections.unmodifiableList(paths));
}
示例9: DirList3
import java.util.Collections; //导入方法依赖的package包/类
public DirList3(Entry3[] entries, boolean eof) {
this.entries = Collections.unmodifiableList(Arrays.asList(entries));
this.eof = eof;
}
示例10: getExamples
import java.util.Collections; //导入方法依赖的package包/类
public List<ExampleProcess> getExamples() {
return Collections.unmodifiableList(exampleProcesses);
}
示例11: MultiResponse
import java.util.Collections; //导入方法依赖的package包/类
MultiResponse(List<Response> responses) {
this.responses = Collections.unmodifiableList(responses);
}
示例12: getIntermediateMimetypes
import java.util.Collections; //导入方法依赖的package包/类
public List<String> getIntermediateMimetypes()
{
return Collections.unmodifiableList(intermediateMimetypes);
}
示例13: getSubtypes
import java.util.Collections; //导入方法依赖的package包/类
public List<ItemType> getSubtypes() {
return Collections.unmodifiableList(items);
}
示例14: getChildren
import java.util.Collections; //导入方法依赖的package包/类
@Override
public List<TransformationUtility> getChildren() {
return Collections.unmodifiableList(childrenList);
}
示例15: getMessages
import java.util.Collections; //导入方法依赖的package包/类
public List<MessageEntry> getMessages() {
return Collections.unmodifiableList(messages);
}