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

com.redhat.lightblue.migrator.Inconsistency Maven / Gradle / Ivy

There is a newer version: 2.56.1
Show newest version
package com.redhat.lightblue.migrator;

import java.util.List;

/**
 * Keeps the inconsistent field, its source and destination values
 */
public class Inconsistency {
    private final String field;
    private final Object sourceValue;
    private final Object destValue;

    public Inconsistency(String field, Object sourceValue, Object destValue) {
        this.field = field;
        this.sourceValue = sourceValue;
        this.destValue = destValue;
    }

    public String getField() {
        return field;
    }

    public Object getSourceValue() {
        return sourceValue;
    }

    public Object getDestValue() {
        return destValue;
    }

    @Override
    public String toString() {
        return "field=" + field + ", sourceValue=" + sourceValue + " destValue=" + destValue;
    }

    public static String getPathList(List l) {
        StringBuilder bld = new StringBuilder();
        boolean first = true;
        for (Inconsistency x : l) {
            if (first) {
                first = false;
            } else {
                bld.append(',');
            }
            bld.append(x.field);
        }
        return bld.toString();
    }

    public static String getMismatchedValues(List l) {
        StringBuilder bld = new StringBuilder();
        boolean first = true;
        for (Inconsistency x : l) {
            if (first) {
                first = false;
            } else {
                bld.append(',');
            }
            bld.append("s:").append(x.sourceValue == null ? "null" : x.sourceValue.toString()).
                    append(" d:").append(x.destValue == null ? "null" : x.destValue.toString());
        }
        return bld.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy