com.gs.obevo.dbmetadata.deepcompare.ClassCompareInfo Maven / Gradle / Ivy
/**
* Copyright 2017 Goldman Sachs.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.gs.obevo.dbmetadata.deepcompare;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.collection.MutableCollection;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.tuple.Tuples;
public class ClassCompareInfo {
private final Class clazz;
private final Function keyFunction;
private final MutableCollection>> compareFunctions;
private final MutableCollection collectionComparisonInfos;
public static final Function TO_CLAZZ = new Function() {
@Override
public Class valueOf(ClassCompareInfo object) {
return object.getClazz();
}
};
public static ClassCompareInfoBuilder newBuilder() {
return new ClassCompareInfoBuilder();
}
private ClassCompareInfo(Class clazz, Function keyFunction,
MutableCollection>> compareFunctions,
MutableCollection collectionComparisonInfos) {
this.clazz = clazz;
this.keyFunction = keyFunction;
this.compareFunctions = compareFunctions;
this.collectionComparisonInfos = collectionComparisonInfos;
}
private Class getClazz() {
return this.clazz;
}
public Function getKeyFunction() {
return this.keyFunction;
}
public MutableCollection>> getCompareFunctions() {
return this.compareFunctions;
}
public MutableCollection getCollectionComparisonInfos() {
return this.collectionComparisonInfos;
}
public static class ClassCompareInfoBuilder {
private Class clazz;
private Function keyFunction;
private final MutableCollection compareFunctions = Lists.mutable.empty();
private final MutableCollection collectionComparisonInfos = Lists.mutable.empty();
public ClassCompareInfoBuilder setClazz(Class clazz) {
this.clazz = clazz;
return this;
}
public ClassCompareInfoBuilder setKeyFunction(Function keyFunction) {
this.keyFunction = keyFunction;
return this;
}
public ClassCompareInfoBuilder addCompareFunction(String fieldName, Function compareFunction) {
this.compareFunctions.add(Tuples.pair(fieldName, compareFunction));
return this;
}
public ClassCompareInfoBuilder addCollectionComparisonInfo(CollectionFieldCompareInfo collectionComparisonInfo) {
this.collectionComparisonInfos.add(collectionComparisonInfo);
return this;
}
public ClassCompareInfo build() {
return new ClassCompareInfo(this.clazz, this.keyFunction, this.compareFunctions, this.collectionComparisonInfos);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy