Classes - craterdog/java-primitive-types GitHub Wiki
The Java Primitive Types is a group of immutable primitive object types (classes) that provide useful abstractions. For a more detailed view of the model below, click here.
Each primitive class in this project extends the Primitive
class which implements the canonical methods defined by the java.lang.Object
class:
String toString()
int hashCode()
boolean equals(Object object)
int compareTo(T object)
This primitive class encapsulates the mathematical concept of an angle in radians. All angles are normalized to the range (-pi..pi] to be consistent with convention. In addition to the canonical java.lang.Object
methods, this class implements the following (static) functions that operate on angles:
Angle inverse(Angle angle)
Angle negative(Angle angle)
Angle sum(Angle angle1, Angle angle2)
Angle difference(Angle angle1, Angle angle2)
Angle product(Angle angle, double multiplier)
Angle quotient(Angle angle, double divisor)
double sine(Angle angle)
Angle arcsine(double ratio)
double cosine(Angle angle)
Angle arccosine(double ratio)
double tangent(Angle angle)
Angle arctangent(double ratio)
Angle arctangent(double x, double y)
This primitive class encapsulates the mathematical concept of a probability. All probabilities lie in the range [0.0..1.0]. In addition to the canonical java.lang.Object
methods, this class implements the following additional methods:
boolean toBoolean()
double toDouble()
This class also implements the following (static) functions that operate on probabilities:
boolean coinToss(Probability probability)
Probability not(Probability value)
Probability and(Probability value1, Probability value2)
Probability sans(Probability value1, Probability value2)
Probability or(Probability value1, Probability value2)
Probability xor(Probability value1, Probability value2)
This primitive class encapsulates an arbitrary number of random bytes in a way that can be used as a unique identifier within a certain size space of "things". The tags are formatted in a way that makes them easy to view. The following shows some examples of various length tags:
Tag size 0 bytes:
Tag size 1 bytes: 2R
Tag size 2 bytes: 5V00
Tag size 5 bytes: WHQGXSY4
Tag size 8 bytes: 2PP8JYQVZBRG8
Tag size 12 bytes: DP02NM4W1F3B2J8XC5XH
Tag size 16 bytes: 4C6CZVXZRT0YFBGTD9WXZQWT4W
Tag size 20 bytes: 8262KJCK8HRR08G10M5X7HY15X91RTYF
Tag size 27 bytes: A5C2B4LMFNQZF508FGFC44C92YCFT5G0BYB8B5MCJN70
Tag size 32 bytes: AS5RH03BP0ACP5H980J3MQZNPAK6D3L4P4Z2GH20R052HB8NC160
Each tag is formatted as a base 32 ('0'..'9', 'A'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z') string representation of the random bytes that define the tag. The bigger the tag the less likely there will be a collision and the more likely that it will be unique. To see how to choose a tag size for your application click here.
In addition to the canonical java.lang.Object
methods, this class implements the following additional methods:
byte[] toBytes()
It also implements the following (static) function:
int stringSize(int tagSize)
This primitive class enhances the behavior of the java.lang.String
class by adding the ability for its characters to be iterated over within the standard Java for each
loops. In addition to the canonical java.lang.Object
methods and the methods defined by the java.lang.String
class, this class implements the following additional methods that are defined in the craterdog.core.Sequential<Character>
interface:
Iterator<Character> getIterator()
boolean isEmpty()
int getSize()
Character[] toArray()
This primitive class encapsulates the behavior of a byte array by adding the ability for its bytes to be iterated over within the standard Java for each
loops. It also allows the binary data that is encapsulated to be formatted into strings of various numeric bases (2, 16, 32, 64). In addition to the canonical java.lang.Object
methods and the methods defined by the java.lang.Object
class, this class implements the following additional methods that are defined in the craterdog.core.Composite
and craterdog.core.Sequential<Byte>
interfaces and in the class itself:
Iterator<Byte> getIterator()
String toString(int base)
String toString(String indentation)
String toString(String indentation, int base)
byte[] toBytes()
boolean isEmpty()
int getSize()
Byte[] toArray()