Skip to content

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed May 3, 2024
1 parent 9b1d07c commit f3bfff4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
94 changes: 48 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,52 +39,54 @@ implementation 'com.cedarsoftware:java-util:2.9.0'
---

Included in java-util:
* **ArrayUtilities** - Useful utilities for working with Java's arrays `[]`
* **ByteUtilities** - Useful routines for converting `byte[]` to HEX character `[]` and visa-versa.
* **ClassUtilities** - Useful utilities for Class work. For example, call `computeInheritanceDistance(source, destination)` to get the inheritance distance (number of super class steps to make it from source to destination. It will return the distance as an integer. If there is no inheritance relationship between the two,
then -1 is returned. The primitives and primitive wrappers return 0 distance as if they are the
same class.
* **Sets**
* **CompactSet** - Small memory footprint `Set` that expands to a `HashSet` when `size() > compactSize()`.
* **CompactLinkedSet** - Small memory footprint `Set` that expands to a `LinkedHashSet` when `size() > compactSize()`.
* **CompactCILinkedSet** - Small memory footprint `Set` that expands to a case-insensitive `LinkedHashSet` when `size() > compactSize()`.
* **CompactCIHashSet** - Small memory footprint `Set` that expands to a case-insensitive `HashSet` when `size() > compactSize()`.
* **CaseInsensitiveSet** - `Set` that ignores case for `Strings` contained within.
* **ConcurrentSet** - A thread-safe `Set` which does not require each element to be `Comparable` like `ConcurrentSkipListSet` which is a `NavigableSet,` which is a `SortedSet.`
* **SealableSet** - Provides a `Set` (or `Set` wrapper) that will make it read-only (sealed) or read-write (unsealed), controllable via a `Supplier<Boolean>.` This moves the immutability control outside the `Set` and ensures that all views on the `Set` respect the sealed-ness. One master supplier can control the immutability of many collections.
* **SealableNavigableSet** - Provides a `NavigableSet` (or `NavigableSet` wrapper) that will make it read-only (sealed) or read-write (unsealed), controllable via a `Supplier<Boolean>.` This moves the immutability control outside the `NavigableSet` and ensures that all views on the `NavigableSet` respect the sealed-ness. One master supplier can control the immutability of many collections.
* **Maps**
* **CompactMap** - Small memory footprint `Map` that expands to a `HashMap` when `size() > compactSize()` entries.
* **CompactLinkedMap** - Small memory footprint `Map` that expands to a `LinkedHashMap` when `size() > compactSize()` entries.
* **CompactCILinkedMap** - Small memory footprint `Map` that expands to a case-insensitive `LinkedHashMap` when `size() > compactSize()` entries.
* **CompactCIHashMap** - Small memory footprint `Map` that expands to a case-insensitive `HashMap` when `size() > compactSize()` entries.
* **CaseInsensitiveMap** - `Map` that ignores case when `Strings` are used as keys.
* **LRUCache** - Thread safe LRUCache that implements the full Map API and supports a maximum capacity. Once max capacity is reached, placing another item in the cache will cause the eviction of the item that was the least recently used (LRU).
* **TrackingMap** - `Map` class that tracks when the keys are accessed via `.get()` or `.containsKey()`. Provided by @seankellner
* **SealableMap** - Provides a `Map` (or `Map` wrapper) that will make it read-only (sealed) or read-write (unsealed), controllable via a `Supplier<Boolean>.` This moves the immutability control outside the `Map` and ensures that all views on the `Map` respect the sealed-ness. One master supplier can control the immutability of many collections.
* **SealableNavigbableMap** - Provides a `NavigableMap` (or `NavigableMap` wrapper) that will make it read-only (sealed) or read-write (unsealed), controllable via a `Supplier<Boolean>.` This moves the immutability control outside the `NavigableMap` and ensures that all views on the `NavigableMap` respect the sealed-ness. One master supplier can control the immutability of many collections.
* **Lists**
* **ConcurrentList** - Provides a thread-safe `List` (or `List` wrapper). Use the no-arg constructor for a thread-safe `List,` use the constructor that takes a `List` to wrap another `List` instance and make it thread-safe (no elements are copied).
* **SealableList** - Provides a `List` (or `List` wrapper) that will make it read-only (sealed) or read-write (unsealed), controllable via a `Supplier<Boolean>.` This moves the immutability control outside the `List` and ensures that all views on the `List` respect the sealed-ness. One master supplier can control the immutability of many collections.

* **Converter** - Convert from one instance to another. For example, `convert("45.3", BigDecimal.class)` will convert the `String` to a `BigDecimal`. Works for all primitives, primitive wrappers, `Date`, `java.sql.Date`, `String`, `BigDecimal`, `BigInteger`, `AtomicBoolean`, `AtomicLong`, etc. The method is very generous on what it allows to be converted. For example, a `Calendar` instance can be input for a `Date` or `Long`. Call the method `Converter.getSupportedConversions()` or `Converter.allSupportedConversions()` to get a list of all source/target conversions. Currently, there are 680+ conversions.
* **DateUtilities** - Robust date String parser that handles date/time, date, time, time/date, string name months or numeric months, skips comma, etc. English month names only (plus common month name abbreviations), time with/without seconds or milliseconds, `y/m/d` and `m/d/y` ordering as well.
* **DeepEquals** - Compare two object graphs and return 'true' if they are equivalent, 'false' otherwise. This will handle cycles in the graph, and will call an `equals()` method on an object if it has one, otherwise it will do a field-by-field equivalency check for non-transient fields. Has options to turn on/off using `.equals()` methods that may exist on classes.
* **IO**
* **FastReader** - Works like `BufferedReader` and `PushbackReader` without the synchronization. Tracks `line` and `col` by watching for `0x0a,` which can be useful when reading text/json/xml files. You can `.pushback()` a character read, which is very useful in parsers.
* **FastWriter** - Works like `BufferedWriter` without the synchronization.
* **FastByteArrayInputStream** - Unlike the JDK `ByteArrayInputStream`, `FastByteArrayInputStream` is not `synchronized.`
* **FastByteArrayOutputStream** - Unlike the JDK `ByteArrayOutputStream`, `FastByteArrayOutputStream` is not `synchronized.`
* **IOUtilities** - Handy methods for simplifying I/O including such niceties as properly setting up the input stream for HttpUrlConnections based on their specified encoding. Single line `.close()` method that handles exceptions for you.
* **EncryptionUtilities** - Makes it easy to compute MD5, SHA-1, SHA-256, SHA-512 checksums for `Strings`, `byte[]`, as well as making it easy to AES-128 encrypt `Strings` and `byte[]`'s.
* **Executor** - One line call to execute operating system commands. `Executor executor = new Executor(); executor.exec('ls -l');` Call `executor.getOut()` to fetch the output, `executor.getError()` retrieve error output. If a -1 is returned, there was an error.
* **GraphComparator** - Compare any two Java object graphs. It generates a `List` of `Delta` objects which describe the difference between the two Object graphs. This Delta list can be played back, such that `List deltas = GraphComparator.delta(source, target); GraphComparator.applyDelta(source, deltas)` will bring source up to match target. See JUnit test cases for example usage. This is a completely thorough graph difference (and apply delta), including support for `Array`, `Collection`, `Map`, and object field differences.
* **MathUtilities** - Handy mathematical algorithms to make your code smaller. For example, minimum of array of values.
* **ReflectionUtils** - Simple one-liners for many common reflection tasks. Speedy reflection calls due to Method caching.
* **StringUtilities** - Helpful methods that make simple work of common `String` related tasks.
* **SystemUtilities** - A Helpful utility methods for working with external entities like the OS, environment variables, and system properties.
* **Traverser** - Pass any Java object to this Utility class, it will call your passed in anonymous method for each object it encounters while traversing the complete graph. It handles cycles within the graph. Permits you to perform generalized actions on all objects within an object graph.
* **UniqueIdGenerator** - Generates unique Java long value, that can be deterministically unique across up to 100 servers in a cluster (if configured with an environment variable), the ids are monotonically increasing, and can generate the ids at a rate of about 10 million per second. Because the current time to the millisecond is embedded in the id, one can back-calculate when the id was generated.
## Included in java-util:
- **ArrayUtilities** - Provides utilities for working with Java arrays `[]`, enhancing array operations.

- **ByteUtilities** - Offers routines for converting `byte[]` to hexadecimal character arrays and vice versa, facilitating byte manipulation.

- **ClassUtilities** - Includes utilities for class-related operations. For example, the method `computeInheritanceDistance(source, destination)` calculates the number of superclass steps between two classes, returning it as an integer. If no inheritance relationship exists, it returns -1. Distances for primitives and their wrappers are considered as 0, indicating no separation.

### Sets
- **CompactSet** - A memory-efficient `Set` that expands to a `HashSet` when `size() > compactSize()`.
- **CompactLinkedSet** - A memory-efficient `Set` that transitions to a `LinkedHashSet` when `size() > compactSize()`.
- **CompactCILinkedSet** - A compact, case-insensitive `Set` that becomes a `LinkedHashSet` when expanded.
- **CompactCIHashSet** - A small-footprint, case-insensitive `Set` that expands to a `HashSet`.
- **CaseInsensitiveSet** - A `Set` that ignores case sensitivity for `Strings`.
- **ConcurrentSet** - A thread-safe `Set` not requiring elements to be comparable, unlike `ConcurrentSkipListSet`.
- **SealableSet** - Allows toggling between read-only and writable states via a `Supplier<Boolean>`, managing immutability externally.
- **SealableNavigableSet** - Similar to `SealableSet` but for `NavigableSet`, controlling immutability through an external supplier.

### Maps
- **CompactMap** - A `Map` with a small memory footprint that scales to a `HashMap` as needed.
- **CompactLinkedMap** - A compact `Map` that extends to a `LinkedHashMap` for larger sizes.
- **CompactCILinkedMap** - A small-footprint, case-insensitive `Map` that becomes a `LinkedHashMap`.
- **CompactCIHashMap** - A compact, case-insensitive `Map` expanding to a `HashMap`.
- **CaseInsensitiveMap** - Treats `String` keys in a case-insensitive manner.
- **LRUCache** - A thread-safe LRU cache implementing the full Map API, managing items based on usage.
- **TrackingMap** - Tracks access patterns to its keys, aiding in performance optimizations.
- **SealableMap** - Allows toggling between sealed (read-only) and unsealed (writable) states, managed externally.
- **SealableNavigableMap** - Extends `SealableMap` features to `NavigableMap`, managing state externally.

### Lists
- **ConcurrentList** - Provides a thread-safe `List` that can be either an independent or a wrapped instance.
- **SealableList** - Enables switching between sealed and unsealed states for a `List`, managed via an external `Supplier<Boolean>`.

### Additional Utilities
- **Converter** - Facilitates type conversions, e.g., converting `String` to `BigDecimal`. Supports a wide range of conversions.
- **DateUtilities** - Robustly parses date strings with support for various formats and idioms.
- **DeepEquals** - Deeply compares two object graphs for equivalence, handling cycles and using custom `equals()` methods where available.
- **IO Utilities**
- **FastReader** and **FastWriter** - Provide high-performance alternatives to standard IO classes without synchronization.
- **FastByteArrayInputStream** and **FastByteArrayOutputStream** - Non-synchronized versions of standard Java IO byte array streams.
- **EncryptionUtilities** - Simplifies the computation of checksums and encryption using common algorithms.
- **Executor** - Simplifies the execution of operating system commands with methods for output retrieval.
- **GraphComparator** - Compares two object graphs and provides deltas, which can be applied to synchronize the graphs.
- **MathUtilities** - Offers handy mathematical operations and algorithms.
- **ReflectionUtils** - Provides efficient and simplified reflection operations.
- **StringUtilities** - Contains helpful methods for common `String` manipulation tasks.
- **SystemUtilities** - Offers utilities for interacting with the operating system and environment.
- **Traverser** - Allows generalized actions on all objects within an object graph through a user-defined method.
- **UniqueIdGenerator** - Generates unique identifiers with embedded timing information, suitable for use in clustered environments.

See [changelog.md](/changelog.md) for revision history.

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cedarsoftware/util/UniqueIdGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private static int getServerId(String externalVarName) {
* To set the unique machine index value, set the environment variable JAVA_UTIL_CLUSTERID to a unique two-digit
* number on each machine in the cluster. If the machines are in a managed container, the uniqueId will use the
* hash of the hostname, first byte of hash, modulo 100 to provide unique machine ID. If neither of these
* environment variables are set, will it resort to using a secure random number from 00 to 99 for the machine
* environment variables are set, it will resort to using a secure random number from 00 to 99 for the machine
* instance number portion of the unique ID.<br>
* <br>
* This API is slower than the 19 digit API. Grabbing a bunch of IDs in a tight loop for example, could cause
Expand Down Expand Up @@ -175,7 +175,7 @@ private static long getUniqueIdAttempt() {
/**
* ID format will be 1234567890123.9999.99 (no dots - only there for clarity - the number is a long). There are
* 13 digits for time - milliseconds since Jan 1, 1970. This is followed by a count that is 0000 through 9999.
* This is followed by a random 2 digit number. This number is chosen when the JVM is started and then stays fixed
* This is followed by a random 2-digit number. This number is chosen when the JVM is started and then stays fixed
* until next restart. This is to ensure uniqueness within cluster.<br>
* <br>
* Because there is the possibility two machines could choose the same random number and be at the same count, at the
Expand Down

0 comments on commit f3bfff4

Please sign in to comment.