DiffResult.java 2.29 KB
package org.apache.commons.lang3.builder;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class DiffResult
  implements Iterable<Diff<?>>
{
  public static final String OBJECTS_SAME_STRING = "";
  private final List<Diff<?>> a;
  private final Object b;
  private final Object c;
  private final ToStringStyle d;
  
  DiffResult(Object paramObject1, Object paramObject2, List<Diff<?>> paramList, ToStringStyle paramToStringStyle)
  {
    if (paramObject1 == null) {
      throw new IllegalArgumentException("Left hand object cannot be null");
    }
    if (paramObject2 == null) {
      throw new IllegalArgumentException("Right hand object cannot be null");
    }
    if (paramList == null) {
      throw new IllegalArgumentException("List of differences cannot be null");
    }
    this.a = paramList;
    this.b = paramObject1;
    this.c = paramObject2;
    if (paramToStringStyle == null)
    {
      this.d = ToStringStyle.DEFAULT_STYLE;
      return;
    }
    this.d = paramToStringStyle;
  }
  
  public List<Diff<?>> getDiffs()
  {
    return Collections.unmodifiableList(this.a);
  }
  
  public int getNumberOfDiffs()
  {
    return this.a.size();
  }
  
  public ToStringStyle getToStringStyle()
  {
    return this.d;
  }
  
  public Iterator<Diff<?>> iterator()
  {
    return this.a.iterator();
  }
  
  public String toString()
  {
    return toString(this.d);
  }
  
  public String toString(ToStringStyle paramToStringStyle)
  {
    if (this.a.size() == 0) {
      return "";
    }
    ToStringBuilder localToStringBuilder = new ToStringBuilder(this.b, paramToStringStyle);
    paramToStringStyle = new ToStringBuilder(this.c, paramToStringStyle);
    Iterator localIterator = this.a.iterator();
    while (localIterator.hasNext())
    {
      Diff localDiff = (Diff)localIterator.next();
      localToStringBuilder.append(localDiff.getFieldName(), localDiff.getLeft());
      paramToStringStyle.append(localDiff.getFieldName(), localDiff.getRight());
    }
    return String.format("%s %s %s", new Object[] { localToStringBuilder.build(), "differs from", paramToStringStyle.build() });
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/org/apache/commons/lang3/builder/DiffResult.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */