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

Add more introspection properties #1754

danieldietrich opened this issue Dec 11, 2016 · 0 comments

Add more introspection properties #1754

danieldietrich opened this issue Dec 11, 2016 · 0 comments


Copy link

@danieldietrich danieldietrich commented Dec 11, 2016

The bold printed properties are new:

Value has:

  • isAsync() — is computed asynchronously
  • isLazy() — is evaluated lazily (as opposed to eagerly)
  • isSingleValued() — can contain at most one value

Traversable additionally has:

  • hasDefiniteSize() — has at most a finite number of elements
  • isDistinct() — cannot contain duplicate elements (using equals)
  • isOrdered() — has an underlying Comparator (by implementing Ordered)
  • isSequential() — elements occur in a predictable, fixed sequence
  • isTraversableOnce() — can be iterated once (read: is stateful)

Note:** It is odd that these properties are observed on an instance of that type, for example:

// = false, but a user may think that is has size 1

// = false, but a user may think that the list contains distinct elements
List(1, 2).isDistinct();

// = false, but a user may think that the elements are ordered in the list
List(1, 2).isOrdered();

// = false, but a user may think that there is only a single element

We need to keep in mind that these properties are intended to be observed on instances of super types, for example:

if (traversable.hasDefiniteSize()) {
    println("the size is: " + traversable.size());

if (traversable.isOrdered()) {
    Comparator<T> comparator = ((Ordered<T>) traversable).comparator();
    // ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant