List of usage examples for java.util Collections checkedList
public static <E> List<E> checkedList(List<E> list, Class<E> type)
From source file:es.tid.fiware.rss.dao.impl.PricePointDaoImpl.java
/** * Method executes HQL query.//from w w w.j a va 2 s . com * * @param hql * String with HQL query * @return resultList */ private List<BmPricePoint> listPricePointQuery(final String hql) { PricePointDaoImpl.LOGGER.debug(hql); // @SuppressWarnings("rawtypes") List list = getHibernateTemplate().find(hql); // @SuppressWarnings("unchecked") List<BmPricePoint> resultList = Collections.checkedList(list, BmPricePoint.class); return resultList; }
From source file:es.upm.fiware.rss.dao.impl.DbeTransactionDaoImpl.java
/** * Method executes HQL query./*from w w w .j a v a2s. co m*/ * * @param hql * String with HQL query * @return resultList */ private List<DbeTransaction> listDbeTransactionQuery(final String hql) { DbeTransactionDaoImpl.LOGGER.debug("listDbeTransactionQuery hql-->" + hql); List<DbeTransaction> resultList; try { List list = this.getSession().createQuery(hql).list(); resultList = Collections.checkedList(list, DbeTransaction.class); } catch (Exception e) { DbeTransactionDaoImpl.LOGGER.error("Error db", e); return null; } return resultList; }
From source file:es.tid.fiware.rss.dao.impl.DbeTransactionDaoImpl.java
@Override public List<DbeTransaction> getTransactionByTxPbCorrelationId(String pbCorrelationId) { String hql = "from DbeTransaction as trans where trans.txPbCorrelationId=?"; List<DbeTransaction> resultList = null; try {/*w ww .ja va 2s. com*/ List list = getHibernateTemplate().find(hql, pbCorrelationId); resultList = Collections.checkedList(list, DbeTransaction.class); } catch (Exception e) { DbeTransactionDaoImpl.LOGGER.error("Error db", e); return null; } return resultList; }
From source file:edu.rit.flick.DefaultFlickFile.java
@Override public File inflate(final Configuration configuration, final File fileIn, final File fileOut) { try {// ww w.j a v a 2s . c om if (!getDefaultDeflatedExtension().endsWith(Files.getFileExtension(fileIn.getName()))) { final File decompressedFile = archiveFile(fileIn, true); if (decompressedFile != null && configuration.getFlag(DELETE_FLAG)) if (!FileUtils.deleteQuietly(fileIn)) System.err.printf(FILE_COULD_NOT_BE_DELETED_WARNING_FORMAT, fileIn.getPath()); return decompressedFile; } final LongAdder unzippedContentsSize = new LongAdder(); final long inputFileSize = FileUtils.sizeOf(fileIn); final long t0 = System.currentTimeMillis(); flickFile.extractAll(fileOut.getPath()); final RandomAccessFile raf = new RandomAccessFile(flickFile.getFile(), InternalZipConstants.READ_MODE); final HeaderReader hr = new HeaderReader(raf); final ZipModel zm = hr.readAllHeaders(); final CentralDirectory centralDirectory = zm.getCentralDirectory(); @SuppressWarnings("unchecked") final List<FileHeader> fhs = Collections.checkedList(centralDirectory.getFileHeaders(), FileHeader.class); final List<File> files = fhs.stream().map(fh -> { final File file = FileUtils.getFile(fileOut.getPath(), File.separator, fh.getFileName()); unzippedContentsSize.add(file.length()); return file; }).collect(Collectors.toList()); if (!configuration.getFlag(KEEP_ZIPPED_FLAG)) // Traverse directory and look for files to decompress for (final File file : files) { File decompressedFile = null; if (!file.isDirectory()) decompressedFile = archiveFile(file, false); if (decompressedFile != null) { unzippedContentsSize.add(-FileUtils.sizeOf(file)); unzippedContentsSize.add(FileUtils.sizeOf(decompressedFile)); file.delete(); } } raf.close(); if (configuration.getFlag(DELETE_FLAG)) if (!FileUtils.deleteQuietly(fileIn)) System.err.printf(FILE_COULD_NOT_BE_DELETED_WARNING_FORMAT, fileIn.getPath()); final double overallTime = (System.currentTimeMillis() - t0) / 1000d; if (configuration.getFlag(VERBOSE_FLAG)) { // Get the percent deflation on the compressed file final double percDeflated = 100 * unzippedContentsSize.doubleValue() / inputFileSize; System.out.printf(VERBOSE_DECOMPRESSION_INFO_FORMAT, fileIn.getName(), overallTime, percDeflated); } } catch (final Exception e) { e.printStackTrace(); } return fileOut; }
From source file:io.sidecar.client.SidecarUserClient.java
@SuppressWarnings("unchecked") public List<UUID> getGroupMembers(UUID groupId) { try {/*from w ww. j a v a2 s .c o m*/ URL endpoint = clientConfig .fullUrlForPath("/rest/v1/provision/group/" + encode(groupId.toString()) + "/members"); SidecarGetRequest sidecarGetRequest = new SidecarGetRequest.Builder(accessKey.getKeyId(), "", accessKey.getSecret()).withSignatureVersion(ONE).withUrl(endpoint).build(); SidecarResponse response = sidecarGetRequest.send(); if (response.getStatusCode() == 200) { return Collections.checkedList(mapper.readValue(response.getBody(), List.class), UUID.class); } else { throw new SidecarClientException(response.getStatusCode(), response.getBody()); } } catch (Exception e) { throw propagate(e); } }
From source file:io.sidecar.client.SidecarUserClient.java
@SuppressWarnings({ "unchecked", "unused" }) public List<UUID> getGroupsForUser(String emailAddress) { try {/*from w ww. j av a 2 s .com*/ URL endpoint = clientConfig .fullUrlForPath("/rest/v1/provision/user/" + encode(emailAddress) + "/groups"); SidecarGetRequest sidecarGetRequest = new SidecarGetRequest.Builder(accessKey.getKeyId(), "", accessKey.getSecret()).withSignatureVersion(ONE).withUrl(endpoint).build(); SidecarResponse response = sidecarGetRequest.send(); if (response.getStatusCode() == 200) { return Collections.checkedList(mapper.readValue(response.getBody(), List.class), UUID.class); } else { throw new SidecarClientException(response.getStatusCode(), response.getBody()); } } catch (Exception e) { throw propagate(e); } }
From source file:io.sidecar.client.SidecarUserClient.java
@SuppressWarnings("unchecked") public List<Device> getDevicesForUser() { try {// w ww . ja v a 2s .c om URL endpoint = clientConfig.fullUrlForPath("/rest/v1/provision/user/devices"); SidecarGetRequest sidecarPostRequest = new SidecarGetRequest.Builder(accessKey.getKeyId(), "", accessKey.getSecret()).withSignatureVersion(ONE).withUrl(endpoint).build(); SidecarResponse response = sidecarPostRequest.send(); // check for an OK response code if (response.getStatusCode() == 200) { return Collections.checkedList(mapper.readValue(response.getBody(), java.util.List.class), Device.class); } else { throw new SidecarClientException(response.getStatusCode(), response.getBody()); } } catch (Exception e) { throw propagate(e); } }
From source file:es.tid.fiware.rss.dao.impl.DbeTransactionDaoImpl.java
/** * Method executes HQL query./* www.j a va2 s .c o m*/ * * @param hql * String with HQL query * @return resultList */ private List<DbeTransaction> listDbeTransactionQuery(final String hql) { DbeTransactionDaoImpl.LOGGER.debug("listDbeTransactionQuery hql-->" + hql); List list = getHibernateTemplate().find(hql); List<DbeTransaction> resultList = Collections.checkedList(list, DbeTransaction.class); if (resultList != null) { DbeTransactionDaoImpl.LOGGER.debug("there is something to return"); } return resultList; }
From source file:io.sidecar.client.SidecarUserClient.java
@SuppressWarnings("unchecked") public List<NotificationRule> getNotificationRules() { try {//w ww .j a v a2s .c om URL endpoint = clientConfig.fullUrlForPath("/rest/v1/provision/user/notifications/rules"); SidecarGetRequest sidecarPostRequest = new SidecarGetRequest.Builder(accessKey.getKeyId(), "", accessKey.getSecret()).withSignatureVersion(ONE).withUrl(endpoint).build(); SidecarResponse response = sidecarPostRequest.send(); // check for an OK response code if (response.getStatusCode() == 200) { return Collections.checkedList(mapper.readValue(response.getBody(), java.util.List.class), NotificationRule.class); } else { throw new SidecarClientException(response.getStatusCode(), response.getBody()); } } catch (Exception e) { throw propagate(e); } }
From source file:org.openlmis.fulfillment.web.BaseWebIntegrationTest.java
<T> List<T> getPageContent(Page page, Class<T> type) { List content = page.getContent(); if (isEmpty(content)) { // nothing to do return Collections.emptyList(); }/*from www . j a va 2 s .c om*/ if (type.isInstance(content.get(0))) { // content contains instances of the given type return Collections.checkedList(content, type); } if (content.get(0) instanceof Map) { // jackson does not convert json to correct type // instead it use default operation and objects are // represented by Map // We have to do manually convert map to the given type =( ObjectMapper mapper = new ObjectMapper(); mapper.findAndRegisterModules(); TypeFactory factory = mapper.getTypeFactory(); CollectionLikeType collectionType = factory.constructCollectionLikeType(List.class, type); return mapper.convertValue(content, collectionType); } throw new IllegalStateException("the page content contains unsupported type"); }