Utility classes

Small helpers without framework dependencies. They exist here because at least two modules need them; anything used by one module only belongs in that module.

Class Purpose
KlokFastID randomUUID(): a random version 4 UUID drawn from ThreadLocalRandom instead of SecureRandom, so it never blocks or contends. Used for correlation ids, invocation ids and CloudEvent ids by the broker client, the Quarkus extension and the Gradle plugin. Not sortable, and never to be used as a secret or a token.
KlokGenericTypeResolver Interface with default methods that resolve the actual type arguments of a class at runtime, walking the hierarchy up to the class or interface that declares the parameter. Type variables bound by intermediate generic classes are followed to the concrete class, so class MyWorker extends Worker<A, B> with class Worker<REQ, RES> extends Processing<REQ, RES> resolves Processing's first parameter to A. The Quarkus extension uses it to find the datamodels of a route from its class signature; the gradle plugin's documentation scan uses the same rules on source level.
KlokDateHelper XMLGregorianCalendar conversions and formatting for the XSD generated datamodels (xmlGregCalNow, xmlGregCalFromDate, toFormattedString), and getDayOfWeek(Instant). The only implementation: the Quarkus extension's dev.klok.framework.helpers.KlokDateHelper is deprecated and delegates here.
KlokSymmetricEncryption AES-GCM encryption of short strings into URL-safe Base64, with a key derived from a password by PBKDF2 (deriveKey, getSecretKeyFor, encrypt, decrypt). Kept by decision as the shared implementation for encrypting caller ids; no project calls it today (Design decisions). Not for secrets at rest.
KlokStringUtils capitalizeFirstLetter, used by the repository naming.
JvmHelper Java version, home and vendor for log banners, sleep without checked exception; the Java broker client uses it.

Enums

  • ProjectType: INTEGRATION (int), DATAMODEL (mdl), APPLICATION (app), FRONTEND (gui), DOCUMENTATION (doc), LIBRARY (lib), OTHER (no segment). shortName() is the segment repoName puts in a repository name. The Gradle plugin's klok.projectType is a separate enum of its own (dev.klok.framework.gradle.model.ProjectType).
  • DomainType: GLOBAL (tenant wide), DOMAIN, SYSTEM, PUBLIC. Decides the name segment repoName adds for integration and datamodel projects and the segment projectPackageName adds to a package.

Both enums are used only by the repository and package naming in this library (Naming conventions). The documentation scope of a project is derived from its GitLab path by the documentation naming ports, not from these enums.

Tests

The unit tests are in src/test/java/dev/klok/framework/common (KlokFastIDTest, KlokDateHelperTest, KlokSymmetricEncryptionTest, KlokGenericTypeResolverTest); KlokGenericTypeResolverHierarchyTest documents the intermediate generic class case that broke the 1.x resolver. KlokStringUtils and JvmHelper have no test of their own.