/walkingkooka

Contains a lot of building blocks to do common tasks well in fewer lines of code and more elegantly as well as numerous helpers to improve testing and legibility of tests.

Primary LanguageJavaApache License 2.0Apache-2.0

Build Status Coverage Status License Language grade: Java Total alerts J2CL compatible

Basic Project

A very brief overview of some larger more powerful features and the small are available in this and child projects, that do much much more leveraging the basic fundamentals present in this library. One example of the utility is presented below. Most if not all values and abstractions are immutable, functional and provide helpers to assist in creation of implementations.

  • A collection of List, Set, Map, and Stack abstractions, may of which are immutable.
  • ImmutableList an immutable List with would be mutator methods such as concat, replace and more.
  • ImmutableListDefaults an ImmutableList implementation leaving only a single method to be implemented (aka equivalent of AbstractList for List).
  • Many additional adaptors missing from the JDK
  • Many factory methods are available for the various implementations.
  • Factory methods are available that provide a Concurrent implementations in a JRE but a regular when translated to javascript, which is single threaded anyway.

[*.comparator]

  • NullAwareAfterComparator - wraps another comparator, so nulls sort AFTER non null sorted values.
  • NullAwareBeforeComparator - wraps another comparator, so nulls sort BEFORE non null sorted values.
  • Many additional Predicate(s).
  • A new interface CharPredicate replacing the need for IntPredicate.
  • Many useful and interesting implementations.

-ClassVisitor advanced visitor over different members of a single class and its hierarchy. Useful to visit class members, super classes and similar. -JavaVisibility object oriented abstraction of class and member visibilities with numerous useful operations.

  • New functional abstractions for many JDK class components, such as ClassName, FieldName, MethodName replacing the need for String for said names in some APIS.
  • Abstractions like ClassAttributes, FieldAttributes, MethodAttributes which provide oo methods rather than using bit patterns.
  • Several interfaces with defender methods (think mixin) that assist with testing class structure and members.
  • A Stream implementation that sources Nodes from a Consumer.
  • CaseSensitivity Useful case sensitivity String to CharSequences, like startsWith, endsWidth, index, equals
  • CharSequences Supports many of the useful String methods and more for CharSequence using a CaseSensitivity
  • GlobPattern May be used to match glob patterns where question mark matches a single char, and star zero or more, eg /user/Miroslav/*.txt (all text files under) or /user/Miroslav/???.txt (three letter txt files)
  • TextCursor provides a cursor that may be used to advance over text, one character at a time.
  • TextCursorSavePoint Multiple save points may be created and used to reset the TextCursor at any time.
  • TextCursorLineInfo Describe the column, line position and more of the TextCursor within its text.
  • Collection of misc interfaces and useful abstractions.

Goals and problems attempting to solve:

  • A Context typically accompanies one or more other values which need some task to be performed.
  • The JDK typically mixes user context such as a Locale along with the NumberFormat and its symbols.
  • In this design the compiled pattern separate from the user context Locale, which means customisation of the Locale and similar symbols can be done on at the request level keeping the original parser or formatter unmodified.
  • This means that all parsers/formatters and similar workers are immutable, functional and threadsafe, unlike DateFormat and other JRE classes.

Numerous projects provide specialised Context which add properties and methods to assist a task, eg the users Locale or number formatting symbols. Some examples include:

  • DateTimeContext symbols, locale, month names and more. Simple another parameter accompanying the LocalDate.
  • DecimalNumberContext symbols, locale, grouping separator count and more. Simple another parameter accompanying the Number.
  • Either is immutable and holds either of two values, but never none or both.
  • Numerous functional methods (map etc) are available to operate on either value.

A better Object#toString builder that actually produces significantly more readable output when compared to Guava and Apache Common equivalents.

  • Automatic quoting and escaping of char (within single quotes) and CharSequences (within double quotes) even when within collections.
  • Skip default values for primitives and Strings (eg skip properties that are boolean=true, numeric=0 etc)
  • Assign labels with values, labels can be skipped if the value is skipped.
  • Support for hex representation of bytes
  • All the above can be enabled or disabled.
  • Customizable separators for non scalar values (arrays, collections etc)
  • See Public API.
  • See Unit tests for more examples of usage and the product.