(Object coll)
| 589 | } |
| 590 | |
| 591 | static public Iterator iter(Object coll){ |
| 592 | if(coll instanceof Iterable) |
| 593 | return ((Iterable)coll).iterator(); |
| 594 | else if(coll == null) |
| 595 | return new Iterator(){ |
| 596 | public boolean hasNext(){ |
| 597 | return false; |
| 598 | } |
| 599 | |
| 600 | public Object next(){ |
| 601 | throw new NoSuchElementException(); |
| 602 | } |
| 603 | |
| 604 | public void remove(){ |
| 605 | throw new UnsupportedOperationException(); |
| 606 | } |
| 607 | }; |
| 608 | else if(coll instanceof Map){ |
| 609 | return ((Map)coll).entrySet().iterator(); |
| 610 | } |
| 611 | else if(coll instanceof String){ |
| 612 | final String s = (String) coll; |
| 613 | return new Iterator(){ |
| 614 | int i = 0; |
| 615 | |
| 616 | public boolean hasNext(){ |
| 617 | return i < s.length(); |
| 618 | } |
| 619 | |
| 620 | public Object next(){ |
| 621 | return s.charAt(i++); |
| 622 | } |
| 623 | |
| 624 | public void remove(){ |
| 625 | throw new UnsupportedOperationException(); |
| 626 | } |
| 627 | }; |
| 628 | } |
| 629 | else if(coll.getClass().isArray()){ |
| 630 | return ArrayIter.createFromObject(coll); |
| 631 | } |
| 632 | else |
| 633 | return iter(seq(coll)); |
| 634 | } |
| 635 | |
| 636 | static public Object seqOrElse(Object o) { |
| 637 | return seq(o) == null ? null : o; |
nothing calls this directly
no test coverage detected