Note that there are some explanatory texts on larger screens.

plurals
  1. PONull pointer in my Facade :(
    primarykey
    data
    text
    <p>I've written a task manager, and well it;'s a long story... all in Java by the way. So I wrote a Facade which you can see below there is a problem with the HashMap and I suspect that the values which I attempt to add into the HashMap during the construction aren't going so well. The method that is triggering the null pointer exception is the create method. the input parameters to the method have been verified by me and my trusty debugger to be populated.</p> <p>any help here would be great... I'm sure I forgot to mention something so I'll reply to comments asap as I need to get this thing done now.</p> <pre><code>package persistence; import java.util.UUID; import java.util.HashMap; import persistence.framework.ComplexTaskRDBMapper; import persistence.framework.IMapper; import persistence.framework.RepeatingTaskRDBMapper; import persistence.framework.SingleTaskRDBMapper; public class PersistanceFacade { @SuppressWarnings("unchecked") private static Class SingleTask; @SuppressWarnings("unchecked") private static Class RepeatingTask; @SuppressWarnings("unchecked") private static Class ComplexTask; private static PersistanceFacade uniqueInstance = null; @SuppressWarnings("unchecked") private HashMap&lt;Class, IMapper&gt; mappers; public PersistanceFacade() { mappers = new HashMap&lt;Class, IMapper&gt;(); try { SingleTask = Class.forName("SingleTask"); RepeatingTask = Class.forName("RepeatingTask"); ComplexTask = Class.forName("ComplexTask"); mappers.put(SingleTask, new SingleTaskRDBMapper()); mappers.put(RepeatingTask, new RepeatingTaskRDBMapper()); mappers.put(ComplexTask, new ComplexTaskRDBMapper()); } catch (ClassNotFoundException e) {} } public static synchronized PersistanceFacade getUniqueInstance() { if (uniqueInstance == null) { uniqueInstance = new PersistanceFacade(); return uniqueInstance; } else return uniqueInstance; } public void create(UUID oid, Object obj) { IMapper mapper = (IMapper) mappers.get(obj.getClass()); mapper.create(oid, obj); } @SuppressWarnings("unchecked") public Object read(UUID oid, Class type) { IMapper mapper = (IMapper) mappers.get(type); return mapper.read(oid); } public void update(UUID oid, Object obj) { IMapper mapper = (IMapper) mappers.get(obj.getClass()); mapper.update(oid, obj); } @SuppressWarnings("unchecked") public void destroy(UUID oid, Class type) { IMapper mapper = (IMapper) mappers.get(type); mapper.destroy(oid); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload