package ch.uzh.csg.paymentlib.payment;

import ch.uzh.csg.paymentlib.exceptions.IllegalArgumentException;
import ch.uzh.csg.paymentlib.exceptions.NotSignedException;
import ch.uzh.csg.paymentlib.exceptions.UnknownCurrencyException;
import ch.uzh.csg.paymentlib.exceptions.UnknownSignatureAlgorithmException;

//TODO: javadoc
public class DecoderFactory {
	
	@SuppressWarnings("unchecked")
	public static <T extends SerializableObject> T decode(Class<? extends SerializableObject> clazz, byte[] bytes) throws IllegalAccessException, IllegalArgumentException, NotSignedException, UnknownSignatureAlgorithmException, UnknownCurrencyException {
		try {
			T t = (T) clazz.newInstance();
			t.decode(bytes);
			return t;
		} catch (InstantiationException e) {
			return null;
		}
	}
	
}

@@ -515,32 +515,8 @@
 rows
- IllegalAccessException,
  Ill
@@ -758,16 +758,73 @@
  null;%0D%0A
+%09%09%7D catch (IllegalAccessException e) %7B%0D%0A%09%09%09return null;%0D%0A
 %09%09%7D%0D%0A%09%7D%0D

Edit DecoderFactory, catch exception instead of throwing it.