List of usage examples for com.google.gson GsonBuilder registerTypeAdapter
@SuppressWarnings({ "unchecked", "rawtypes" }) public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter)
From source file:com.ikanow.infinit.e.api.knowledge.QueryHandler.java
License:Open Source License
public static AdvancedQueryPojo createQueryPojo(String queryJson) { GsonBuilder gb = AdvancedQueryPojo.getDefaultBuilder(); gb.registerTypeAdapter(AdvancedQueryPojo.QueryRawPojo.class, new AdvancedQueryPojo.QueryRawPojo.Deserializer()); AdvancedQueryPojo query = gb.create().fromJson(queryJson, AdvancedQueryPojo.class); // Fill in the blanks (a decent attempt has been made to fill out the blanks inside these options) if (null == query.input) { query.input = new AdvancedQueryPojo.QueryInputPojo(); }/* w w w .j av a 2 s . c o m*/ if (null == query.score) { query.score = new AdvancedQueryPojo.QueryScorePojo(); } if (null == query.output) { query.output = new AdvancedQueryPojo.QueryOutputPojo(); } if (null == query.output.docs) { // (Docs are sufficiently important we'll make sure they're always present) query.output.docs = new AdvancedQueryPojo.QueryOutputPojo.DocumentOutputPojo(); } return query; }
From source file:com.ikanow.infinit.e.data_model.api.config.SourcePojoApiMap.java
License:Apache License
public GsonBuilder extendBuilder(GsonBuilder gb) { return gb .registerTypeAdapter(SourcePojo.class, new SourcePojoSerializer(_userId, _allowedCommunityIds, _ownedOrModeratedCommunities)) .registerTypeAdapter(SourcePojo.class, new SourcePojoDeserializer(_allowedCommunityIds)); }
From source file:com.ikanow.infinit.e.data_model.api.config.SourcePojoSubstitutionApiMap.java
License:Apache License
@Override public GsonBuilder extendBuilder(GsonBuilder gp) { return new SourceFederatedQueryConfigPojo().extendBuilder(gp.registerTypeAdapter(String.class, (_errorHandler = new SourcePojoSubstitutionDeserializer(_callingUserId)))); //(note this bypasses the custom source pojo deserialization - but it isn't needed because extractor options are already in "." notation) }
From source file:com.ikanow.infinit.e.data_model.api.custom.mapreduce.CustomMapReduceJobPojoApiMap.java
License:Apache License
public GsonBuilder extendBuilder(GsonBuilder gb) { return gb .registerTypeAdapter(CustomMapReduceJobPojo.class, new CustomMapReduceJobPojoSerializer(_allowedCommunityIds)) .registerTypeAdapter(CustomMapReduceJobPojo.class, new CustomMapReduceJobPojoDeserializer(_allowedCommunityIds)); }
From source file:com.ikanow.infinit.e.data_model.api.custom.mapreduce.CustomMapReduceResultPojoApiMap.java
License:Apache License
public GsonBuilder extendBuilder(GsonBuilder gp) { return gp.registerTypeAdapter(CustomMapReduceResultPojo.class, new CustomMapReduceResultPojoDeserializer()); }
From source file:com.ikanow.infinit.e.data_model.api.gui.UIModulePojoApiMap.java
License:Apache License
public GsonBuilder extendBuilder(GsonBuilder gp) { return gp.registerTypeAdapter(UIModulePojo.class, new UIModulePojoSerializer(_allowedCommunityIds)); }
From source file:com.ikanow.infinit.e.data_model.api.knowledge.DocumentPojoApiMap.java
License:Apache License
public GsonBuilder extendBuilder(GsonBuilder gp) { return gp.registerTypeAdapter(DocumentPojo.class, new DocumentPojoSerializer()) .registerTypeAdapter(DocumentPojo.class, new DocumentPojoDeserializer()); }
From source file:com.ikanow.infinit.e.data_model.api.ResponsePojo.java
License:Apache License
@Override public GsonBuilder extendBuilder(GsonBuilder gb) { try {/*from w w w .jav a 2 s. c om*/ if (null == _esVersion) { // (some grovelling to avoid class def errors in earlier versions) _esVersion = ElasticSearchManager.getVersion(); } if (_esVersion >= 100) { if (null == _esTextClass) { try { _esTextClass = Class.forName("org.elasticsearch.common.text.Text"); } catch (ClassNotFoundException e) { return gb; } } gb = gb.registerTypeAdapter(_esTextClass, new TextSerializer()); } } catch (Exception e) { // can't find ES, which is fine unless you try to use it, in which case it will error else where _esVersion = 0; } catch (Error ee) { // (ditto) _esVersion = 0; } return gb; }
From source file:com.ikanow.infinit.e.data_model.api.ResponsePojoApiMap.java
License:Apache License
@Override public GsonBuilder extendBuilder(GsonBuilder gp) { // Serialization: if (null != _dataMap) { gp = _dataMap.extendBuilder(gp); }//from ww w . j a va 2s . c o m // Deserialization: else if ((null != _type1) || (null != _listType1)) { gp = gp.registerTypeAdapter(ResponsePojo.class, new ResponsePojoDeserializer(_type1, _listType1)); } else if ((null != _type2) || (null != _listType2)) { gp = gp.registerTypeAdapter(ResponsePojo.class, new ResponsePojoDeserializer(_type2, _listType2, _deserMap)); } else { gp = gp.registerTypeAdapter(ResponsePojo.class, new ResponsePojoDeserializer()); } return gp; }
From source file:com.ikanow.infinit.e.data_model.api.social.sharing.SharePojoApiMap.java
License:Apache License
public GsonBuilder extendBuilder(GsonBuilder gp) { return gp.registerTypeAdapter(SharePojo.class, new SharePojoSerializer(_allowedCommunityIds)); }