Skip to content

Add 'InvertibleCodec' interface #542

Closed
@jenetics

Description

Extend the existing Codec interface, so it also contains an encoder function, which allows creating a Genotype from an existing decoded value T. This is done by introducing an Encoding interfaces.

public interface InvertibleCodec<T, G extends Gene<?, G>> extends Codec<T, G> {
	public Function<T, Genotype<G>> encoder();
	public default Genotype<G> encode(final T value) {
		return encoder().apply(value);
	}
}

All predefined Codec classes in the Codecs class should then return instances of the Encodec interface.

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions