List of usage examples for com.google.gson GsonBuilder registerTypeAdapterFactory
public GsonBuilder registerTypeAdapterFactory(TypeAdapterFactory factory)
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_TYPE_LIST) public ClientResponse getProductTypeList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //ProductTypeList response = new Gson().fromJson("{\"productTypes\":[{\"id\":\"1\",\"title\":\"Property\"}, {\"id\":\"2\",\"title\":\"Room\"}]}", ProductTypeList.class ); //ProductTypeList response = new ProductTypeList(); //response.setProductTypes(productManager.getProductTypes()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/*from w ww . j ava 2 s .c o m*/ String productString = gson.toJson(productManager.getProductTypes()); ProductTypeList response = gson.fromJson("{\"productTypes\":" + productString + "}", ProductTypeList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_SIZE_LIST) public ClientResponse getProductSizeList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //ProductSizeList response = new ProductSizeList(); //response.setProductSizes(productManager.getProductSizes()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();//from w ww. j ava 2 s. c o m String productString = gson.toJson(productManager.getProductSizes()); ProductSizeList response = gson.fromJson("{\"productSizes\":" + productString + "}", ProductSizeList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_CATEGORY_LIST) public ClientResponse getProductCategoryList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //ProductCategoryList response = new ProductCategoryList(); //response.setProductCategories(productManager.getProductCategories()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/*from w w w . j ava 2 s . c o m*/ String productString = gson.toJson(productManager.getProductCategories()); ProductCategoryList response = gson.fromJson("{\"productCategories\":" + productString + "}", ProductCategoryList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_LOCATION_LIST) public ClientResponse getLocationList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //LocationList response = new Gson().fromJson("{\"locations\":[{\"id\":\"1\",\"locationType\":\"area\",\"searchString\":\"London\",\"postCode\":\"c1\"}, {\"id\":\"2\",\"locationType\":\"area\",\"searchString\":\"London 123\",\"postCode\":\"c2\"}, {\"id\":\"3\",\"locationType\":\"area\",\"searchString\":\"London 456\",\"postCode\":\"c3\"}]}", LocationList.class ); //LocationList response = new LocationList(); //response.setLocations(productManager.getLocations()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();//w w w . jav a2 s. c o m String productString = gson.toJson(productManager.getLocations()); LocationList response = gson.fromJson("{\"locations\":" + productString + "}", LocationList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_AMENITY_LIST) public ClientResponse getAmenityList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/* w ww . j a v a2 s . co m*/ String amenityListString = gson.toJson(productManager.getAmenities()); AmenityList response = gson.fromJson("{\"amenities\":" + amenityListString + "}", AmenityList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_AVAILABILITY_LIST) public ClientResponse getAvailabilityList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/*w ww. jav a 2 s . c o m*/ String availabilitiesString = gson.toJson(productManager.getAvailabilities()); AvailabilityList response = gson.fromJson("{\"availabilities\":" + availabilitiesString + "}", AvailabilityList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_STAY_LIST) public ClientResponse getStayList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //StayList response = new StayList(); //response.setStays(productManager.getStays()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/*from w ww . ja v a2 s . c o m*/ String productString = gson.toJson(productManager.getStays()); StayList response = gson.fromJson("{\"stays\":" + productString + "}", StayList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_SMOKING_LIST) public ClientResponse getSmokingList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //SmokingList response = new SmokingList(); //response.setSmokings(productManager.getSmokings()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/*from ww w . j av a 2 s . co m*/ String productString = gson.toJson(productManager.getSmokings()); SmokingList response = gson.fromJson("{\"smokings\":" + productString + "}", SmokingList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_OCCUPATION_LIST) public ClientResponse getOccupationList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //OccupationList response = new OccupationList(); //response.setOccupations(productManager.getOccupations()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();//from w w w . j a v a 2 s. c o m String productString = gson.toJson(productManager.getOccupations()); OccupationList response = gson.fromJson("{\"occupations\":" + productString + "}", OccupationList.class); response.setSuccess(true); return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PET_LIST) public ClientResponse getPetList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //PetList response = new PetList(); //response.setPets(productManager.getPets()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create();/* w ww .j a v a2s. c om*/ String productString = gson.toJson(productManager.getPets()); PetList response = gson.fromJson("{\"pets\":" + productString + "}", PetList.class); response.setSuccess(true); return response; }