Algorithm contains this deepCopy method:
@Nonnull
@Override
public INode deepCopy() {
Algorithm copy = new Algorithm(this);
for (INode child : this.children.values()) {
copy.children.put(child.getKind(), child.deepCopy());
}
return copy;
}
All the algorithms (AES, ...) are extending Algorithm, so they get this deepCopy method. However, calling it on an AES object does not create an AES instance but an Algorithm instance (creating later problems when relying on instanceof, in the enricher for example).
To solve this, the only solution is probably to add each subclass of Algorithm a "copy" constructor (like AES(AES aes), calling the super "copy" constructor of Algorithm given below) and to overwrite the deepCopy() method, in which we instantiate a new AES using this constructor.
private Algorithm(@Nonnull Algorithm algorithm) {
this.children = new HashMap<>();
this.kind = algorithm.kind;
this.detectionLocation = algorithm.detectionLocation;
this.name = algorithm.name;
}
Algorithmcontains thisdeepCopymethod:All the algorithms (AES, ...) are extending
Algorithm, so they get thisdeepCopymethod. However, calling it on anAESobject does not create anAESinstance but anAlgorithminstance (creating later problems when relying oninstanceof, in theenricherfor example).To solve this, the only solution is probably to add each subclass of
Algorithma "copy" constructor (likeAES(AES aes), calling the super "copy" constructor ofAlgorithmgiven below) and to overwrite thedeepCopy()method, in which we instantiate a newAESusing this constructor.