List of usage examples for java.util Collections checkedList
public static <E> List<E> checkedList(List<E> list, Class<E> type)
From source file:io.sidecar.client.SidecarUserClient.java
@SuppressWarnings("unchecked") private List<UserAnswerBucket> postUserBasedQuery(String path, Query query) { try {/* w w w. j a va 2 s . c o m*/ URL endpoint = clientConfig.fullUrlForPath(path); SidecarPostRequest sidecarPostRequest = new SidecarPostRequest.Builder(accessKey.getKeyId(), "", accessKey.getSecret()).withSignatureVersion(ONE).withUrl(endpoint).withPayload(query).build(); SidecarResponse response = sidecarPostRequest.send(); if (response.getStatusCode() == 200) { LOGGER.debug(response.getBody()); return Collections.checkedList(mapper.readValue(response.getBody(), List.class), UserAnswerBucket.class); } else { throw new SidecarClientException(response.getStatusCode(), response.getBody()); } } catch (Exception e) { throw propagate(e); } }
From source file:net.sourceforge.pmd.lang.java.rule.codestyle.LinguisticNamingRule.java
@Override protected Collection<String> defaultSuppressionAnnotations() { return Collections.checkedList(Arrays.asList("java.lang.Override"), String.class); }
From source file:org.aitools.programd.Core.java
/** * Gets the list of replies to some input sentences. Assumes that the * sentences have already had all necessary pre-processing and substitutions * performed./*from w ww .j a v a 2 s .c o m*/ * * @param sentenceList the input sentences * @param userid the userid requesting the replies * @param botid * @return the list of replies to the input sentences */ @SuppressWarnings("boxing") protected List<String> getReplies(List<String> sentenceList, String userid, String botid) { if (sentenceList == null) { return null; } // All replies will be assembled in this ArrayList. List<String> replies = Collections.checkedList(new ArrayList<String>(sentenceList.size()), String.class); // Get the requested bot. Bot bot = this._bots.get(botid); // Ready the that and topic predicates for constructing the match path. List<String> thatSentences = bot.sentenceSplit(this._predicateManager.get("that", 1, userid, botid)); String that = null; if (thatSentences.size() > 0) { that = InputNormalizer.patternFitIgnoreCase(thatSentences.get(thatSentences.size() - 1)); } if (that == null || "".equals(that) || that.equals(this._predicateEmptyDefault)) { that = "*"; } String topic = InputNormalizer.patternFitIgnoreCase(this._predicateManager.get("topic", userid, botid)); if ("".equals(topic) || topic.equals(this._predicateEmptyDefault)) { topic = "*"; } // We might use this to track matching statistics. long time = 0; // Mark the time just before matching starts. time = System.currentTimeMillis(); // Get a reply for each sentence. for (String sentence : sentenceList) { replies.add(getReply(sentence, that, topic, userid, botid)); } // Increment the (static) response count. this._responseCount++; // Produce statistics about the response time. // Mark the time that processing is finished. time = System.currentTimeMillis() - time; // Calculate the average response time. this._totalTime += time; this._avgResponseTime = (float) this._totalTime / (float) this._responseCount; if (this._matchLogger.isDebugEnabled()) { this._matchLogger.debug(String.format("Response %d in %dms. (Average: %.2fms)", this._responseCount, time, this._avgResponseTime)); } // Invoke targeting if appropriate. /* * if (responseCount % TARGET_SKIP == 0) { if (USE_TARGETING) { * Graphmaster.checkpoint(); } } */ // If no replies, return an empty string. if (replies.size() == 0) { replies.add(""); } return replies; }
From source file:org.sventon.model.RepositoryEntry.java
/** * Creates a collection of <code>RepositoryEntry</code> objects based * on given collection of <code>SVNDirEntry</code> instances. * * @param entries Collection of SVNDirEntry. * @param basePath Base repository path for the entries. * @return The collection of entries.//from ww w .jav a 2s. c o m */ public static List<RepositoryEntry> createEntryCollection(final Collection<SVNDirEntry> entries, final String basePath) { final List<RepositoryEntry> dir = Collections.checkedList(new ArrayList<RepositoryEntry>(), RepositoryEntry.class); for (final SVNDirEntry entry : entries) { dir.add(new RepositoryEntry(entry, basePath)); } return dir; }
From source file:org.sventon.util.FileExtensionFilter.java
/** * Filter a given list of entries./* w w w .ja va 2 s. c o m*/ * * @param entries List of entries to filter. * @return List of entries matching given extension. */ public List<DirEntry> filter(final List<DirEntry> entries) { final List<DirEntry> dir = Collections.checkedList(new ArrayList<DirEntry>(), DirEntry.class); for (final DirEntry entry : entries) { final String fileExtension = FilenameUtils.getExtension(entry.getName()).toLowerCase(); if (filterExtension.equals(fileExtension)) { dir.add(entry); } } return dir; }