All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openlca.git.model.Diff Maven / Gradle / Ivy

There is a newer version: 2.2.1
Show newest version
package org.openlca.git.model;

import java.util.List;

public class Diff extends ModelRef {

	public final DiffType diffType;
	public final Reference oldRef;
	public final Reference newRef;

	public Diff(DiffType diffType, Reference oldRef, Reference newRef) {
		super(diffType == DiffType.DELETED ? oldRef : newRef);
		this.diffType = diffType;
		this.oldRef = oldRef;
		this.newRef = newRef;
	}

	public static List filter(List diffs, DiffType type) {
		return filter(diffs, new DiffType[] { type });
	}

	public static List filter(List diffs, DiffType... types) {
		if (types == null)
			return diffs;
		return diffs.stream().filter(d -> {
			for (DiffType diffType : types)
				if (d.diffType == diffType)
					return true;
			return false;
		}).toList();
	}

	@Override
	protected String fieldsToString() {
		var s = super.fieldsToString();
		return s + ", diffType=" + diffType
				+ ", oldRef=" + (oldRef != null ? oldRef.toString() : "null")
				+ ", newRef=" + (newRef != null ? newRef.toString() : "null");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy