commit
f01e302aa2
|
@ -212,19 +212,11 @@ public final class GsonWrapper {
|
|||
Schema.make().get();
|
||||
ASObjectAdapter base =
|
||||
new ASObjectAdapter(schema);
|
||||
GsonBuilder b = initGsonBuilder(builder,schema,base);
|
||||
for (AdapterEntry<?> entry : builder.adapters.build()) {
|
||||
if (entry.hier)
|
||||
b.registerTypeHierarchyAdapter(
|
||||
entry.type,
|
||||
entry.adapter!=null ?
|
||||
entry.adapter : base);
|
||||
else
|
||||
b.registerTypeAdapter(
|
||||
entry.type,
|
||||
entry.adapter!=null ?
|
||||
entry.adapter:base);
|
||||
}
|
||||
GsonBuilder b = initGsonBuilder(
|
||||
builder,
|
||||
schema,
|
||||
base,
|
||||
builder.adapters.build());
|
||||
if (builder.pretty)
|
||||
b.setPrettyPrinting();
|
||||
this.gson = b.create();
|
||||
|
@ -239,12 +231,29 @@ public final class GsonWrapper {
|
|||
private static GsonBuilder initGsonBuilder(
|
||||
Builder builder,
|
||||
Schema schema,
|
||||
ASObjectAdapter base) {
|
||||
return new GsonBuilder()
|
||||
ASObjectAdapter base,
|
||||
Iterable<AdapterEntry<?>> adapters) {
|
||||
|
||||
GsonBuilder gson = new GsonBuilder()
|
||||
.registerTypeHierarchyAdapter(TypeValue.class, new TypeValueAdapter(schema))
|
||||
.registerTypeHierarchyAdapter(LinkValue.class, new LinkValueAdapter(schema))
|
||||
.registerTypeHierarchyAdapter(Iterable.class, ITERABLE);
|
||||
|
||||
for (AdapterEntry<?> entry : adapters) {
|
||||
if (entry.hier)
|
||||
gson.registerTypeHierarchyAdapter(
|
||||
entry.type,
|
||||
entry.adapter!=null ?
|
||||
entry.adapter : base);
|
||||
else
|
||||
gson.registerTypeAdapter(
|
||||
entry.type,
|
||||
entry.adapter!=null ?
|
||||
entry.adapter:base);
|
||||
}
|
||||
|
||||
return gson
|
||||
.registerTypeHierarchyAdapter(NLV.class, NLV)
|
||||
.registerTypeHierarchyAdapter(Iterable.class, ITERABLE)
|
||||
.registerTypeHierarchyAdapter(ActionsValue.class, ACTIONS)
|
||||
.registerTypeHierarchyAdapter(Optional.class, OPTIONAL)
|
||||
.registerTypeHierarchyAdapter(Range.class, RANGE)
|
||||
|
|
|
@ -200,10 +200,16 @@ public final class Schema {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Model model(String objectType) {
|
||||
return objectTypeMap.get(objectType);
|
||||
}
|
||||
|
||||
public Model model() {
|
||||
return objectClassMap.get(ASObject.Builder.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get.
|
||||
|
||||
|
||||
* @return Schema * @see com.google.common.base.Supplier#get() */
|
||||
public Schema get() {
|
||||
return new Schema(this);
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.apache.http.config.RegistryBuilder;
|
|||
import org.apache.http.config.SocketConfig;
|
||||
import org.apache.http.conn.HttpClientConnectionManager;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
@ -43,7 +44,8 @@ public final class HttpFetch
|
|||
implements Supplier<HttpFetch> {
|
||||
|
||||
private final RegistryBuilder<ConnectionSocketFactory> csfr =
|
||||
RegistryBuilder.<ConnectionSocketFactory>create();
|
||||
RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.INSTANCE);
|
||||
private ConnectionConfig defaultConnectionConfig;
|
||||
private SocketConfig defaultSocketConfig;
|
||||
private final ImmutableMap.Builder<HttpHost,ConnectionConfig> connectionConfigs =
|
||||
|
|
Loading…
Reference in New Issue