List of usage examples for java.util Collections unmodifiableList
public static <T> List<T> unmodifiableList(List<? extends T> list)
From source file:Main.java
/** * Functions as per {@link Collections#unmodifiableList(List)} with the exception that if the * given list is null, this method will return an unmodifiable empty list as per * {@link Collections#emptyList()}.// www .j ava 2 s . com * * @param list the list for which an unmodifiable view is to be returned * @return an unmodifiable view of the specified list, or an unmodifiable empty list if the * given list is null */ public static <T> List<T> unmodifiableListNullSafe(List<? extends T> list) { if (list == null) { return Collections.emptyList(); } return Collections.unmodifiableList(list); }
From source file:org.apache.nutch.storage.local.CustomDaoFactory.java
public List<Dao<?, ?>> getCreatedDaos() { synchronized (registredDaos) { return Collections.unmodifiableList(registredDaos); } }
From source file:net.dv8tion.jda.core.utils.cache.impl.AbstractCacheView.java
@Override public List<T> asList() { ArrayList<T> list = new ArrayList<>(elements.size()); elements.forEachValue(list::add);// ww w . ja v a 2 s .co m return Collections.unmodifiableList(list); }
From source file:com.imhasan.beingjava.test.ImageController.java
private List<File> getFilesFromDirectory(String directory) { File folder = new File(directory); File[] listOfFiles = folder.listFiles(); List<File> files = new ArrayList<>(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { if (validateFile(listOfFiles[i].getName())) { files.add(listOfFiles[i]); }//from www. j a va 2 s. c o m } } return Collections.unmodifiableList(files); }
From source file:de.th.wildau.dsc.sne.webserver.WebServer.java
/** * Web server / main constructor.//from w ww . j a va2 s. c om * * @param startArguments */ public WebServer(String[] startArguments) { loadConfiguration(startArguments); Log.debug(Configuration.getInstance().toString()); Log.debug("Information about the OS: " + System.getProperty("os.name") + " - " + System.getProperty("os.version") + " - " + System.getProperty("os.arch")); if (Configuration.getConfig().getProxyHost() != null) { Log.debug("setup proxy configuration"); System.setProperty("http.proxyHost", Configuration.getConfig().getProxyHost()); System.setProperty("http.proxyPort", String.valueOf(Configuration.getConfig().getProxyPort())); } Log.debug("find supported scripting languages"); supportedScriptLanguages = Collections.unmodifiableList(ScriptExecutor.getSupportedScriptLanguages()); Log.debug("Supported Script Languages " + Arrays.toString(supportedScriptLanguages.toArray())); Log.info("instantiating web server"); try { ServerSocket server = new ServerSocket(Configuration.getConfig().getServerPort()); Log.debug("bound port " + Configuration.getConfig().getServerPort()); int corePoolSize = Runtime.getRuntime().availableProcessors(); int maxPoolSize = (2 * corePoolSize) + 1; Log.debug("core/max pool size: " + corePoolSize + "/" + maxPoolSize); LinkedBlockingQueue<Runnable> workerQueue = new LinkedBlockingQueue<Runnable>(); long keepAliveTime = 30; /* * keepAliveTime - If the pool currently has more than corePoolSize * threads, excess threads will be terminated if they have been idle * for more than the keepAliveTime. */ ThreadPoolExecutor threadPool = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS, workerQueue); threadPool.prestartAllCoreThreads(); Socket socket = null; while (true) { try { socket = server.accept(); Log.info(socket.getInetAddress().getHostName() + " client request"); threadPool.execute(new HttpHandler(socket)); Log.debug("current threads: " + threadPool.getActiveCount()); } catch (final IOException ex) { Log.error("Connection failed!", ex); } catch (final RejectedExecutionException ex) { // XXX [sne] RejectedExecutionException // http://stackoverflow.com/questions/1519725/why-does-executors-newcachedthreadpool-throw-java-util-concurrent-rejectedexecut // http://www.javamex.com/tutorials/threads/thread_pools_queues.shtml // http://stackoverflow.com/questions/2001086/how-to-make-threadpoolexecutors-submit-method-block-if-it-is-saturated Log.error("RejectedExecutionException", ex); socket.close(); } catch (final Exception ex) { Log.fatal("Unknown error!", ex); } } } catch (final IOException ex) { Log.fatal("Can not start the server!", ex); System.err.println("Can not start the server! " + ex.getMessage()); } catch (final Exception ex) { Log.fatal("Unknown error!", ex); } }
From source file:net.modelbased.sensapp.acceptance.driver.data.SensorData.java
public List<Event> getEvents() { return Collections.unmodifiableList(events); }
From source file:org.jasig.cas.validation.ImmutableAssertionImpl.java
public List<Authentication> getChainedAuthentications() { return Collections.unmodifiableList(this.principals); }
From source file:com.htmlhifive.pitalium.core.selenium.PtlCapabilities.java
/** * Capability????/*w ww .ja v a 2 s.c o m*/ * * @return Capability? */ public static List<PtlCapabilities[]> readCapabilities() { synchronized (PtlCapabilities.class) { if (capabilities != null) { return capabilities; } String filePath = PtlTestConfig.getInstance().getEnvironment().getCapabilitiesFilePath(); List<Map<String, Object>> maps = readCapabilitiesFromFileOrResources(filePath); LOG.debug("Capabilities loaded. (size: {})", maps.size()); LOG.trace("Capabilities: {}", maps); List<PtlCapabilities[]> result = new ArrayList<PtlCapabilities[]>(maps.size()); for (Map<String, Object> map : maps) { PtlCapabilities[] array = { new PtlCapabilities(map) }; result.add(array); } capabilities = Collections.unmodifiableList(result); return capabilities; } }
From source file:org.cloudfoundry.client.lib.archive.ZipApplicationArchive.java
private List<Entry> adaptZipEntries(ZipFile zipFile) { List<Entry> entries = new ArrayList<Entry>(); Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { entries.add(new EntryAdapter(zipEntries.nextElement())); }/*from ww w . j a v a 2 s . c om*/ return Collections.unmodifiableList(entries); }
From source file:com.unboundid.scim2.common.messages.PatchRequest.java
/** * Create a new Patch Operation Request. * * @param operations The list of operations to include. */// w w w . j ava 2s . c o m @JsonCreator public PatchRequest( @JsonProperty(value = "Operations", required = true) final List<PatchOperation> operations) { this.operations = Collections.unmodifiableList(operations); }