NameDerivative class

A name derivative builder.

This builder knows how to take a name from distinct raw forms and build its derivatives through a state management mechanism. That is, as the name changes, its derivatives (or states) are persisted and notified to any subscriber listening to those changes, thanks to a StreamController that broadcasts them.

The builder starts by creating an initial state of the created name. If a change event occurs to this name, this change is hence viewed as the current name state to consider, and the previous one becomes history. As this works like a state store, this gives a rollback flexibility in case an undesired change is made.

Once the builder finishes building up the name, the changes are committed and the store is freed as well as the StreamController for performance purposes. That means, the builder may no longer change the final name state and should live up to that last change.

In the following example, a subscriber prints out the different states of the name: Jane Ann Doe.

var derivative = Namefully('Jane Ann Doe').derivative
  ..stream.listen((d) => print('stream name: $d'))
  ..shorten()     // stream name: 'Jane Doe'
  ..upper()       // stream name: 'JANE DOE'
  ..byLastName()  // stream name: 'DOE JANE'
  ..lower();      // stream name: 'doe jane'
print(derivative.done()); // 'doe jane'

NOTE: Most of the operations supported here can be performed using Namefully.format. This builder is an expensive operation and should be used in specific use cases, or when judged extremely necessary. Otherwise, keep it sane and simple using the traditional Namefully class.

Constructors

NameDerivative.of(Namefully instance)
Creates name derivatives, starting from this first instance.

Properties

context Namefully
The name for the current context.
no setter
hashCode int
The hash code for this object.
no setterinherited
isDone bool
Whether the builder is still open for more nesting operations.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<Namefully>
The name changes made available for listeners.
no setter

Methods

byFirstName() → void
Arranges the name by NameOrder.firstName.
byLastName() → void
Arranges the name by NameOrder.lastName.
close() → void
Closes this builder on demand.
done() Namefully
Returns the final state of the changing name.
flip() → void
Flips definitely the name order from the current config.
lower() → void
Transforms a birth name into lowercase.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rollback() → void
Rolls back to the previous context.
shorten() → void
Shortens a full name to a typical name, a combination of first and last name.
toString() String
A string representation of this object.
override
upper() → void
Transforms a birth name into UPPERCASE.

Operators

operator ==(Object other) bool
The equality operator.
inherited