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

com.deepoove.swagger.diff.compare.PropertyDiff Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package com.deepoove.swagger.diff.compare;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.deepoove.swagger.diff.model.ElProperty;

import io.swagger.models.Model;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.RefProperty;

public class PropertyDiff {

	private List increased;
	private List missing;

	Map oldDedinitions;
	Map newDedinitions;

	private PropertyDiff() {
		increased = new ArrayList();
		missing = new ArrayList();
	}

	public static PropertyDiff buildWithDefinition(Map left,
			Map right) {
		PropertyDiff diff = new PropertyDiff();
		diff.oldDedinitions = left;
		diff.newDedinitions = right;
		return diff;
	}

	public PropertyDiff diff(Property left, Property right) {
		if ((null == left || left instanceof RefProperty) && (null == right || right instanceof RefProperty)) {
			Model leftModel = null == left ? null : oldDedinitions.get(((RefProperty) left).getSimpleRef());
			Model rightModel = null == right ? null : newDedinitions.get(((RefProperty) right).getSimpleRef());
			ModelDiff diff = ModelDiff
					.buildWithDefinition(oldDedinitions, newDedinitions)
					.diff(leftModel, rightModel);
			increased.addAll(diff.getIncreased());
			missing.addAll(diff.getMissing());
		}
		return this;
	}

	public List getIncreased() {
		return increased;
	}

	public void setIncreased(List increased) {
		this.increased = increased;
	}

	public List getMissing() {
		return missing;
	}

	public void setMissing(List missing) {
		this.missing = missing;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy