Add Particle#copy (#4126)

This commit is contained in:
RK_01 2024-08-29 15:32:28 +02:00 committed by GitHub
parent 32e51b52aa
commit 5017d4bbb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,6 +72,14 @@ public final class Particle implements IdHolder {
arguments.set(index, new ParticleData<>(type, value));
}
public Particle copy() {
final Particle particle = new Particle(id);
for (ParticleData<?> argument : arguments) {
particle.arguments.add(argument.copy());
}
return particle;
}
@Override
public String toString() {
return "Particle{" +
@ -109,6 +117,10 @@ public final class Particle implements IdHolder {
wrapper.write(type, value);
}
public ParticleData<T> copy() {
return new ParticleData<>(type, value);
}
@Override
public String toString() {
return "ParticleData{" +