@Override public Set<? extends NodePropertiesConfiguration> getNodeConfigurations() throws AppClusterConfigurationException { Set<String> ids = getUniqueStrings("appcluster.nodes", true); Set<NodePropertiesConfiguration> nodes = new LinkedHashSet<NodePropertiesConfiguration>(ids.size()*4/3+1); for(String id : ids) { if( !nodes.add(new NodePropertiesConfiguration(this, id)) ) throw new AssertionError(); } return AoCollections.optimalUnmodifiableSet(nodes); }
/** * Gets an unmodifiable wrapper around this list. * May or may not wrap this list itself. */ public static <E> List<E> unmodifiable(List<E> list) { if(list==null) { // Empty return Collections.emptyList(); } return AoCollections.optimalUnmodifiableList(list); } }
/** * Gets an unmodifiable wrapper around this list. * May or may not wrap this list itself. */ public static <K,V> Map<K,V> unmodifiable(Map<K,V> map) { if(map==null) { // Empty return Collections.emptyMap(); } return AoCollections.optimalUnmodifiableMap(map); } }
static SortedSet<String> getUnmodifiableSortedSet(String[] array, Comparator<Object> collator) { if(array==null || array.length==0) return AoCollections.emptySortedSet(); if(array.length==1) return AoCollections.singletonSortedSet(array[0]); SortedSet<String> sortedSet = new TreeSet<String>(collator); sortedSet.addAll(Arrays.asList(array)); return Collections.unmodifiableSortedSet(sortedSet); }
private ServiceSet( Service template, Set<Service> services ) { this.template = template; this.services = AoCollections.optimalUnmodifiableSet(services); SortedSet<Target> newTargets = new TreeSet<Target>(); for(Service service : services) { newTargets.addAll(service.getTargets()); } this.targets = AoCollections.optimalUnmodifiableSortedSet(newTargets); }
protected JdbcResource(AppCluster cluster, JdbcResourceConfiguration resourceConfiguration, Collection<? extends ResourceNode<?,?>> resourceNodes) throws AppClusterConfigurationException { super(cluster, resourceConfiguration, resourceNodes); this.schemas = AoCollections.unmodifiableCopySet(resourceConfiguration.getSchemas()); this.tableTypes = AoCollections.unmodifiableCopySet(resourceConfiguration.getTableTypes()); this.excludeTables = AoCollections.unmodifiableCopySet(resourceConfiguration.getExcludeTables()); this.noWarnTables = AoCollections.unmodifiableCopySet(resourceConfiguration.getNoWarnTables()); this.prepareSlaves = AoCollections.unmodifiableCopyMap(resourceConfiguration.getPrepareSlaves()); }
this.enabled = cluster.isEnabled() && resourceConfiguration.isEnabled(); this.display = resourceConfiguration.getDisplay(); this.masterRecords = AoCollections.unmodifiableCopySet(resourceConfiguration.getMasterRecords()); this.masterRecordsTtl = resourceConfiguration.getMasterRecordsTtl(); this.type = resourceConfiguration.getType(); newResourceNodes.add(rn); this.resourceNodes = AoCollections.optimalUnmodifiableSet(newResourceNodes); final Set<Nameserver> newEnabledNameservers = new LinkedHashSet<Nameserver>(); for(ResourceNode<?,?> resourceNode : resourceNodes) { if(node.isEnabled()) newEnabledNameservers.addAll(node.getNameservers()); this.enabledNameservers = AoCollections.optimalUnmodifiableSet(newEnabledNameservers); this.synchronizers = AoCollections.optimalUnmodifiableMap(newSynchronizers);
allServices.put( currentZone, AoCollections.optimalUnmodifiableSet(zoneServices) ) != null ) { return AoCollections.optimalUnmodifiableMap(allServices);
throw new IllegalArgumentException("Neither ports nor protocols nor modules provided."); this.ports = AoCollections.unmodifiableCopySet(ports); this.protocols = AoCollections.unmodifiableCopySet(protocols); this.sourcePorts = AoCollections.unmodifiableCopySet(sourcePorts); this.modules = AoCollections.unmodifiableCopySet(modules); if(destinationIPv4 == null && destinationIPv6 == null) { throw new IllegalArgumentException("Neither destinationIPv4 nor destinationIPv6 provided. To match all, use \"0.0.0.0/0\" or \"::/0\"."); this.targets = AoCollections.optimalUnmodifiableSortedSet(newTargets);
protected ResourceNode(Node node, ResourceNodeConfiguration<R,RN> resourceNodeConfiguration) { this.node = node; this.nodeRecords = AoCollections.unmodifiableCopySet(resourceNodeConfiguration.getNodeRecords()); }
@Override public Iterator<String> getParameterNames() { return AoCollections.emptyIterator(); }
@Override public SortedSet<E> headSet(E toElement) { if(ObjectUtils.equals(element, toElement)) return emptySortedSet(); throw new IllegalArgumentException(); }
/** * @param baseName the base name of the default locale's bundle. * @param locales the set of all allowed locales. */ public EditableResourceBundleSet(String baseName, Collection<Locale> locales) { // The locales are sorted by language, country, then variant. SortedSet<Locale> modifiableSet = new TreeSet<Locale>(LocaleComparator.getInstance()); modifiableSet.addAll(locales); this.baseName = baseName; this.locales = AoCollections.optimalUnmodifiableSortedSet(modifiableSet); }
static SortedSet<String> getUnmodifiableSortedSet(Collection<String> collection, Comparator<Object> collator) { if(collection==null || collection.isEmpty()) return AoCollections.emptySortedSet(); if(collection.size()==1) return AoCollections.singletonSortedSet(collection.iterator().next()); SortedSet<String> sortedSet = new TreeSet<String>(collator); sortedSet.addAll(collection); return Collections.unmodifiableSortedSet(sortedSet); }
protected Csync2Resource(AppCluster cluster, Csync2ResourceConfiguration resourceConfiguration, Collection<? extends ResourceNode<?,?>> resourceNodes) throws AppClusterConfigurationException { super(cluster, resourceConfiguration, resourceNodes); this.allowMultiMaster = resourceConfiguration.getAllowMultiMaster(); this.groups = AoCollections.unmodifiableCopySet(resourceConfiguration.getGroups()); }
visited.add(pageRef); nexts.add(pageRef); Iterator<? extends PageReferrer> empty = AoCollections.emptyIterator(); // Java 1.7: Use java.util.Collections.emptyIterator() afters.add(empty);
@Override public SortedSet<E> subSet(E fromElement, E toElement) { if(ObjectUtils.equals(element, fromElement) && ObjectUtils.equals(element, toElement)) return emptySortedSet(); throw new IllegalArgumentException(); }
@Override public Set<Table> getVertices() throws SQLException { Set<Table> vertices = new LinkedHashSet<>(); for(Schema schema : getSchemas().values()) { for(Table table : schema.getTables().values()) { if(tableTypes==null || tableTypes.contains(table.getTableType())) vertices.add(table); } } return AoCollections.optimalUnmodifiableSet(vertices); }
private Country(int since, String[] states) { this.since = since; this.states = AoCollections.optimalUnmodifiableList(Arrays.asList(states)); }
/** * Gets a map view of the resources keyed on String resourceId. * This is for compatibility with JSP EL - it is not a fast implementation. */ public Map<String,? extends Resource<?,?>> getResourceMap() { synchronized(startedLock) { LinkedHashMap<String,Resource<?,?>> map = new LinkedHashMap<String,Resource<?,?>>(resources.size()*4/3+1); for(Resource<?,?> resource : resources) map.put(resource.getId(), resource); return AoCollections.optimalUnmodifiableMap(map); } }