Name |
Ceylon Chayote - Various Utility Functions and Classes |
---|---|
Description |
Various utility classes and methods for Ceylon. These are intended to all be written in native Ceylon, with no dependency on JDK-specific modules. Format [[Integer]]s or [[com.vasileff.ceylon.integer64::Integer64]]s as either hex or bits Strings with padding and underscores to make them more readable. print(formatAndPadAsBits(30)); > <b>0001_1110</b> print(formatAndPadAsHex(500000); > <b>0007_a120</b> Determine whether an [[Integer] has too many (or too few in the case of negative) bits on a Ceylon platform (JVM or JS) print(isOverflowOnPlatform($0010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000)); > <b>false</b> (JVM) > <b>true</b> (JS) Helper functions for equals() and hash: hashes(myObject.myInteger,myObject.myString); > <b>1312847</b> equalsWith(myObject.myInteger,otherObject.myInteger); > <b>true</b> or <b>false</b> equalsWithMultiple([myObject.myInteger,otherObject.myInteger], [myObject.myString,otherObject.myString]); > <b>true</b> or <b>false</b> Functions to translate [[Integer]]s or [[com.vasileff.ceylon.integer64::Integer64]]s into Sequences of Bytes integerToBytes(941226); > <b>[0, 0, 0, 0, 0, $1110.byte, $0101_1100.byte, $1010_1010.byte]</b> integerToBytesNoZeros(941226); > <b>[$1110.byte, $0101_1100.byte, $1010_1010.byte]</b> Convenience function: helpString() to help output class string attributes. helpString("Thing", "Name"->"FirstThing", "Number"->1, "Optional"->null); > <b>"Thing:{Name=FirstThing,Number=1,Optional=null}"</b> Wrapper types for commonly used types to add unique typing. Example, in contexts where several Integer variables are used for different concepts such as AccountNumber, ReferenceNumber, etc Examples: class AccountNumber(Integer baseValue) extends WrappedInteger(baseValue) {} class ReferenceNumber(Integer baseValue) extends WrappedInteger(baseValue) {} value accountNum1 = AccountNumber("1"); value accountNum2 = AccountNumber("2"); value refNum1 = ReferenceNumber("1"); value refNum2 = ReferenceNumber("2"); assertFalse(accountNum1.equals(accountNum2); assertFalse(accountNum1.equals(referenceNum1); assertFalse(referenceNum2.equals(accountNum2); |
Last Published | Apr 9, 2016 |
Stats |
Downloads (JVM): 4003 Downloads (JS): 1283 Source downloads: 4813 |
Module links |
Home Code repository Issue tracker Imported By Browse |
0.0.14 | JVM JavaScript JVM: 1.2.x, 1.3.x (latest) JavaScript: 1.2.1, 1.2.2, 1.3.x (latest) | Published Apr 9, 2016 |
Browse |
View docs |
|
0.0.13 | JVM JavaScript JVM: 1.2.x, 1.3.x (latest) JavaScript: 1.2.1, 1.2.2, 1.3.x (latest) | Published Feb 14, 2016 |
Browse |
View docs |
|
0.0.12 | JVM JavaScript JVM: 1.2.x, 1.3.x (latest) JavaScript: 1.2.0 (outdated) | Published Nov 7, 2015 |
Browse |
View docs |
|
0.0.11 | JVM JavaScript JVM: 1.2.x, 1.3.x (latest) JavaScript: 1.2.0 (outdated) | Published Oct 30, 2015 |
Browse |
View docs |
|
0.0.10 | JVM JavaScript JVM: 1.1.0 (outdated) JavaScript: 1.1.0 (outdated) | Published Jul 1, 2015 |
Browse |
View docs |
|
0.0.9 | JVM JavaScript JVM: 1.1.0 (outdated) JavaScript: 1.1.0 (outdated) | Published Apr 28, 2015 |
Browse |
View docs |
|
0.0.8 | JVM JavaScript JVM: 1.1.0 (outdated) JavaScript: 1.1.0 (outdated) | Published Apr 25, 2015 |
Browse |
View docs |
|
0.0.7 | JVM JavaScript JVM: 1.1.0 (outdated) JavaScript: 1.1.0 (outdated) | Published Apr 18, 2015 |
Browse |
View docs |
|
0.0.6 | JVM JavaScript JVM: 1.1.0 (outdated) JavaScript: 1.1.0 (outdated) | Published Apr 5, 2015 |
Browse |
View docs |
|
0.0.5 | JVM JavaScript JVM: 1.1.0 (outdated) JavaScript: 1.1.0 (outdated) | Published Apr 4, 2015 |
Browse |
View docs |