com.github.zthulj.zcopybook.model.ZCopyBook Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zCopybook Show documentation
Show all versions of zCopybook Show documentation
Library helping to convert positionnal inputs (cobol) to json, using a copybook format
The newest version!
package com.github.zthulj.zcopybook.model;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Getter
@RequiredArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public final class ZCopyBook {
private final RootNode rootNode;
private List> valueNodes;
private int waitedLength;
public static ZCopyBook from(RootNode rootNodeCopybook){
List> allValueNodes = new ArrayList<>();
rootNodeCopybook.getChilds().forEach(
(k,v) -> allValueNodes.addAll(v.getAllValueNodes())
);
final int waited = allValueNodes.stream().mapToInt(e->e.getCoordinates().getSize()).sum();
return new ZCopyBook<>(rootNodeCopybook,allValueNodes, waited);
}
}