Java Code Examples for java.util.Collections.unmodifiableList()

The following are Jave code examples for showing how to use unmodifiableList() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: org.alloytools.alloy   File: A4Preferences.java   View Source Code Vote up 6 votes
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
	};
}
 
Example 2
Project: dcmrs-broker   File: HttpUtil.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: lams   File: NameIDMappingResponseImpl.java   View Source Code Vote up 6 votes
/** {@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);
}
 
Example 4
Project: rskj   File: Federation.java   View Source Code Vote up 6 votes
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;
}
 
Example 5
Project: incubator-netbeans   File: AntBuildExtender.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 6
Project: multidexlib2   File: AbstractMultiDexContainer.java   View Source Code Vote up 5 votes
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;
}
 
Example 7
Project: kheera-testrunner-android   File: Examples.java   View Source Code Vote up 5 votes
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;
}
 
Example 8
Project: Elasticsearch   File: BlobPath.java   View Source Code Vote up 4 votes
public BlobPath add(String path) {
    List<String> paths = new ArrayList<>();
    paths.addAll(this.paths);
    paths.add(path);
    return new BlobPath(Collections.unmodifiableList(paths));
}
 
Example 9
Project: hadoop   File: READDIR3Response.java   View Source Code Vote up 4 votes
public DirList3(Entry3[] entries, boolean eof) {
  this.entries = Collections.unmodifiableList(Arrays.asList(entries));
  this.eof = eof;
}
 
Example 10
Project: rapidminer   File: OperatorDocumentation.java   View Source Code Vote up 4 votes
public List<ExampleProcess> getExamples() {
	return Collections.unmodifiableList(exampleProcesses);
}
 
Example 11
Project: pcloud-networking-java   File: MultiResponse.java   View Source Code Vote up 4 votes
MultiResponse(List<Response> responses) {
    this.responses = Collections.unmodifiableList(responses);
}
 
Example 12
Project: alfresco-repository   File: ComplexContentTransformer.java   View Source Code Vote up 4 votes
public List<String> getIntermediateMimetypes()
{
   return Collections.unmodifiableList(intermediateMimetypes);
}
 
Example 13
Project: AptSpring   File: ItemType.java   View Source Code Vote up 4 votes
public List<ItemType> getSubtypes() {
  return Collections.unmodifiableList(items);
}
 
Example 14
Project: butterfly   File: TransformationUtilityLoop.java   View Source Code Vote up 4 votes
@Override
public List<TransformationUtility> getChildren() {
    return Collections.unmodifiableList(childrenList);
}
 
Example 15
Project: ForgeHax   File: CustomMessageEntry.java   View Source Code Vote up 4 votes
public List<MessageEntry> getMessages() {
    return Collections.unmodifiableList(messages);
}
 
Example 16
Project: membrane-spring-boot-starter   File: PathResolver.java   View Source Code Vote up 4 votes
List<String> regexPaths() {
    return Collections.unmodifiableList(regexPaths);
}
 
Example 17
Project: INFOotball   File: SimpleListAdapter.java   View Source Code Vote up 4 votes
public void set(List<T> items){
    this.items = Collections.unmodifiableList(new ArrayList<>(items));
    notifyDataSetChanged();
}
 
Example 18
Project: GitHub   File: ClassMetaData.java   View Source Code Vote up 4 votes
public List<VariableElement> getIndexedFields() {
    return Collections.unmodifiableList(indexedFields);
}
 
Example 19
Project: monarch   File: CompositeGroupJunction.java   View Source Code Vote up 2 votes
/**
 * 
 * @return List containing the filter evaluatable Composite Comparison conditions ( equi join
 *         conditions across the regions)
 */
List getFilterableCCList() {
  // return unmodifiable copy
  return Collections.unmodifiableList(this.filterableCC);
}
 
Example 20
Project: twichat   File: JsonArray.java   View Source Code Vote up 2 votes
/**
 * Returns a list of the values in this array in document order. The returned list is backed by
 * this array and will reflect subsequent changes. It cannot be used to modify this array.
 * Attempts to modify the returned list will result in an exception.
 *
 * @return a list of the values in this array
 */
public List<JsonValue> values() {
  return Collections.unmodifiableList( values );
}