fix some compiler warnings after tweaking what it warns on
This commit is contained in:
parent
401b3fed2e
commit
ce273d533c
|
@ -1,13 +1,5 @@
|
|||
package net.socialgamer.cah;
|
||||
|
||||
import net.socialgamer.cah.db.BlackCard;
|
||||
import net.socialgamer.cah.db.WhiteCard;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
@ -18,6 +10,14 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.socialgamer.cah.db.BlackCard;
|
||||
import net.socialgamer.cah.db.WhiteCard;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
|
||||
|
||||
/**
|
||||
* Servlet implementation class TestServlet
|
||||
|
@ -44,23 +44,24 @@ public class TestServlet extends HttpServlet {
|
|||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
@Override
|
||||
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
final PrintWriter out = response.getWriter();
|
||||
// ServletOutputStream out = response.getOutputStream();
|
||||
Session session = sessionFactory.openSession();
|
||||
@SuppressWarnings("rawtypes")
|
||||
List b = session.createQuery("from BlackCard order by random()").list();
|
||||
for (BlackCard bc : (List<BlackCard>) b) {
|
||||
final Session session = sessionFactory.openSession();
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<BlackCard> b = session.createQuery("from BlackCard order by random()").list();
|
||||
for (final BlackCard bc : b) {
|
||||
out.println(StringEscapeUtils.escapeHtml4(bc.toString()));
|
||||
}
|
||||
|
||||
out.println("\n\n\n");
|
||||
@SuppressWarnings("rawtypes")
|
||||
List w = session.createQuery("from WhiteCard order by random()").list();
|
||||
for (WhiteCard wc : (List<WhiteCard>) w) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<WhiteCard> w = session.createQuery("from WhiteCard order by random()").list();
|
||||
for (final WhiteCard wc : w) {
|
||||
out.println(StringEscapeUtils.escapeHtml4(wc.toString()));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,20 +10,20 @@ import org.hibernate.Session;
|
|||
|
||||
|
||||
public class BlackDeck {
|
||||
private List<BlackCard> deck;
|
||||
private List<BlackCard> dealt;
|
||||
private final List<BlackCard> deck;
|
||||
private final List<BlackCard> dealt;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BlackDeck() {
|
||||
Session session = HibernateUtil.instance.sessionFactory.openSession();
|
||||
deck = (List<BlackCard>) session.createQuery("from BlackCard order by random()").list();
|
||||
final Session session = HibernateUtil.instance.sessionFactory.openSession();
|
||||
deck = session.createQuery("from BlackCard order by random()").list();
|
||||
dealt = new ArrayList<BlackCard>();
|
||||
}
|
||||
|
||||
public BlackCard getNextCard() {
|
||||
// Without knowing what the implementation of List that Hibernate returns
|
||||
// is, I'm going to pull from the end instead of the beginning.
|
||||
BlackCard card = deck.get(deck.size() - 1);
|
||||
final BlackCard card = deck.get(deck.size() - 1);
|
||||
deck.remove(deck.size() - 1);
|
||||
dealt.add(card);
|
||||
return card;
|
||||
|
|
|
@ -3,28 +3,28 @@ package net.socialgamer.cah.data;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import net.socialgamer.cah.HibernateUtil;
|
||||
import net.socialgamer.cah.db.WhiteCard;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
|
||||
public class WhiteDeck {
|
||||
|
||||
private List<WhiteCard> deck;
|
||||
private List<WhiteCard> dealt;
|
||||
private final List<WhiteCard> deck;
|
||||
private final List<WhiteCard> dealt;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WhiteDeck() {
|
||||
Session session = HibernateUtil.instance.sessionFactory.openSession();
|
||||
deck = (List<WhiteCard>) session.createQuery("from WhiteCard order by random()").list();
|
||||
final Session session = HibernateUtil.instance.sessionFactory.openSession();
|
||||
deck = session.createQuery("from WhiteCard order by random()").list();
|
||||
dealt = new ArrayList<WhiteCard>();
|
||||
}
|
||||
|
||||
public WhiteCard getNextCard() {
|
||||
// Without knowing what the implementation of List that Hibernate returns
|
||||
// is, I'm going to pull from the end instead of the beginning.
|
||||
WhiteCard card = deck.get(deck.size() - 1);
|
||||
final WhiteCard card = deck.get(deck.size() - 1);
|
||||
deck.remove(deck.size() - 1);
|
||||
dealt.add(card);
|
||||
return card;
|
||||
|
|
Loading…
Reference in New Issue