Fork me on GitHub

Maven Central Build Status Test Status Coverage

Introduction

This project is a collection of miscellaneous tools shared by a number of projects of the same author. There are simple tuples to use with Java Streams, type-safe maps (following advice of Joshua Bloch), a finder that handles in a smart way queries to data sources, a facility to use the DCI (Data, Context and Interactions) architectural pattern, a simple message bus suitable for using the pub-sub pattern inside an application, some test utilities, an experimental actor framework and a few other small things.

Yes, the project name is a tribute to the jazz standard with the same name by Maschwitz and Strachey.

The project is composed of mostly independent modules, with different levels of stability and internal quality. At the moment there is not an automatic system to check the compatibility of the APIs from version to version; in general look at the following Javadoc tags:

  • stable: to designate things with a certain degree of maturity.
  • draft: to designate things that are going to stabilise;
  • experimental: to designate things that are really raw and might go away soon, or perhaps mutate dramatically;

TheseFoolishThings is licensed with the Apache license.

A quick look

Here it is a quick look at some of the available features.

Pair and Triple

Pair and Triple are implementations of 2 and 3-elements tuples. They are pretty useful in Stream programming, for instance offering a way to implement nested loops:

final var actual = IntStream.rangeClosed(1, limit)
                            .boxed()
                            .flatMap(a -> Pair.pairRangeClosed(a, a + 1, limit))
                            .flatMap(p -> Triple.tripleRangeClosed(p, p.b + 1, limit))
                            .collect(toList());

… or indexed loops:

final var actual =  IntStream.rangeClosed(1, limit)
                             .boxed()
                             .flatMap(a -> Pair.pairRangeClosed(a, a + 1, limit))
                             .collect(toList());

Finder

Finder is a query builder with a fluent API that allows to access collections of data from a variety of data sources. It offers features such as pagination and composition. Its API is extensible, so a variety of filtering criteria and query parameters can be specified. Notwithstanding the apparent similarity with Streams, it is quite different since it supports not only in-memory operations; for instance, implementations can query a database by generating ad-hoc SQL, so data are retrieved in the most efficient way.

        log.info("Whose first name starts with B: {}",
                 registry.findPerson()
                         .withFirstName("B.*")
                         .results());

        log.info("Whose first name starts with B, sorted by first name: {}",
                 registry.findPerson()
                         .sort(BY_FIRST_NAME)
                         .withFirstName("B.*")
                         .results());

As

As provides a dynamic implementation of the Data, Context and Interaction architectural pattern — dynamic in the sense that classes providing interaction support can be associated to existing objects. For instance, in the following code Displayable and Renderable are not known to the model class Person, but they are available at runtime in association with that class to provide extended functions:

@ExtensionMethod(AsExtensions.class) @Slf4j
public class DisplayableExample
  {
    public void run()
      {
        final var joe = new Person(new Id("1"), "Joe", "Smith");
        final var luke = new Person(new Id("2"), "Luke", "Skywalker");
        // approach with classic getter
        log.info("******** (joe as Displayable).displayName: {}", joe.as(_Displayable_).getDisplayName());
        log.info("******** (luke as Displayable).displayName: {}", luke.as(_Displayable_).getDisplayName());
        // approach oriented to Tell Don't Ask
        joe.as(_Renderable_).renderTo("******** (joe as Renderable): %1$s %2$s ", log::info);
        luke.as(_Renderable_).renderTo("******** (luke as Renderable): %1$s %2$s ", log::info);
      }
  }

P&S MessageBus

PENDING INTRODUCTION AND EXAMPLE

Collaborative Actors

PENDING INTRODUCTION AND EXAMPLE

Type-safe maps

PENDING INTRODUCTION AND EXAMPLE

Modules

General information

Maven dependency

Since most modules can be used independently, Maven dependency information is available in their specific documentation.

Sources, issue tracker and continuous integration

The primary source repository is on Bitbucket, a secondary repository (synchronized in real time) is available on GitHub.

To checkout sources from Bitbucket:

> git clone https://bitbucket.org/tidalwave/thesefoolishthings-src

To checkout sources from GitHub:

> git clone https://github.com/tidalwave-it/thesefoolishthings-src

The issue tracker is hosted on the Atlassian Jira Cloud:

The continuous integration is available at:

API documentation

Aggregate Javadoc