本文整理汇总了Java中com.google.api.client.util.Sets类的典型用法代码示例。如果您正苦于以下问题:Java Sets类的具体用法?Java Sets怎么用?Java Sets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sets类属于com.google.api.client.util包,在下文中一共展示了Sets类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFeedbackRecipients
import com.google.api.client.util.Sets; //导入依赖的package包/类
private Set<User> getFeedbackRecipients()
{
UserGroup feedbackRecipients = configurationService.getConfiguration().getFeedbackRecipients();
if ( feedbackRecipients != null )
{
return feedbackRecipients.getMembers();
}
return Sets.newHashSet();
}
示例2: importContacts
import com.google.api.client.util.Sets; //导入依赖的package包/类
private void importContacts() {
Set<User> users = Sets.newHashSet();
Uri uri = ContactsContract.Contacts.CONTENT_URI;
uri = Uri.withAppendedPath(uri, ContactsContract.Contacts.Entity.CONTENT_DIRECTORY);
Cursor cursor = getContentResolver().query(uri,
new String[]{ContactsContract.RawContacts.CONTACT_ID, ContactsContract.CommonDataKinds.Email.ADDRESS, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.Photo.PHOTO_URI},
ContactsContract.Contacts.IN_VISIBLE_GROUP + " = 1 and " +
ContactsContract.CommonDataKinds.Email.ADDRESS + " is not null and " +
ContactsContract.CommonDataKinds.Email.ADDRESS + " not like '%@s.whatsapp.net' and " +
ContactsContract.CommonDataKinds.Email.ADDRESS + " like '%@%'"
,
null, null);
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToNext();
String id = cursor.getString(0);
String email = cursor.getString(1);
String name = cursor.getString(2);
String photo = cursor.getString(3);
Log.d(TAG, id + " display name: " + name + " Email: " + email + " Photo: " + photo);
uri = photo == null ? null : Uri.parse(photo);
User user = new User(email, name, uri, new UserProfile(UserState.UNKNOW));
if (!users.contains(user)) {
addContact(id, user);
}
users.add(user);
}
contacts.addAll(users);
listView.getAdapter().notifyDataSetChanged();
cursor.close();
}
示例3: testExecuteMulti
import com.google.api.client.util.Sets; //导入依赖的package包/类
@Test
public void testExecuteMulti() throws Exception {
Channel result = mock(Channel.class);
Channel result2 = mock(Channel.class);
QueryContext context = mock(QueryContext.class);
Query<ResolvedChannel> channelQuery = mock(Query.class);
Application application = mock(Application.class);
ApplicationConfiguration configuration = mock(ApplicationConfiguration.class);
Selection selection = Selection.ALL;
HttpServletRequest request = mock(HttpServletRequest.class);
when(request.getParameter("annotations")).thenReturn("banana");
when(context.getRequest()).thenReturn(request);
when(configuration.isReadEnabled(any(Publisher.class))).thenReturn(true);
when(configuration.isPrecedenceEnabled()).thenReturn(false);
when(application.getConfiguration()).thenReturn(configuration);
when(context.getApplication()).thenReturn(application);
when(context.getSelection()).thenReturn(Optional.of(selection));
when(channelQuery.isListQuery()).thenReturn(true);
when(channelQuery.getContext()).thenReturn(context);
when(channelQuery.getOperands()).thenReturn(
AttributeQuerySet.create(Sets.<AttributeQuery<Object>>newHashSet())
);
when(channelResolver.resolveChannels(any(ChannelQuery.class)))
.thenReturn(
Futures.immediateFuture(
Resolved.valueOf(ImmutableSet.of(result, result2))
)
);
QueryResult<ResolvedChannel> queryResult = objectUnderTest.execute(channelQuery);
ImmutableList<Channel> channels = queryResult.getResources().toList().stream()
.map(ResolvedChannel::getChannel)
.collect(MoreCollectors.toImmutableList());
assertThat(channels, containsInAnyOrder(result, result2));
}
示例4: execute
import com.google.api.client.util.Sets; //导入依赖的package包/类
@Override
@Transactional
public void execute( JobConfiguration jobConfiguration )
{
notifier.clear( jobConfiguration ).notify( jobConfiguration, "Monitoring data" );
MonitoringJobParameters monitoringJobParameters = (MonitoringJobParameters) jobConfiguration.getJobParameters();
//TODO improve collection usage
try
{
List<Period> periods;
Collection<ValidationRule> validationRules;
List<String> groupUIDs = monitoringJobParameters.getValidationRuleGroups();
if ( groupUIDs.isEmpty() )
{
validationRules = validationRuleService
.getValidationRulesWithNotificationTemplates();
}
else
{
validationRules = groupUIDs.stream()
.map( ( uid ) -> validationRuleService.getValidationRuleGroup( uid ) )
.filter( Objects::nonNull )
.map( ValidationRuleGroup::getMembers )
.filter( Objects::nonNull )
.reduce( Sets.newHashSet(), SetUtils::union );
}
if ( monitoringJobParameters.getRelativeStart() != 0 && monitoringJobParameters.getRelativeEnd() != 0 )
{
Date startDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeStart() );
Date endDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeEnd() );
periods = periodService.getPeriodsBetweenDates( startDate, endDate );
periods = ListUtils.union( periods, periodService.getIntersectionPeriods( periods ) );
}
else
{
periods = validationRules.stream()
.map( ValidationRule::getPeriodType )
.distinct()
.map( ( vr ) -> Arrays.asList( vr.createPeriod(), vr.getPreviousPeriod( vr.createPeriod() ) ) )
.reduce( Lists.newArrayList(), ListUtils::union );
}
ValidationAnalysisParams parameters = validationService
.newParamsBuilder( validationRules, null, periods )
.withIncludeOrgUnitDescendants( true )
.withMaxResults( ValidationService.MAX_SCHEDULED_ALERTS )
.withSendNotifications( monitoringJobParameters.isSendNotifications() )
.withPersistResults( monitoringJobParameters.isPersistResults() )
.build();
validationService.validationAnalysis( parameters );
notifier.notify( jobConfiguration, INFO, "Monitoring process done", true );
}
catch ( RuntimeException ex )
{
notifier.notify( jobConfiguration, ERROR, "Process failed: " + ex.getMessage(), true );
messageService.sendSystemErrorNotification( "Monitoring process failed", ex );
throw ex;
}
}
示例5: initialise
import com.google.api.client.util.Sets; //导入依赖的package包/类
public static void initialise(String[] args) throws ParseException {
CommandLineParser parser = new DefaultParser();
CommandLine line = parser.parse(optionsToParse, args);
for (Option opt : line.getOptions()) {
log.debug(String.format("Parsing command line option -%s, value = %s ",
opt.getLongOpt() != null ? "-" + opt.getLongOpt() : opt.getOpt(),
opt.getValue()));
}
opts.help = line.hasOption("help");
opts.useHash = line.hasOption("hash-compare");
opts.version = line.hasOption("version");
opts.recursive = line.hasOption("recursive");
opts.dryRun = line.hasOption("dry-run");
opts.authorise = line.hasOption("authorise");
if (line.hasOption("local")) {
opts.localPath = line.getOptionValue("local");
}
if (line.hasOption("remote")) {
opts.remotePath = line.getOptionValue("remote");
}
if (line.hasOption("direction")) {
String chosen = line.getOptionValue("direction").toLowerCase();
if (!chosen.equals("up") && !chosen.equals("down")) {
throw new ParseException("Direction must be one of up or down");
}
opts.direction = Direction.valueOf(chosen.toUpperCase());
}
if (line.hasOption("threads")) {
opts.threads = Integer.parseInt(line.getOptionValue("threads"));
}
if (line.hasOption("tries")) {
opts.tries = Integer.parseInt(line.getOptionValue("tries"));
}
if (line.hasOption("max-size")) {
opts.maxSizeKb = Integer.parseInt(line.getOptionValue("max-size"));
}
if (line.hasOption("keyfile")) {
opts.keyFile = Paths.get(line.getOptionValue("keyfile"));
}
if (line.hasOption("logfile")) {
opts.logFile = line.getOptionValue("logfile");
}
if (line.hasOption("split-after")) {
opts.splitAfter = Integer.parseInt(line.getOptionValue("split-after"));
if (opts.splitAfter > 60) {
throw new ParseException("maximum permissible value for split-after is 60");
}
}
if (line.hasOption("ignore")) {
Path ignoreFile = Paths.get(line.getOptionValue("ignore"));
if (!Files.exists(ignoreFile)) {
throw new ParseException("specified ignore file does not exist");
}
try {
opts.ignored = Sets.newHashSet();
opts.ignored.addAll(Files.readAllLines(ignoreFile, Charset.defaultCharset()));
} catch (IOException e) {
throw new ParseException(e.getMessage());
}
}
opts.isInitialised = true;
}
示例6: BuildGcsUploadReport
import com.google.api.client.util.Sets; //导入依赖的package包/类
public BuildGcsUploadReport(Run<?, ?> run) {
super(run);
this.buckets = Sets.newHashSet();
this.files = Sets.newHashSet();
}
示例7: bootstrapSchedules
import com.google.api.client.util.Sets; //导入依赖的package包/类
public boolean bootstrapSchedules(
Iterable<Channel> channels,
Interval interval,
Publisher source,
boolean migrateContent,
boolean writeEquivalences,
boolean forwarding
) {
if (!bootstrapLock.tryLock()) {
return false;
}
bootstrapping.set(true);
processed.set(0);
failures.set(0);
progress.set(0);
total.set(Iterables.size(channels));
Set<ListenableFuture<UpdateProgress>> futures = Sets.newHashSet();
log.info(
"Bootstrapping {} channels for interval from {} to {}",
Iterables.size(channels),
interval.getStart(),
interval.getEnd()
);
try {
for (Channel channel : channels) {
futures.add(bootstrapChannel(
channel,
interval,
source,
migrateContent,
writeEquivalences,
forwarding
));
}
Futures.getChecked(Futures.allAsList(futures), Exception.class);
} catch (Exception e) {
//this is already logged in the callback
} finally {
bootstrapLock.unlock();
bootstrapping.set(false);
}
return true;
}