Package com.getperka.flatpack.ext

Examples of com.getperka.flatpack.ext.SerializationContext


  protected <T> T testCodex(Provider<? extends Codex<T>> codexes, T value, Set<HasUuid> scanned) {
    // Just smoke-test the description
    assertNotNull(codexes.get().describe());

    StringWriter out = new StringWriter();
    SerializationContext serialization = serializationContext(out);
    try {
      Codex<T> codex = codexes.get();
      codexes.get().write(value, serialization);
      if (scanned != null) {
        visitors.getWalkers().walkImmutable(codex).accept(packScanners.get(), value);
        scanned.addAll(serialization.getEntities());
      }
    } finally {
      closeContext();
    }
View Full Code Here


    packScope.enter()
        .withJsonWriter(json)
        .withPrincipal(principal)
        .withTraversalMode(TraversalMode.SPARSE);

    SerializationContext context = contexts.get();
    try {
      context.add(entity);
      visitorSupport.visit(writers.get(), entity);
      return json.get();
    } catch (Exception e) {
      context.fail(e);
      return null;
    } finally {
      packScope.exit();
    }
  }
View Full Code Here

    packScope.enter()
        .withJsonWriter(json)
        .withPrincipal(principal)
        .withTraversalMode(TraversalMode.SPARSE);

    SerializationContext context = contexts.get();
    try {
      context.add(entity);
      visitorSupport.visit(writers.get(), entity);
    } catch (Exception e) {
      context.fail(e);
    } finally {
      packScope.exit();
    }
  }
View Full Code Here

    JsonTreeWriter json = new JsonTreeWriter();
    JsonElement toReturn;
    json.setSerializeNulls(false);
    packScope.enter().withEntity(entity).withJsonWriter(json);
    try {
      SerializationContext context = contexts.get();
      doPack(entity, context);
      toReturn = json.get();
      context.runPostWork();
      context.close();
    } finally {
      packScope.exit();
    }
    return toReturn;
  }
View Full Code Here

  public void pack(FlatPackEntity<?> entity, Writer out) throws IOException {
    JsonWriter json = jsonWriter(out);

    packScope.enter().withEntity(entity).withJsonWriter(json);
    try {
      SerializationContext context = contexts.get();
      doPack(entity, context);
      context.runPostWork();
      context.close();
    } finally {
      packScope.exit();
    }
  }
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.ext.SerializationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.