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

The following are Jave code examples for showing how to use unmodifiableCollection() 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: mid-tier   File: AccountRepresentation.java   View Source Code Vote up 5 votes
@ApiModelProperty(
        access = "public",
        name = "transactions",
        value = "the transactions that have taken place for the account.")
public Collection<TransactionRepresentation> getTransactions() {
    if (transactions == null) {
        return null;
    } else {
        return Collections.unmodifiableCollection(transactions);
    }
}
 
Example 2
Project: azure-libraries-for-java   File: SubnetImpl.java   View Source Code Vote up 5 votes
@Override
public Collection<NicIPConfiguration> listNetworkInterfaceIPConfigurations() {
    Collection<NicIPConfiguration> ipConfigs = new ArrayList<>();
    Map<String, NetworkInterface> nics = new TreeMap<>();
    List<IPConfigurationInner> ipConfigRefs = this.inner().ipConfigurations();
    if (ipConfigRefs == null) {
        return ipConfigs;
    }

    for (IPConfigurationInner ipConfigRef : ipConfigRefs) {
        String nicID = ResourceUtils.parentResourceIdFromResourceId(ipConfigRef.id());
        String ipConfigName = ResourceUtils.nameFromResourceId(ipConfigRef.id());
        // Check if NIC already cached
        NetworkInterface nic = nics.get(nicID.toLowerCase());
        if (nic == null) {
            //  NIC not previously found, so ask Azure for it
            nic = this.parent().manager().networkInterfaces().getById(nicID);
        }

        if (nic == null) {
            // NIC doesn't exist so ignore this bad reference
            continue;
        }

        // Cache the NIC
        nics.put(nic.id().toLowerCase(), nic);

        // Get the IP config
        NicIPConfiguration ipConfig = nic.ipConfigurations().get(ipConfigName);
        if (ipConfig == null) {
            // IP config not found, so ignore this bad reference
            continue;
        }

        ipConfigs.add(ipConfig);
    }

    return Collections.unmodifiableCollection(ipConfigs);
}
 
Example 3
Project: incubator-netbeans   File: JavaAntLogger.java   View Source Code Vote up 5 votes
/**
 * Finds source roots corresponding to the apparently active classpath
 * (as reported by logging from Ant when it runs the Java launcher with -cp).
 */
private static Collection<FileObject> getCurrentSourceRootsForClasspath(SessionData data) {
    if (data.classpath == null &&
            data.modulepath == null &&
            data.upgradeModulepath == null) {
        return Collections.emptySet();
    }
    Collection<FileObject> result;
    synchronized (data) {
        result = data.searchSourceRoots;
    }
    if (result == null) {
        result = new LinkedHashSet<>();
        addPath(data.classpath, result, false);
        addPath(data.modulepath, result, true);
        addPath(data.upgradeModulepath, result, true);
        if (data.platformSources != null) {
            result.addAll(Arrays.asList(data.platformSources.getRoots()));
        } else {
            // no platform found. use default one:
            JavaPlatform plat = JavaPlatform.getDefault();
            // in unit tests the default platform may be null:
            if (plat != null) {
                result.addAll(Arrays.asList(plat.getSourceFolders().getRoots()));
            }
        }
        result = Collections.unmodifiableCollection(result);
        synchronized (data) {
            data.searchSourceRoots = result;
        }
    }
    return result;
}
 
Example 4
Project: athena   File: SubnetWebResource.java   View Source Code Vote up 5 votes
/**
 * Changes JsonNode alocPools to a collection of the alocPools.
 *
 * @param allocationPools the allocationPools JsonNode
 * @return a collection of allocationPools
 */
public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
    checkNotNull(allocationPools, JSON_NOT_NULL);
    ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
            .newConcurrentMap();
    Integer i = 0;
    for (JsonNode node : allocationPools) {
        IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
        IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
        AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
        alocplMaps.putIfAbsent(i, alocPls);
        i++;
    }
    return Collections.unmodifiableCollection(alocplMaps.values());
}
 
