| /*=============================================================================# |
| # Copyright (c) 2012, 2021 Original NatTable authors and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 |
| # |
| # Contributors: |
| # Original NatTable authors and others - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.ecommons.waltable.layer.event; |
| |
| import org.eclipse.statet.ecommons.waltable.coordinate.LRange; |
| |
| |
| public class StructuralDiff { |
| |
| public enum DiffTypeEnum { |
| ADD, CHANGE, DELETE; |
| } |
| |
| |
| private final DiffTypeEnum diffType; |
| |
| private final LRange beforePositionRange; |
| |
| private final LRange afterPositionRange; |
| |
| |
| public StructuralDiff(final DiffTypeEnum diffType, final LRange beforePositionRange, final LRange afterPositionRange) { |
| if (diffType == null) { |
| throw new NullPointerException("diffType"); |
| } |
| if (beforePositionRange == null) { |
| throw new NullPointerException("beforePositionRange"); |
| } |
| if (afterPositionRange == null) { |
| throw new NullPointerException("afterPositionRange"); |
| } |
| |
| this.diffType= diffType; |
| this.beforePositionRange= beforePositionRange; |
| this.afterPositionRange= afterPositionRange; |
| } |
| |
| public DiffTypeEnum getDiffType() { |
| return this.diffType; |
| } |
| |
| public LRange getBeforePositionRange() { |
| return this.beforePositionRange; |
| } |
| |
| public LRange getAfterPositionRange() { |
| return this.afterPositionRange; |
| } |
| |
| |
| @Override |
| public int hashCode() { |
| return ((((this.diffType.hashCode() |
| * 13) + this.beforePositionRange.hashCode()) |
| * 14) + this.afterPositionRange.hashCode()); |
| } |
| |
| @Override |
| public boolean equals(final Object obj) { |
| if (this == obj) { |
| return true; |
| } |
| if (!(obj instanceof StructuralDiff)) { |
| return false; |
| } |
| final StructuralDiff other= (StructuralDiff) obj; |
| return (this.diffType == other.diffType |
| && this.beforePositionRange == other.beforePositionRange |
| && this.afterPositionRange == other.afterPositionRange ); |
| } |
| |
| @Override |
| public String toString() { |
| return getClass().getSimpleName() |
| + " " + this.diffType + " (" |
| + " before= " + this.beforePositionRange + ", " |
| + " after= " + this.afterPositionRange + ")"; |
| } |
| |
| } |