Set iterator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Set iterator method.

This code example shows how to use the following methods:isEmpty, iterator
  public Iterator<T> iterator() {
    return ids.iterator();
  } 
 
  public synchronized T choose() { 
    if (!ids.isEmpty()) {
      if (iter == null || !iter.hasNext()) {
        iter = ids.iterator();
      } 
      try { 
        return iter.next();
      } catch (NoSuchElementException e) {
        return null; 
      } 
    } else { 
      return null; 
    } 
  } 
} 
8
CodeRank
This code example shows how to use the following methods:iterator
        return mergeStats;
    } 
 
    @Override 
    public Set<OnGoingMerge> onGoingMerges() {
        for (CustomConcurrentMergeScheduler scheduler : schedulers) {
            return scheduler.onGoingMerges();
        } 
        return ImmutableSet.of(); 
    } 
 
    public static class CustomConcurrentMergeScheduler extends TrackingConcurrentMergeScheduler { 
 
        private final ShardId shardId;
 
        private final ConcurrentMergeSchedulerProvider provider;
 
        private CustomConcurrentMergeScheduler(ESLogger logger, ShardId shardId, ConcurrentMergeSchedulerProvider provider) {
            super(logger);
            this.shardId = shardId;
8
CodeRank
This code example shows how to use the following methods:isEmpty, iterator
    private final Subject subject;
 
    public RealmSubjectUserInfo(Subject subject) {
        this.subject = subject;
        Set<RealmUser> users = subject.getPrincipals(RealmUser.class);
        userName = users.isEmpty() ? null : users.iterator().next().getName();
    } 
 
    public String getUserName() {
        return userName;
    } 
 
    public Collection<Principal> getPrincipals() {
        return subject.getPrincipals();
    } 
 
    public Subject getSubject() {
        return subject;
    } 
 
8
CodeRank
This code example shows how to use the following methods:iterator, size
        Employee emp = new Employee();
        emp.setEmail("MADHUMITA");
 
        Set<ConstraintViolation<Employee>> constraintViolations = validator.validate(emp);
 
        assertEquals("Wrong number of constraints", constraintViolations.size(), 1);
        assertEquals(CustomMessageInterpolator.MESSAGE, constraintViolations.iterator().next().getMessage());
    } 
 
    private static class CustomMessageInterpolator implements MessageInterpolator { 
 
        public static final String MESSAGE = "Message created by custom interpolator";
 
        @Override 
        public String interpolate(String messageTemplate, Context context) {
            return MESSAGE;
        } 
 
        @Override 
        public String interpolate(String messageTemplate, Context context, Locale locale) {
8
CodeRank
This code example shows how to use the following methods:iterator
    } 
 
    private Bean<?> getBean(final String ref) {
        WildFlyBatchLogger.LOGGER.tracef("Looking up bean reference for '%s'", ref);
        final Set<Bean<?>> beans = beanManager.getBeans(ref);
        final Iterator<Bean<?>> iter = beans.iterator();
        if (iter.hasNext()) {
            final Bean<?> bean = iter.next();
            WildFlyBatchLogger.LOGGER.tracef("Found bean '%s' for reference '%s'", bean, ref);
            return bean;
        } 
        WildFlyBatchLogger.LOGGER.tracef("No bean found for reference '%s;'", ref);
        return null; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:iterator, size
 
    @Test 
    public void testResource() throws Exception { 
        // There's one bean of type CDIResource and it's scope is @RequestScoped (this is resteasy-cdi specific) 
        Set<Bean<?>> beans = beanManager.getBeans(CDIResource.class); 
        assertEquals(1, beans.size()); 
        assertEquals(RequestScoped.class, beans.iterator().next().getScope()); 
    } 
 
    @Test 
    public void testApplication() throws Exception { 
        // There's one bean of type CDIApplication and it's scope is @ApplicationScoped 
        Set<Bean<?>> beans = beanManager.getBeans(CDIApplication.class); 
        assertEquals(1, beans.size()); 
        assertEquals(ApplicationScoped.class, beans.iterator().next().getScope()); 
    } 
 
    @Test 
    public void testProvider() throws Exception { 
        // There's one bean of type CDIProvider and it's scope is @ApplicationScoped 
8
CodeRank
This code example shows how to use the following methods:iterator, size
        assertThat(yamlSuites.containsKey(dirName), equalTo(true));
        assertSingleFile(yamlSuites.get(dirName), dirName, fileName);
    } 
 
    private static void assertSingleFile(Set<File> files, String dirName, String fileName) {
        assertThat(files.size(), equalTo(1));
        File file = files.iterator().next();
        assertThat(file.getName(), equalTo(fileName));
        assertThat(file.getParentFile().getName(), equalTo(dirName));
    } 
} 
7
CodeRank
This code example shows how to use the following methods:iterator
        return this;
    } 
 
    private <T> T getReference(Class<T> clazz, BeanManager beanManager) {
        Set<Bean<?>> beans = beanManager.getBeans(clazz, new AnnotationLiteral<Default>() {});
        Iterator<Bean<?>> i = beans.iterator();
        if (!i.hasNext()) {
            return null; 
        } 
 
        Bean<?> bean = i.next();
        CreationalContext<?> context = beanManager.createCreationalContext(bean);
        return (T) beanManager.getReference(bean, clazz, context);
    } 
 
    public InjectedValue<WeldBootstrapService> getWeldContainer() { 
        return weldContainer;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:iterator
        return mergeStats;
    } 
 
    @Override 
    public Set<OnGoingMerge> onGoingMerges() {
        for (CustomConcurrentMergeScheduler scheduler : schedulers) {
            return scheduler.onGoingMerges();
        } 
        return ImmutableSet.of(); 
    } 
 
    @Override 
    public void close() { 
        indexSettingsService.removeListener(applySettings);
    } 
 
    public int getMaxMerges() { 
        return this.maxMergeCount;
    } 
 
6
CodeRank
This code example shows how to use the following methods:iterator, size
        Driver driver = new Driver("Sebastian", "Vettel"); 
        driver.setAge(25); 
        driver.setAddress("ABC"); 
 
        result = validator.validate(car);
        assertEquals(1, result.size());
        assertEquals("The Car has to pass the fuel test and inspection test before being driven", result.iterator().next()
                .getMessage()); 
        car.setPassedVehicleInspection(true);
 
        result = validator.validate(car);
        // New group set in defaultsequence for Car as per CarGroupSequenceProvider should be implemented now 
        assertEquals(2, result.size());
 
        car.setDriver(driver);
        // implementing validation for group associated with associated objects of Car(in this case Driver) 
        Set<ConstraintViolation<Car>> driverResult = validator.validate(car, DriverChecks.class);
        assertEquals(1, driverResult.size());
        driver.setHasValidDrivingLicense(true); 
        assertEquals(0, validator.validate(car, DriverChecks.class).size());
8
CodeRank

Related Set iterator Questions & Answers:

Other Set iterator Examples

79:	
80:	    /**
81:	     * Unregister this account/device pair within the server.
82:	     */
83:	    static void unregister(final Context context, final String regId) {

Read More

iterator Method Overview
Returns an iterator over the elements in this set.
See Code Examples for other Java 8 Set Methods: