@@ -0,0 +1,2135 @@
+/**%0A * Copyright 2016 Alessandro Daniele, Fabio Cesarato, Andrea Giraldin%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *     http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.salsaw.msalsa.services;%0A%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutputStream;%0A%0A/**%0A * Generic class that permit to serialize and deserialize object using standard Java object serialization%0A * %0A * @author Alessandro Daniele, Fabio Cesarato, Andrea Giraldin%0A *%0A */%0Apublic class ObjectSerializer%3CT%3E %7B%0A%0A%09private final String filePath;%0A%0A%09public ObjectSerializer(String filePath) %7B%0A%09%09if (filePath == null %7C%7C filePath.isEmpty() == true) %7B%0A%09%09%09throw new IllegalArgumentException(%22salsaParameters%22);%0A%09%09%7D%0A%0A%09%09this.filePath = filePath;%0A%09%7D%0A%0A%09/**%0A%09 * Read a Java object stored inside file system%0A%09 * %0A%09 * @param entity%0A%09 * @throws IOException%0A%09 */%0A%09public void serialize(T entity) throws IOException %7B%0A%09%09try (FileOutputStream fileOut = new FileOutputStream(this.filePath)) %7B%0A%09%09%09try (ObjectOutputStream out = new ObjectOutputStream(fileOut)) %7B%0A%09%09%09%09out.writeObject(entity);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * Write a Java object inside file system%0A%09 * %0A%09 * @return%0A%09 * @throws FileNotFoundException%0A%09 * @throws IOException%0A%09 * @throws ClassNotFoundException%0A%09 */%0A%09@SuppressWarnings(%22unchecked%22)%0A%09public T deserialize() throws FileNotFoundException, IOException, ClassNotFoundException %7B%0A%09%09try (FileInputStream fileIn = new FileInputStream(this.filePath)) %7B%0A%09%09%09try (ObjectInputStream in = new ObjectInputStream(fileIn)) %7B%0A%09%09%09%09return (T) in.readObject();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add generic class to serialize object