Example 5
Project: incubator-netbeans   File: JavaOperationsImpl.java   View Source Code Vote up 5 votes
@Override
@NonNull
public Collection<? extends String> getMethodNames(
        final @NonNull String clz,
        final boolean rt,
        final @NullAllowed String returnType,
        final @NullAllowed String... parameterTypes) throws QueryException {
    final List<? extends ExecutableElement> methods = getMethods(clz, null, rt, returnType, parameterTypes);
    final List<String> result = new ArrayList<String>(methods.size());
    for (ExecutableElement method : methods) {
        result.add(method.getSimpleName().toString());
    }
    return Collections.unmodifiableCollection(result);
}
 
Example 6
Project: athena   File: SubnetManager.java   View Source Code Vote up 4 votes
@Override
public Iterable<Subnet> getSubnets() {
    return Collections.unmodifiableCollection(subnetStore.values());
}
 
Example 7
Project: alvisnlp   File: Run.java   View Source Code Vote up 4 votes
public Collection<String> getPropertyKeys() {
	return Collections.unmodifiableCollection(properties.keySet());
}
 
Example 8
Project: bibliome-java-utils   File: AlvisAEAnnotationSet.java   View Source Code Vote up 4 votes
public Collection<TextBound> getTextBound() {
	return Collections.unmodifiableCollection(textBound);
}
 
Example 9
Project: incubator-netbeans   File: BaseNode.java   View Source Code Vote up 4 votes
public synchronized Collection<Property> getProperties() {
    Property[] properties = getSheet().get(Sheet.PROPERTIES).getProperties();
    return Collections.unmodifiableCollection(Arrays.asList(properties));
}
 
Example 10
Project: bibliome-java-utils   File: DocumentSchema.java   View Source Code Vote up 4 votes
public Collection<AnnotationSchema> getAnnotationSchemas() {
	return Collections.unmodifiableCollection(annotationSchemas.values());
}
 
Example 11
Project: incubator-netbeans   File: ProfileSupport.java   View Source Code Vote up 4 votes
Collection<Violation> getViolations() {
    return Collections.unmodifiableCollection(violations);
}
 
Example 12
Project: athena   File: FloatingIpManager.java   View Source Code Vote up 4 votes
@Override
public Collection<FloatingIp> getFloatingIps() {
    return Collections.unmodifiableCollection(floatingIpStore.values());
}
 
Example 13
Project: dubbox-hystrix   File: MultiMessage.java   View Source Code Vote up 4 votes
public Collection removeMessages() {
    Collection result = Collections.unmodifiableCollection(messages);
    messages.clear();
    return result;
}
 
Example 14
Project: apache-tomcat-7.0.73-with-comment   File: SnakeTimer.java   View Source Code Vote up 4 votes
protected static Collection<Snake> getSnakes() {
    return Collections.unmodifiableCollection(snakes.values());
}
 
Example 15
Project: s-store   File: Producer.java   View Source Code Vote up 4 votes
public final Collection<Consumer<U>> getConsumers() {
    return (Collections.unmodifiableCollection(this.consumers));
}
 
Example 16
Project: pgcodekeeper   File: CliArgs.java   View Source Code Vote up 4 votes
@Override
public Collection<DangerStatement> getAllowedDangers() {
    return Collections.unmodifiableCollection(allowedDangers);
}
 
Example 17
Project: bibliome-java-utils   File: CompositeServiceFactory.java   View Source Code Vote up 4 votes
@Override
public Collection<K> supportedServices() {
    return Collections.unmodifiableCollection(factories.keySet());
}
 
Example 18
Project: java-messenger-watchdog   File: MemoryWebsiteRepository.java   View Source Code Vote up 4 votes
@Override
public Collection<Website> findAll() {
  return Collections.unmodifiableCollection(new ArrayList<>(websites));
}
 
Example 19
Project: HCFCore   File: UnmodifiableTrie.java   View Source Code Vote up 4 votes
public Collection<V> values() {
    return Collections.unmodifiableCollection(delegate.values());
}
 
Example 20
Project: foldem   File: Hand.java   View Source Code Vote up 2 votes
/**
 * Obtains an unmodifiable view of the cards within this hand.
 * 
 * @return An unmodifiable view of the cards within this hand.
 */
public Collection<Card> cards() {
	return Collections.unmodifiableCollection(cards);
}