Package de.danielbechler.diff.node

Examples of de.danielbechler.diff.node.DiffNode


  {
    if (!instances.getType().isPrimitive())
    {
      throw new IllegalArgumentException("The primitive differ can only deal with primitive types.");
    }
    final DiffNode node = new DiffNode(parentNode, instances.getSourceAccessor(), instances.getType());
    if (shouldTreatPrimitiveDefaultsAsUnassigned(node) && instances.hasBeenAdded())
    {
      node.setState(DiffNode.State.ADDED);
    }
    else if (shouldTreatPrimitiveDefaultsAsUnassigned(node) && instances.hasBeenRemoved())
    {
      node.setState(DiffNode.State.REMOVED);
    }
    else if (!instances.areEqual())
    {
      node.setState(DiffNode.State.CHANGED);
    }
    return node;
  }
View Full Code Here


    @Override
    public boolean matches(final Object argument)
    {
      if (argument instanceof DiffNode)
      {
        final DiffNode node = (DiffNode) argument;
        final NodePath path = node.getPath();
        if (expectedNodePath != null && path != null && !path.matches(this.expectedNodePath))
        {
          return false;
        }
        if (expectedTypeHint != null && expectedTypeHint != node.getValueType())
        {
          return false;
        }
        return true;
      }
View Full Code Here

    return false;
  }

  private static Iterable<PropertyAwareAccessor> getSiblingAccessors(final DiffNode node)
  {
    final DiffNode parentNode = node.getParentNode();
    if (parentNode != null)
    {
      final TypeInfo typeInfo = parentNode.getValueTypeInfo();
      if (typeInfo != null)
      {
        return typeInfo.getAccessors();
      }
    }
View Full Code Here

    return false;
  }

  public final DiffNode compare(final DiffNode parentNode, final Instances instances)
  {
    final DiffNode mapNode = new DiffNode(parentNode, instances.getSourceAccessor(), instances.getType());
    if (instances.hasBeenAdded())
    {
      compareEntries(mapNode, instances, instances.getWorking(Map.class).keySet());
      mapNode.setState(DiffNode.State.ADDED);
    }
    else if (instances.hasBeenRemoved())
    {
      compareEntries(mapNode, instances, instances.getBase(Map.class).keySet());
      mapNode.setState(DiffNode.State.REMOVED);
    }
    else if (instances.areSame())
    {
      mapNode.setState(DiffNode.State.UNTOUCHED);
    }
    else if (comparisonStrategyResolver.resolveComparisonStrategy(mapNode) != null)
    {
      comparisonStrategyResolver.resolveComparisonStrategy(mapNode).compare(mapNode, instances.getType(), instances.getWorking(Map.class), instances.getBase(Map.class));
    }
View Full Code Here

    return !type.isPrimitive() && !type.isArray();
  }

  public final DiffNode compare(final DiffNode parentNode, final Instances instances)
  {
    final DiffNode beanNode = new DiffNode(parentNode, instances.getSourceAccessor(), instances.getType());
    if (instances.areNull() || instances.areSame())
    {
      beanNode.setState(DiffNode.State.UNTOUCHED);
    }
    else if (instances.hasBeenAdded())
    {
      compareUsingAppropriateMethod(beanNode, instances);
      beanNode.setState(DiffNode.State.ADDED);
    }
    else if (instances.hasBeenRemoved())
    {
      compareUsingAppropriateMethod(beanNode, instances);
      beanNode.setState(DiffNode.State.REMOVED);
    }
    else
    {
      compareUsingAppropriateMethod(beanNode, instances);
    }
View Full Code Here

  {
    final TypeInfo typeInfo = typeInfoResolver.typeInfoForNode(beanNode);
    beanNode.setValueTypeInfo(typeInfo);
    for (final PropertyAwareAccessor propertyAccessor : typeInfo.getAccessors())
    {
      final DiffNode propertyNode = differDispatcher.dispatch(beanNode, beanInstances, propertyAccessor);
      if (isReturnableResolver.isReturnable(propertyNode))
      {
        beanNode.addChild(propertyNode);
      }
    }
View Full Code Here

    final Thing thingOne = new Thing("a", "b");
    final Thing thingTwo = new Thing("aa", "bb");

    final ThingHolder first = new ThingHolder(singleton(thingOne), "ignore", "include");
    final ThingHolder second = new ThingHolder(singleton(thingTwo), "ignore this change", "include");
    final DiffNode compareResults = builder.build().compare(first, second);

    assertThat(compareResults.isChanged(), is(true));
  }
View Full Code Here

    TestIntBeanPublic base = new TestIntBeanPublic();
    base.setValue(1);

    ObjectDiffer differ = ObjectDifferBuilder.buildDefault();
    final DiffNode root = differ.compare(working, base);

    root.visit(new PrintingVisitor(working, base));
  }
View Full Code Here

    final ObjectDifferBuilder builder = ObjectDifferBuilder.startBuilding();
    builder.inclusion().include().node(NodePath.with("aliases"));
    final ObjectDiffer differ = builder.build();

    final DiffNode root = differ.compare(b, a);
    root.visit(new PrintingVisitor(b, a));

    NodeAssertions.assertThat(root).root().hasChanges();
  }
View Full Code Here

    TestIntBeanPrivate base = new TestIntBeanPrivate();
    base.setValue(1);

    ObjectDiffer differ = ObjectDifferBuilder.buildDefault();
    final DiffNode root = differ.compare(working, base);

    root.visit(new PrintingVisitor(working, base));
  }
View Full Code Here

TOP

Related Classes of de.danielbechler.diff.node.DiffNode

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.