Package com.vercer.engine.persist

Examples of com.vercer.engine.persist.PropertyTranslator


  protected PropertyTranslator translator(Field field)
  {
    if (storageStrategy.entity(field))
    {
      PropertyTranslator translator;
      if (relationshipStrategy.parent(field))
      {
        translator = parentTranslator;
      }
      else if (relationshipStrategy.child(field))
View Full Code Here


    encodeKeySpec = new KeySpecification(kind, parentKey, null);

    keyCache.cacheKeyReferenceForInstance(instance, encodeKeySpec.toObjectReference());
     
    // translate fields to properties - sets parent and id on key
    PropertyTranslator encoder = encoder(instance);
    Set<Property> properties = encoder.typesafeToProperties(instance, Path.EMPTY_PATH, indexed);
    if (properties == null)
    {
      throw new IllegalStateException("Could not translate instance: " + instance);
    }
View Full Code Here

        {
          childProperties = pps.getProperties();
        }

        // get the correct translator for this field
        PropertyTranslator translator = decoder(field, childProperties);

        // get the type that we need to store
        Type type = typeFromField(field);

        onBeforeTranslate(field, childProperties);

        // create instance
        Object value;
        try
        {
          value = translator.propertiesToTypesafe(childProperties, fieldPath, type);
        }
        catch (Exception e)
        {
          // add a bit of context to the trace
          throw new IllegalStateException("Problem translating field " + field, e);
View Full Code Here

          value = converters.convert(value, type);

          Path childPath = new Path.Builder(path).field(fieldToPartName(field)).build();

          PropertyTranslator translator = encoder(field, value);
          Set<Property> properties = translator.typesafeToProperties(value, childPath, indexed(field));
          if (properties == null)
          {
            throw new IllegalStateException("Could not translate value to properties: " + value);
          }
          merged.addAll(properties);
View Full Code Here

  @Test
  public void writeReadSimpleList() throws SecurityException, NoSuchFieldException
  {
    // create dummy translator that always returns a single property containing the instance
    PropertyTranslator chained = new DirectTranslator();

    ListTranslator translator = new ListTranslator(chained);
    Set<Property> encoded = translator.typesafeToProperties(values, Path.EMPTY_PATH, true);

    // should be a single property with a list of values
View Full Code Here

  @Test
  public void writeReadComplexList() throws SecurityException, NoSuchFieldException
  {
    // create dummy translator that always returns two properties
    PropertyTranslator chained = new PropertyTranslator()
    {
      public Set<Property> typesafeToProperties(Object object, Path path, boolean indexed)
      {
        HashSet<Property> properties = new HashSet<Property>();
        properties.add(new SimpleProperty(new Path.Builder(path).field("first").build(), object, indexed));
View Full Code Here

TOP

Related Classes of com.vercer.engine.persist.PropertyTranslator

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.