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

org.openprovenance.prov.nf.xml.Statement Maven / Gradle / Ivy

package org.openprovenance.prov.nf.xml;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.openprovenance.prov.model.StatementOrBundle;

import com.fasterxml.jackson.annotation.JsonIgnore;

public interface Statement extends Comparable {
	public void normalize();
	
	@JsonIgnore
	public StatementOrBundle.Kind	getKind();
	
	public LinkedList> paramsAsListsofStrings();
	
	default > int compareLists (List l1, List l2) {
		int len1 = l1.size();
		int len2 = l2.size();
		int len=Math.min(len1,len2);
		for (int i=0; i> int compareListsOfLists (LinkedList> l1, LinkedList> l2) {
		while (true) {
			if (l1.isEmpty()) {
				if (l2.isEmpty()) {
					return 0;
				} else {
					return -1;
				}

			} else {
				if (l2.isEmpty()) {
					return 1;
				} else {
					List v1=l1.removeFirst();
					List v2=l2.removeFirst();
					int comp=compareLists(v1,v2);
					if (comp==0) {
						// iterate with l1 and l2
					} else {
						return comp;
					}
				}
			}
		}
	}
	
	
	public List getAttr();
	
	@Override
	default public int compareTo(Statement o) {
		int comp=this.getKind().compareTo(o.getKind());
		if (comp!=0) {
			return comp;
		} else {
			LinkedList> l1 = this.paramsAsListsofStrings();
			LinkedList> l2 = o.paramsAsListsofStrings();
			int comp_l=compareListsOfLists(l1,l2);
			if (comp_l!=0) {
				return comp_l;
			} else {
				return compareLists(this.getAttr(),o.getAttr());
			}
		}
	}
	
	default > void doSort(List l) {
		if ((l!=null) && (!l.isEmpty())) {
			System.out.println(l);
			Collections.sort(l);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy