下面列出了java.util.List#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Collection<FileInfo> getFiles() {
PhpModule phpModule = PhpModule.Factory.lookupPhpModule(project);
if (phpModule == null) {
return Collections.emptyList();
}
if (!initialized) {
initialized = true;
CodeceptionPreferences.addPreferenceChangeListener(phpModule, WeakListeners.create(PreferenceChangeListener.class, this, CodeceptionPreferences.class));
}
// global configuration
List<FileInfo> files = new ArrayList<>();
files.addAll(defaultConfigSupport.getFiles(null));
if (CodeceptionPreferences.isCustomCodeceptionYmlEnabled(phpModule)) {
List<FileObject> codeceptionYmls = Codecept.getCodeceptionYmls(phpModule);
for (FileObject codeceptionYml : codeceptionYmls) {
files.add(new FileInfo(codeceptionYml));
}
}
return files;
}
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
final String name = group.getMetricIdentifier(metricName);
List<String> tags = new ArrayList<>(configTags);
tags.addAll(getTagsFromMetricGroup(group));
String host = getHostFromMetricGroup(group);
if (metric instanceof Counter) {
Counter c = (Counter) metric;
counters.put(c, new DCounter(c, name, host, tags));
} else if (metric instanceof Gauge) {
Gauge g = (Gauge) metric;
gauges.put(g, new DGauge(g, name, host, tags));
} else if (metric instanceof Meter) {
Meter m = (Meter) metric;
// Only consider rate
meters.put(m, new DMeter(m, name, host, tags));
} else if (metric instanceof Histogram) {
LOGGER.warn("Cannot add {} because Datadog HTTP API doesn't support Histogram", metricName);
} else {
LOGGER.warn("Cannot add unknown metric type {}. This indicates that the reporter " +
"does not support this metric type.", metric.getClass().getName());
}
}
@Override
public Long zUnionStore(byte[] destKey, Aggregate aggregate, Weights weights, byte[]... sets) {
List<Object> args = new ArrayList<Object>(sets.length*2 + 5);
args.add(destKey);
args.add(sets.length);
args.addAll(Arrays.asList(sets));
if (weights != null) {
args.add("WEIGHTS");
for (double weight : weights.toArray()) {
args.add(BigDecimal.valueOf(weight).toPlainString());
}
}
if (aggregate != null) {
args.add("AGGREGATE");
args.add(aggregate.name());
}
return write(destKey, LongCodec.INSTANCE, ZUNIONSTORE, args.toArray());
}
public static ResultSet primaryKeysResultSet(String[] pkNames, String[] columnNames, short[] keySeqs) {
List pkNameColumn = writeableSingletonList("PK_NAME");
pkNameColumn.addAll(Arrays.asList(pkNames));
List columnNameColumn = writeableSingletonList("COLUMN_NAME");
columnNameColumn.addAll(Arrays.asList(columnNames));
List keySeqColumn = writeableSingletonList("KEY_SEQ");
addAllAsReferenceType(keySeqColumn, keySeqs);
List columns = new ArrayList();
columns.add(pkNameColumn);
columns.add(columnNameColumn);
columns.add(keySeqColumn);
return createResultSet(columns);
}
private static List<SourcePath> doScan(File root, File dir) {
List<SourcePath> sourcePaths = new ArrayList<>();
DirectoryStream<Path> dirStream = null;
try {
dirStream = Files.newDirectoryStream(dir.toPath());
Iterator<Path> it = dirStream.iterator();
while (it.hasNext()) {
Path next = it.next();
if (Files.isDirectory(next)) {
sourcePaths.addAll(doScan(root, next.toFile()));
} else {
sourcePaths.add(new SourcePath(root, next.toFile()));
}
}
} catch (IOException ex) {
if (dirStream != null) {
try {
dirStream.close();
} catch (IOException e) { }
}
}
return sort(sourcePaths);
}
private List<View> getCandidateViews(String viewName, Locale locale, List<MediaType> requestedMediaTypes)
throws Exception {
List<View> candidateViews = new ArrayList<View>();
for (ViewResolver viewResolver : this.viewResolvers) {
View view = viewResolver.resolveViewName(viewName, locale);
if (view != null) {
candidateViews.add(view);
}
for (MediaType requestedMediaType : requestedMediaTypes) {
List<String> extensions = this.contentNegotiationManager.resolveFileExtensions(requestedMediaType);
for (String extension : extensions) {
String viewNameWithExtension = viewName + '.' + extension;
view = viewResolver.resolveViewName(viewNameWithExtension, locale);
if (view != null) {
candidateViews.add(view);
}
}
}
}
if (!CollectionUtils.isEmpty(this.defaultViews)) {
candidateViews.addAll(this.defaultViews);
}
return candidateViews;
}
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
List<Cooccurrence> toRemove = newLinkedList();
for (Entry<Sentence, Collection<Cooccurrence>> sentenceWithCooc : JCasUtil
.indexCovered(jCas, Sentence.class, Cooccurrence.class)
.entrySet()) {
String sText = sentenceWithCooc.getKey().getCoveredText()
.toLowerCase();
if (ABBREV.matcher(sText).matches()
| STOPLIST.matcher(sText).find()) {
toRemove.addAll(sentenceWithCooc.getValue());
}
}
// remove
Cooccurrence[] array = toRemove.toArray(new Cooccurrence[toRemove
.size()]);
for (int i = 0; i < array.length; i++) {
array[i].removeFromIndexes();
}
}
/**
* 从深度信息解析精度
*
* @param depth 深度
* @param symbol 币对
* @return 精度
*/
public static Precision parsePrecisionByDepth(Depth depth, String symbol) {
int base = 0;
int count = 0;
List<Row> rows = depth.getAsks().getList();
rows.addAll(depth.getBids().getList());
for (Row r : rows) {
int c = r.getPrice().scale();
int b = r.getAmount().scale();
if (count < c) {
count = c;
}
if (base < b) {
base = b;
}
}
return new Precision(null, symbol, base, count, null, null,
null, null, null, null);
}
private void updateClasspathList() {
List<CPListElement> srcelements= fFoldersList.getElements();
List<CPListElement> cpelements= fClassPathList.getElements();
int nEntries= cpelements.size();
// backwards, as entries will be deleted
int lastRemovePos= nEntries;
int afterLastSourcePos= 0;
for (int i= nEntries - 1; i >= 0; i--) {
CPListElement cpe= cpelements.get(i);
int kind= cpe.getEntryKind();
if (isEntryKind(kind)) {
if (!srcelements.remove(cpe)) {
cpelements.remove(i);
lastRemovePos= i;
} else if (lastRemovePos == nEntries) {
afterLastSourcePos= i + 1;
}
}
}
if (!srcelements.isEmpty()) {
int insertPos= Math.min(afterLastSourcePos, lastRemovePos);
cpelements.addAll(insertPos, srcelements);
}
if (lastRemovePos != nEntries || !srcelements.isEmpty()) {
fClassPathList.setElements(cpelements);
}
}
@Override
protected void onSubsystemChanged(ModelChangedEvent event) {
Set<String> currentChanges = event.getChangedAttributes().keySet();
Set<String> intersection = Sets.intersection(attributesChanges, currentChanges);
if (!intersection.isEmpty()) {
List<String> listAddresses = new ArrayList<>();
listAddresses.addAll(list(getDnLSubsystem().getPetDoorDevices()));
listAddresses.addAll(list(getDnLSubsystem().getMotorizedDoorDevices()));
doorDevices.setAddresses(listAddresses, true);
}
super.onSubsystemChanged(event);
}
/**
* We represent overloaded functions in variable map as a function
* variable with a union type. This adds a new type to the union.
*
* @param name
* @param type
*/
private void addOverloadToType(String name, FunctionType type) {
Var existing = lookupVarUnsafe(name);
List<Type> alts = new ArrayList<Type>();
alts.addAll(UnionType.getAlternatives(existing.type()));
alts.add(type);
replaceVarUnsafe(name, existing.substituteType(
UnionType.makeUnion(alts)));
}
protected void initAttrIndexLimit() {
for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
assert(attrIndexLimit[i] == 0); // decide on it now!
attrIndexLimit[i] = (haveFlagsHi(i)? 63: 32);
List<Attribute.Layout> defList = attrDefs.get(i);
assert(defList.size() == 32); // all predef indexes are <32
int addMore = attrIndexLimit[i] - defList.size();
defList.addAll(Collections.nCopies(addMore, (Attribute.Layout) null));
}
}
/**
* Refresh the cache of Vets that the ClinicService is holding.
*
* @see org.springframework.samples.petclinic.model.service.ClinicService#shouldFindVets()
*/
@Override
public Collection<Vet> findAll() throws DataAccessException {
List<Vet> vets = new ArrayList<Vet>();
// Retrieve the list of all vets.
vets.addAll(this.jdbcTemplate.query(
"SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
BeanPropertyRowMapper.newInstance(Vet.class)));
// Retrieve the list of all possible specialties.
final List<Specialty> specialties = this.jdbcTemplate.query(
"SELECT id, name FROM specialties",
BeanPropertyRowMapper.newInstance(Specialty.class));
// Build each vet's list of specialties.
for (Vet vet : vets) {
final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
"SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
new BeanPropertyRowMapper<Integer>() {
@Override
public Integer mapRow(ResultSet rs, int row) throws SQLException {
return Integer.valueOf(rs.getInt(1));
}
},
vet.getId().intValue());
for (int specialtyId : vetSpecialtiesIds) {
Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
vet.addSpecialty(specialty);
}
}
return vets;
}
protected void setupPageAndFormValues(HttpServletRequest request,
DynaActionForm daForm, User user, Server s, Org o, Integer trustedOrgCount) {
//ibm jvm has issues adding set in ArrayList constructor so add separately
Set set = user.getOrg().getTrustedOrgs();
List orgList = new ArrayList();
orgList.addAll(set);
request.setAttribute("trustedOrgCount", trustedOrgCount);
request.setAttribute("system", s);
request.setAttribute("orgs", orgList);
request.setAttribute("org", o);
}
/**
* Upload entity data.
*
* @param datasource the datasource
* @return the list
*/
public List<Map<String, String>> uploadEntityData(String datasource) {
List<Map<String,String>> errorList = new ArrayList<>();
Set<String> types = ConfigManager.getTypes(datasource);
Iterator<String> itr = types.iterator();
String type = "";
LOGGER.info("*** Start Colleting Entity Info ***");
List<String> filters = Arrays.asList("_docid", FIRST_DISCOVERED);
EntityAssociationManager childTypeManager = new EntityAssociationManager();
while (itr.hasNext()) {
try {
type = itr.next();
Map<String, Object> stats = new LinkedHashMap<>();
String loaddate = new SimpleDateFormat("yyyy-MM-dd HH:mm:00Z").format(new java.util.Date());
stats.put("datasource", datasource);
stats.put("type", type);
stats.put("start_time", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new java.util.Date()));
LOGGER.info("Fetching {}" , type);
String indexName = datasource + "_" + type;
Map<String, Map<String, String>> currentInfo = ESManager.getExistingInfo(indexName, type, filters);
LOGGER.info("Existing no of docs : {}" , currentInfo.size());
List<Map<String, Object>> entities = fetchEntitiyInfoFromS3(datasource,type,errorList);
List<Map<String, String>> tags = fetchTagsForEntitiesFromS3(datasource, type);
LOGGER.info("Fetched from S3");
if(!entities.isEmpty()){
List<Map<String, String>> overridableInfo = RDSDBManager.executeQuery(
"select updatableFields from cf_pac_updatable_fields where resourceType ='" + type + "'");
List<Map<String, String>> overrides = RDSDBManager.executeQuery(
"select _resourceid,fieldname,fieldvalue from pacman_field_override where resourcetype = '"
+ type + "'");
Map<String, List<Map<String, String>>> overridesMap = overrides.parallelStream()
.collect(Collectors.groupingBy(obj -> obj.get("_resourceid")));
String keys = ConfigManager.getKeyForType(datasource, type);
String idColumn = ConfigManager.getIdForType(datasource, type);
String[] keysArray = keys.split(",");
prepareDocs(currentInfo, entities, tags, overridableInfo, overridesMap, idColumn, keysArray, type);
Map<String,Long> errUpdateInfo = ErrorManager.getInstance(datasource).handleError(indexName,type,loaddate,errorList,true);
Map<String, Object> uploadInfo = ESManager.uploadData(indexName, type, entities, loaddate);
stats.putAll(uploadInfo);
stats.put("errorUpdates", errUpdateInfo);
errorList.addAll(childTypeManager.uploadAssociationInfo(datasource, type)) ;
}
stats.put("total_docs", entities.size());
stats.put("end_time", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new java.util.Date()));
stats.put("newly_discovered",entities.stream().filter(entity->entity.get(DISCOVERY_DATE).equals(entity.get(FIRST_DISCOVERED))).count());
String statsJson = ESManager.createESDoc(stats);
ESManager.invokeAPI("POST", "/datashipper/stats", statsJson);
} catch (Exception e) {
LOGGER.error("Exception in collecting/uploading data for {}" ,type,e);
Map<String,String> errorMap = new HashMap<>();
errorMap.put(ERROR, "Exception in collecting/uploading data for "+type);
errorMap.put(ERROR_TYPE, WARN);
errorMap.put(EXCEPTION, e.getMessage());
errorList.add(errorMap);
}
}
LOGGER.info("*** End Colleting Entity Info ***");
return errorList;
}
protected void includeInputInOutput( Object[][] outputRows ) throws KettleException {
if ( !m_meta.getIncludeInputAsOutput() ) {
for ( Object[] r : outputRows ) {
putRow( m_data.m_outputRowMeta, r );
}
return;
}
List<Object[]> flattenedInputRows = new ArrayList<Object[]>();
int[]
rowCounts =
new int[m_meta.getDoingReservoirSampling() ? m_data.m_reservoirSamplers.size() : m_data.m_frameBuffers.size()];
// RowMetaInterface[] infoMetas = new RowMetaInterface[rowCounts.length];
int index = 0;
int sum = 0;
if ( !m_meta.getDoingReservoirSampling() ) {
for ( List<Object[]> frameBuffer : m_data.m_frameBuffers ) {
sum += frameBuffer.size();
rowCounts[index++] = sum;
flattenedInputRows.addAll( frameBuffer );
}
} else {
for ( ReservoirSamplingData reservoirSamplingData : m_data.m_reservoirSamplers ) {
sum += reservoirSamplingData.getSample().size();
rowCounts[index++] = sum;
flattenedInputRows.addAll( reservoirSamplingData.getSample() );
}
}
index = 0;
for ( int i = 0; i < outputRows.length; i++ ) {
if ( i > rowCounts[index] ) {
index++;
}
// get the input row meta corresponding to this row
RowMetaInterface associatedRowMeta = m_data.m_infoMetas.get( index );
if ( outputRows[i] != null ) {
Object[] inputRow;
if ( m_data.m_batchSize == 1 && m_meta.getDoingReservoirSampling() ) {
inputRow = flattenedInputRows.get( m_data.m_rowByRowReservoirSampleIndex );
} else {
inputRow = flattenedInputRows.get( i );
}
for ( ValueMetaInterface vm : m_data.m_incomingFieldsIncludedInOutputRowMeta.getValueMetaList() ) {
int outputIndex = m_data.m_nonScriptOutputMetaIndexLookup.get( vm.getName() );
// is this user selected input field present in the current info input row set?
int inputIndex = associatedRowMeta.indexOfValue( vm.getName() );
if ( inputIndex >= 0 ) {
outputRows[i][outputIndex] = inputRow[inputIndex];
}
}
putRow( m_data.m_outputRowMeta, outputRows[i] );
}
}
}
public List<String> getLinks() {
List<String> ret = new ArrayList<>();
ret.addAll(this.<String>asList("links"));
ret.addAll(this.<String>asList("external_links"));
return ret;
}
private List<FileObject> getPlatformPath() {
List<FileObject> files = new ArrayList<>();
files.addAll(getDirs(PhpProjectProperties.INCLUDE_PATH));
files.addAll(getDirs(PhpProjectProperties.PRIVATE_INCLUDE_PATH));
return files;
}
public Object[] getElements( Object inputElement )
{
// TODO Auto-generated method stub
input = inputElement;
Object obj = null;
if ( inputElement instanceof List )
{
obj = ( (List) inputElement ).get( 0 );
}
else
{
obj = inputElement;
}
List list = new ArrayList( );
if ( !( obj instanceof ExtendedItemHandle ) )
return EMPTY;
ExtendedItemHandle element = (ExtendedItemHandle) obj;
CrosstabReportItemHandle crossTab = null;
try
{
crossTab = (CrosstabReportItemHandle) element.getReportItem( );
}
catch ( ExtendedElementException e )
{
// TODO Auto-generated catch block
logger.log( Level.SEVERE, e.getMessage( ), e );
}
if ( crossTab == null )
{
return list.toArray( );
}
// if ( crossTab.getCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE )
// != null )
// {
// DesignElementHandle elementHandle = crossTab.getCrosstabView(
// ICrosstabConstants.COLUMN_AXIS_TYPE )
// .getModelHandle( );
// list.addAll( getLevel( (ExtendedItemHandle) elementHandle ) );
// }
if ( crossTab.getCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE ) != null )
{
CrosstabViewHandle crosstabView = crossTab.getCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE );
list.addAll( getLevel( crosstabView ) );
}
return list.toArray( );
}
/**
* Private helper method to go with {@link TurfMeta#coordAll(LineString)}.
*
* @param coords the {@code List} of {@link Point}s.
* @param lineString any {@link LineString} object
* @return a {@code List} made up of {@link Point}s
* @since 4.8.0
*/
@NonNull
private static List<Point> coordAll(@NonNull List<Point> coords, @NonNull LineString lineString) {
coords.addAll(lineString.coordinates());
return coords;
}