我正在比较两个嵌套集合的对象。除了如何重建层次结构之外,生成的diff具有我期望的一切。
作为一个说明性的例子:
我创建了一个新的车库g1,有两辆车,c1和c2。 c1有2个座位c1s1,c1s2。 c2有1个座位,c2s1。我的SimpleTextChangeLog看起来像这样:
.scrollcards {
background-color: #fff;
overflow: auto;
white-space: nowrap;
height: 550px;
}
div.scrollcards .card-main {
display: inline-block;
padding: 14px;
text-decoration: none;
height: auto;
width: 350px;
}
.card-main .card {
height: 400px;
width: 350px;
white-space: hidden;
}
.card-flip,
.card-flip-one,
.card-flip-two,
.card-flip-three,
.card-flip-four {
perspective: 1000px;
cursor: pointer;
transition: 0.6s;
transform-style: preserve-3d;
}
.flip,
.flip,
.flip-one,
.flip-one,
.flip-two,
.flip-two,
.flip-three,
.flip-three,
.flip-four,
.flip-four{
perspective: 1000px;
transform: rotateY(180deg);
}
.card-flip,
.card-flip-one,
.card-flip-two,
.card-flip-three,
.card-flip-four,
.front,
.back {
width: 100%;
height: 480px;
}
.flip,
.flip-one,
.flip-two,
.flip-three,
.flip-four {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
z-index: 2;
transform: rotateY(0deg);
}
.back {
transform: rotateY(180deg);
}
var cardFlip = document.querySelector(".card-flip");
cardFlip.addEventListener("click", function(){
cardFlip.classList.toggle("flip");
});
var cardFlipOne = document.querySelector(".card-flip-one");
cardFlipOne.addEventListener("click", function(){
cardFlipOne.classList.toggle("flip-one");
});
var cardFlipTwo = document.querySelector(".card-flip-two");
cardFlipTwo.addEventListener("click", function(){
cardFlipTwo.classList.toggle("flip-two");
});
var cardFlipThree = document.querySelector(".card-flip-three");
cardFlipThree.addEventListener("click", function(){
cardFlipThree.classList.toggle("flip-three");
});
var cardFlipFour = document.querySelector(".card-flip-four");
cardFlipFour.addEventListener("click", function(){
cardFlipFour.classList.toggle("flip-four");
});
我希望我的ChangeProcessor实现以分层形式打印更改:
new object: ...Garage/g1
new object: ...Seat/c2s1
new object: ...Car/c2
new object: ...Car/c1
new object: ...Seat/c1s1
new object: ...Seat/c1s2
类层次结构:
new object: ...Garage/g1
new object: ...Car/c1
new object: ...Seat/c1s1
new object: ...Seat/c1s2
new object: ...Car/c2
new object: ...Seat/c2s1
有办法做到这一点吗?
答案 0 :(得分:1)
更改列表是一个扁平的未排序列表,因此您无法重现层次结构表单更改。
为什么不使用阴影?
@Entity
class Garage {
@Id int id
Set<Car> cars
String toString() {
"Garage " +id + "\n"+ cars.collect{it.toString()}
}
}
@Entity
class Car {
@Id int id
String toString() {
"Car " +id
}
}
def "should print "(){
when:
def javers = JaversBuilder.javers().build()
javers.commit("", new Garage(id:1, cars: [new Car(id:2), new Car(id:3)]))
Shadow<Garage> g = javers.findShadows(
QueryBuilder.byClass(Garage).withScopeCommitDeep().build())[0]
then:
true
println (g.get())
}
输出:
Garage 1
[Car 2, Car 3]