@Test public void testSave() throws Exception { RandomDataGenerator random = new RandomDataGenerator(new MersenneTwister(123)); NTupleRandomFactory nTupleRandomFactory = new NTupleRandomFactory(3, 5, new RectSize(8), -1.0, 1.0); List<NTuple> tuples = new ArrayList<>(); for (int i = 0; i < 10; ++i) { tuples.add(nTupleRandomFactory.create(random)); } NTuples ntuples = new NTuples(tuples, new RotationMirrorSymmetryExpander(new RectSize(8))); SerializationManager manager = SerializationManagerFactory.create(); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); try (SerializationOutput output = new BinarySerializationOutput(byteStream)) { manager.serialize(ntuples, output); } try (BinarySerializationInput input = new BinarySerializationInput(new ByteArrayInputStream( byteStream.toByteArray()))) { NTuples deserialized = manager.deserialize(input); Assert.assertEquals(ntuples, deserialized); } }
@Override public void save(SerializationManager manager, NTuples object, SerializationOutput output) throws IOException, SerializationException { manager.serialize(object.getMain(), output); output.writeInt(object.getAll().size()); for (NTuple symmetric : object.getAll()) { output.writeInt(getMainIdxForNTuple(symmetric, object.getMain())); output.writeIntArray(symmetric.getLocations()); } }
NTuplesSerializer implements ObjectSerializer<NTuples> { @Override public void save(SerializationManager manager, NTuples object, SerializationOutput output) throws IOException, SerializationException { manager.serialize(object.getMain(), output); output.writeInt(object.getAll().size()); for (NTuple symmetric : object.getAll()) { output.writeInt(getMainIdxForNTuple(symmetric, object.getMain())); output.writeIntArray(symmetric.getLocations()); } } }
NTuplesSerializer implements ObjectSerializer<NTuples> { @Override public void save(SerializationManager manager, NTuples object, SerializationOutput output) throws IOException, SerializationException { manager.serialize(object.getMain(), output); output.writeInt(object.getAll().size()); for (NTuple symmetric : object.getAll()) { output.writeInt(getMainIdxForNTuple(symmetric, object.getMain())); output.writeIntArray(symmetric.getLocations()); } }  }
NTuplesSerializer implements ObjectSerializer<NTuples> { @Override public void save(SerializationManager manager, NTuples object, SerializationOutput output) throws IOException, SerializationException { manager.serialize(object.getMain(), output); output.writeInt(object.getAll().size()); for (NTuple symmetric : object.getAll()) { output.writeInt(getMainIdxForNTuple(symmetric, object.getMain())); output.writeIntArray(symmetric.getLocations()); } }  @Override void save(SerializationManager manager, NTuples object, SerializationOutput output); @Override NTuples load(SerializationManager manager, SerializationInput input); @Override int getUniqueSerializerId(); }
NTuplesSerializer implements ObjectSerializer<NTuples> { @Override public void save(SerializationManager manager, NTuples object, SerializationOutput output) throws IOException, SerializationException { manager.serialize(object.getMain(), output); output.writeInt(object.getAll().size()); for (NTuple symmetric : object.getAll()) { output.writeInt(getMainIdxForNTuple(symmetric, object.getMain())); output.writeIntArray(symmetric.getLocations()); } }  @Override void save(SerializationManager manager, NTuples object, SerializationOutput output); @Override NTuples load(SerializationManager manager, SerializationInput input); @Override int getUniqueSerializerId();  }