Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed IterableEnumVariant class. #35

Open
EJP286CRSKW opened this issue Aug 24, 2023 · 4 comments
Open

Proposed IterableEnumVariant class. #35

EJP286CRSKW opened this issue Aug 24, 2023 · 4 comments

Comments

@EJP286CRSKW
Copy link

EJP286CRSKW commented Aug 24, 2023

I propose this addition to the com.jacob.com package. It is an Iterable and Stream-able subclass of EnumVariant.

IteratableEnumVariant class.

package com.jacob.com;

import java.util.Iterator;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
 * Iterable and streaming EnumVariant.
 * 
 * @author Esmond Pitt
 * @since 1.21
 */
public class IterableEnumVariant extends EnumVariant implements Iterable<Variant>
{
    /**
     * Construct an instance.
     * 
     * @param variant Variant from which to obtain the enumeration.
     */
    public IterableEnumVariant(Variant variant)
    {
        super(variant.m_pVariant);
    }
    
    /**
     * {@inheritDoc}
     * <p>
     * This implementation resets the EnumVariant,
     * so that <code>iterator()</code> can be called multiple times,
     * as can {@link #stream}.
     */
    @Override
    public Iterator<Variant>   iterator()
    {
        super.Reset();
        return new Iterator<Variant>()
        {
            @Override
            public boolean  hasNext()
            {
                return hasMoreElements();
            }
            
            @Override
            public Variant  next()
            {
                return nextElement();
            }
        };
    }
    
    /**
     * Get a Stream from this object.
     * 
     * @return Stream&lt;Variant&gt;.
     */
    public Stream<Variant> stream()
    {
        return StreamSupport.stream(this.spliterator(), false);
    }
}

(or better still fold this into EnumVariant.

@freemansoft
Copy link
Owner

Sample code?

@EJP286CRSKW

This comment was marked as outdated.

@EJP286CRSKW EJP286CRSKW changed the title Proposed IterableActiveXComponent class. Proposed IterableEnumVariant class. Oct 22, 2023
@freemansoft
Copy link
Owner

freemansoft commented Mar 19, 2024

  1. The example uses IterableActiveXComponent which does not exist in the current code base
  2. Could you provide the sample query

freemansoft added a commit that referenced this issue Mar 19, 2024
@freemansoft
Copy link
Owner

Added to EnumVariant 75124c9

Still need sample code or the IterableActiveXComponent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants