Insubstantial/insubstantial — pull request #82 by kschaefe (2012-07-13 15:51:25+00:00)
Title: Insubstantial Issue #68: BaseColorScheme API too limiting

https://github.com/Insubstantial/insubstantial/issues/68

Reworked the derived colors and BaseColorScheme to use immutable,
flyweights and forward resolvers to derived color schemes.

This change introduces new API:
- SchemeDerivedColorsResolver is similar to SchemeDerivedColors, but
each method takes a SubstanceColorScheme. This allows
implementations to create classes that are preferably immutable,
but, at the very least, stateless. Note class documentation asks
implementations to be immutable.
- BaseColorScheme gains a new protected constructor that takes a
SchemeDerivedColorsResolver. This allows derived color schemes to
reuse the same color resolver.
- Both the original BaseColorScheme constructor and the new
SchemeDerivedColorsResolver one defer to a third private
constructor.

This change attempts to maintain backward compatibility:
- SchemeDerivedColorsResolver contains an isDark method. This is
designed to ease migration for current SubstanceColorScheme
implementations.
- The BaseColorScheme private constructor helps maintain the backwards
compatibility by allowing the isDark nature to be retained.
- The new protected static method BaseColorScheme.getResolver aids
implementations is determining the current
SchemeDerivedColorsResolver and more easily use the new
BaseColorScheme constructor.

This change is API breaking in the following ways:
- The SchemeDerivedColorsResolver interface (new) replaces the current
interface parent of SchemeDerivedColors for
DerivedColorsResolverLight and DerivedColorsResolverDark. It also
replaces the SchemeDerivedColors for the field
BaseColorScheme.derivedColorsResolver.

This change introduces the following unresolved bugs:
- Because SchemeDerivedColorsResolver implementations are supposed to
be immutable, the current implementations should be made final. One
of them, DerivedColorsResolverLight, is public and cannot be made
final without adding more API breakage, cf. previous section.