commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-425) Sequence(String)Utils
Date Tue, 17 Jun 2008 14:37:45 GMT

    [ https://issues.apache.org/jira/browse/LANG-425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605622#action_12605622
] 

James Carman commented on LANG-425:
-----------------------------------

Perhaps we come up with a generified interface?  Something like:

{code}
public interface Sequence<T>
{
  public T nextValue();
}
{code}

This just sounds a lot like Iterator<T>, though except the idea of hasNext() might not
be applicable here.  To adapt a Sequence to the Iterator interface we could do:

{code}
public class SequenceIterator<T> implements Iterator<T>
{
  private final Sequence<T> sequence;

  public T next()
  {
    return sequence.nextValue();
  }

  public boolean hasNext()
  {
    return true;
  }
}
{code}

Thus, if code needs a sequence of Integers (or ints with autoboxing), they would declare their
API with Sequence<Integer>.  If they need a sequence of strings, they would do Sequence<String>.

> Sequence(String)Utils
> ---------------------
>
>                 Key: LANG-425
>                 URL: https://issues.apache.org/jira/browse/LANG-425
>             Project: Commons Lang
>          Issue Type: Wish
>    Affects Versions: 2.4
>            Reporter: Robert Scholte
>            Priority: Trivial
>
> Don't you think it's kind of strange to have RandomUtils and RandomStringUtils, but not
just the ordinairy SequenceUtils?
> I've seen commons-id in the sandbox, but maybe some basics should become part of commons
lang.
> Most classes of within this package are stateless/static, or they have a state within
a method (such as StrBuilder). SequenceUtils can only be static, if it has the startValue.
> For example
> {code}
> SequenceUtils.nextInt(10)
> SequenceUtils.nextString("MORE")
> SequenceUtils.nextBoolean(true) //ok, this one is stupid but quite clear
> SequenceUtils.nextString("C0DE", "0123456789ABCDEF") //next hexadecimal
> {code}
> any more ideas?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message