Package org.movealong.sly.model
Class Stringy
- java.lang.Object
-
- org.movealong.sly.model.Stringy
-
- All Implemented Interfaces:
CharSequence,Iterable<Character>
public final class Stringy extends Object implements CharSequence, Iterable<Character>
For unknown reasons, the Java API does not implement native iteration of the characters that make up aStringby implementingIterable.Stringyis aCharSequencedecorator which offers just this missing functionality, as well as easy conversions betweenCharSequence,IterableofCharacter, andString.Useful conversions:
CharSequencetoString-
stringify(new StringBuilder("foobar")) IterabletoString-
stringify(strictQueue('f', 'o', 'o', 'b', 'a', 'r')) CharSequencetoIterable-
stringy("foobar") IterabletoCharSequence-
stringy(strictQueue('f', 'o', 'o', 'b', 'a', 'r'))
Certain operations are idempotent. In general, attempting to construct a type from an object that already expresses that type will return the supplied object. For example,
stringify("foobar")will detect that the suppliedCharSequenceis already aStringand simply return it. This is also the case when attempting to construct aStringyfrom an existingStringy.
-
-
Constructor Summary
Constructors Constructor Description Stringy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<Character>iterator()static Stringstringify(CharSequence chars)static Stringstringify(Iterable<Character> chars)StringstringValue()static Stringystringy(CharSequence chars)static Stringystringy(Iterable<Character> chars)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
charAt, chars, codePoints, length, subSequence
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
stringValue
public String stringValue()
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
stringify
public static String stringify(CharSequence chars)
-
stringy
public static Stringy stringy(CharSequence chars)
-
-