addCopyFactory<E> static method
void
addCopyFactory<E>(
- dynamic factory
Add a new factory.
Each type E
can only have one factory associated with it.
factory
must be of type CopyFactory or DeepCopyFactory, otherwise
an ArgumentError will be thrown.
Implementation
// TODO(obemu): Change argument type of [factory] to [DeepCopyFactory<E>]
// when releasing version v2.0.0
static void addCopyFactory<E>(dynamic factory) {
final DeepCopyFactory<E> fac;
if (factory is CopyFactory<E>) {
fac = DeepCopyFactory<E>(factory);
} else if (factory is DeepCopyFactory<E>) {
fac = factory;
} else {
throw ArgumentError.value(
factory,
"factory",
"Must be of type CopyFactory<E> or DeepCopyFactory<E>",
);
}
_copyFactories.add(fac);
}