public static <T> T checkNullOrNotInstance(T goodInstance, Object obj) {
		if (goodInstance == null) {
			throw new NullPointerException("first parameter must not be null");
		}
		
		@SuppressWarnings("unchecked")
		Class<T> classT = (Class<T>) goodInstance.getClass();
		
		boolean viable = true;

		if (obj == null)  viable = false;
		else if (!(classT.isInstance(obj)))  viable = false;

		if (viable) {
			return classT.cast(obj);
		}
		return null;
	}