List of usage examples for java.util Collections unmodifiableSet
public static <T> Set<T> unmodifiableSet(Set<? extends T> s)
From source file:com.haulmont.chile.core.datatypes.Datatypes.java
/** * @return all registered Datatype names. *//* w ww . j av a 2 s. c om*/ public static Set<String> getNames() { return Collections.unmodifiableSet(instance.datatypeByName.keySet()); }
From source file:fr.isima.ponge.wsprotocol.impl.BusinessProtocolImpl.java
public Set<State> getStates() { return Collections.unmodifiableSet(states); }
From source file:org.apache.nifi.processors.standard.RegexAttributesToJSON.java
@Override protected void init(final ProcessorInitializationContext context) { final List<PropertyDescriptor> properties = new ArrayList<>(); properties.add(ATTRIBUTES_REGEX);/*from w ww . j a va 2s . c om*/ properties.add(ATTRIBUTES_STRIP_PREFIX); properties.add(DESTINATION); properties.add(INCLUDE_CORE_ATTRIBUTES); properties.add(NULL_VALUE_FOR_EMPTY_STRING); this.properties = Collections.unmodifiableList(properties); final Set<Relationship> relationships = new HashSet<>(); relationships.add(REL_SUCCESS); relationships.add(REL_FAILURE); this.relationships = Collections.unmodifiableSet(relationships); }
From source file:org.elasticsearch.client.RestClient.java
/** * Replaces the hosts that the client communicates with. * @see HttpHost/*from w ww .j a va2s . co m*/ */ public synchronized void setHosts(HttpHost... hosts) { if (hosts == null || hosts.length == 0) { throw new IllegalArgumentException("hosts must not be null nor empty"); } Set<HttpHost> httpHosts = new HashSet<>(); AuthCache authCache = new BasicAuthCache(); for (HttpHost host : hosts) { Objects.requireNonNull(host, "host cannot be null"); httpHosts.add(host); authCache.put(host, new BasicScheme()); } this.hostTuple = new HostTuple<>(Collections.unmodifiableSet(httpHosts), authCache); this.blacklist.clear(); }
From source file:com.netflix.nicobar.core.archive.PathScriptArchive.java
protected PathScriptArchive(ScriptModuleSpec moduleSpec, Path rootDirPath, Set<String> entries, long createTime) throws IOException { this.moduleSpec = Objects.requireNonNull(moduleSpec, "moduleSpec"); this.rootDirPath = Objects.requireNonNull(rootDirPath, "rootDirPath"); if (!this.rootDirPath.isAbsolute()) throw new IllegalArgumentException("rootPath must be absolute."); this.entryNames = Collections.unmodifiableSet(Objects.requireNonNull(entries, "entries")); this.rootUrl = this.rootDirPath.toUri().toURL(); this.createTime = createTime; }
From source file:dk.netarkivet.harvester.harvesting.report.AbstractHarvestReport.java
/** * Returns the set of domain names/* w ww.ja v a 2 s . c o m*/ * that are contained in hosts-report.txt * (i.e. host names mapped to domains) * * @return a Set of Strings */ @Override public final Set<String> getDomainNames() { return Collections.unmodifiableSet(domainstats.keySet()); }
From source file:com.github.aptd.simulation.TestCLanguageLabels.java
/** * test-case all resource strings// w w w . java 2s.c o m * * @throws IOException throws on io errors */ @Test public void testResourceString() throws IOException { assumeTrue("no languages are defined for checking", !LANGUAGEPROPERY.isEmpty()); final Set<String> l_ignoredlabel = new HashSet<>(); // --- parse source and get label definition final Set<String> l_label = Collections.unmodifiableSet(Files.walk(Paths.get(SEARCHPATH)) .filter(Files::isRegularFile).filter(i -> i.toString().endsWith(".java")).flatMap(i -> { try { final CJavaVistor l_parser = new CJavaVistor(); l_parser.visit(JavaParser.parse(new FileInputStream(i.toFile())), null); return l_parser.labels().stream(); } catch (final IOException l_excpetion) { assertTrue(MessageFormat.format("io error on file [{0}]: {1}", i, l_excpetion.getMessage()), false); return Stream.empty(); } catch (final ParseProblemException l_exception) { // add label build by class path to the ignore list l_ignoredlabel.add(i.toAbsolutePath().toString() // remove path to class directory .replace(FileSystems.getDefault().provider().getPath(SEARCHPATH).toAbsolutePath() .toString(), "") // string starts with path separator .substring(1) // remove file extension .replace(".java", "") // replace separators with dots .replace("/", CLASSSEPARATOR) // convert to lower-case .toLowerCase() // remove package-root name .replace(CCommon.PACKAGEROOT + CLASSSEPARATOR, "")); System.err.println(MessageFormat.format("parsing error on file [{0}]:\n{1}", i, l_exception.getMessage())); return Stream.empty(); } }).collect(Collectors.toSet())); // --- check of any label is found assertFalse("translation labels are empty, check naming of translation method", l_label.isEmpty()); // --- check label towards the property definition if (l_ignoredlabel.size() > 0) System.err.println(MessageFormat.format( "labels that starts with {0} are ignored, because parsing errors are occurred", l_ignoredlabel)); LANGUAGEPROPERY.forEach((k, v) -> { try { final Properties l_property = new Properties(); l_property.load(new FileInputStream(new File(v))); final Set<String> l_parseditems = new HashSet<>(l_label); final Set<String> l_propertyitems = l_property.keySet().parallelStream().map(Object::toString) .collect(Collectors.toSet()); // --- check if all property items are within the parsed labels l_parseditems.removeAll(l_propertyitems); assertTrue(MessageFormat.format( "the following {1,choice,1#key|1<keys} in language [{0}] {1,choice,1#is|1<are} not existing within the language file:\n{2}", k, l_parseditems.size(), StringUtils.join(l_parseditems, ", ")), l_parseditems.isEmpty()); // --- check if all parsed labels within the property item and remove ignored labels l_propertyitems.removeAll(l_label); final Set<String> l_ignoredpropertyitems = l_propertyitems.parallelStream() .filter(j -> l_ignoredlabel.parallelStream().map(j::startsWith).allMatch(l -> false)) .collect(Collectors.toSet()); assertTrue(MessageFormat.format( "the following {1,choice,1#key|1<keys} in language [{0}] {1,choice,1#is|1<are} not existing within the source code:\n{2}", k, l_ignoredpropertyitems.size(), StringUtils.join(l_ignoredpropertyitems, ", ")), l_ignoredpropertyitems.isEmpty()); } catch (final IOException l_exception) { assertTrue(MessageFormat.format("io exception: {0}", l_exception.getMessage()), false); } }); }
From source file:com.zotoh.maedr.cloud.CloudData.java
/** * @return/*from w w w .ja va 2s.co m*/ * @throws JSONException */ public Set<String> listRegions() throws JSONException { JSONObject r = getRegions(); Set<String> rc = ST(); for (Iterator<?> it = r.keys(); it.hasNext();) { rc.add(nsb(it.next())); } return Collections.unmodifiableSet(rc); }
From source file:com.jsen.core.misc.MimeContentRegistryBase.java
/** * Returns all registered MIME content factories that supports explicitly given MIME type. * /* www.j a va2 s . com*/ * @param mimeType MIME content type of which should returned the MIME content factories. * @return All registered MIME content factories that supports explicitly given MIME type. */ public Set<MimeContentFactory> getExplicitMimeContentFactories(String mimeType) { Set<MimeContentFactory> factories = registeredFactories.get(mimeType); return (factories == null) ? new HashSet<MimeContentFactory>() : Collections.unmodifiableSet(factories); }
From source file:com.qwazr.server.configuration.ServerConfiguration.java
protected static Set<String> buildSet(final String value, final String separatorChars, final boolean trim) { if (value == null || value.isEmpty()) return null; final HashSet<String> set = new HashSet<>(); fillStringListProperty(value, separatorChars, trim, set::add); return Collections.unmodifiableSet(set); }