Pairwise tree generator

Generate tree variants of incoming objects description by pairwise theory

Лицензия

Лицензия

Группа

Группа

com.anyqn.lib
Идентификатор

Идентификатор

pairwise-tree-generator
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Pairwise tree generator
Generate tree variants of incoming objects description by pairwise theory
Ссылка на сайт

Ссылка на сайт

https://github.com/3DRaven/pairwise-tree-generator
Система контроля версий

Система контроля версий

https://github.com/3DRaven/pairwise-tree-generator

Скачать pairwise-tree-generator

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.anyqn.lib/pairwise-tree-generator/ -->
<dependency>
    <groupId>com.anyqn.lib</groupId>
    <artifactId>pairwise-tree-generator</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.anyqn.lib/pairwise-tree-generator/
implementation 'com.anyqn.lib:pairwise-tree-generator:0.0.1'
// https://jarcasting.com/artifacts/com.anyqn.lib/pairwise-tree-generator/
implementation ("com.anyqn.lib:pairwise-tree-generator:0.0.1")
'com.anyqn.lib:pairwise-tree-generator:jar:0.0.1'
<dependency org="com.anyqn.lib" name="pairwise-tree-generator" rev="0.0.1">
  <artifact name="pairwise-tree-generator" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.anyqn.lib', module='pairwise-tree-generator', version='0.0.1')
)
libraryDependencies += "com.anyqn.lib" % "pairwise-tree-generator" % "0.0.1"
[com.anyqn.lib/pairwise-tree-generator "0.0.1"]

Зависимости

compile (7)

Идентификатор библиотеки Тип Версия
com.anyqn.lib : pairwiser jar 0.1.21
org.apache.commons : commons-lang3 jar 3.11
com.fasterxml.jackson.core : jackson-databind jar 2.12.1
org.projectlombok : lombok jar 1.18.16
org.slf4j : slf4j-api jar 1.6.6
ch.qos.logback : logback-classic jar 1.0.7
ch.qos.logback : logback-core jar 1.0.7

test (2)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter jar 5.6.2
org.assertj : assertj-core jar 3.15.0

Модули Проекта

Данный проект не имеет модулей.

Pairwise-tree-generator

Library for generate trees (as example JSONs) from base description based on pairwiser library

Example

We have WEB API with input json. So, lets write description of possible variants of generated JSONs. We can describe field names and possible field values (objects can be values too):

{
    "properties": {
        "minRestrictions": [
            {
                "fieldPath": "fieldD",
                "value": 1
            }
        ],
        "maxRestrictions": [
            {
                "fieldPath": "fieldD",
                "value": 2
            }
        ],
        "objects": [
            "fieldC"
        ]
    },
    "source": {
        "fieldA": [
            "Avalue1"
        ],
        "fieldB": [
            null
        ],
        "fieldC": [
            {
                "subFieldA": [
                    1
                ]
            }
        ],
        "fieldD": [
            {
                "subFieldA": [
                    1
                ]
            }
        ]
    }
}

Let's get generated JSONs variants from description:

<dependency>
    <groupId>com.anyqn.lib</groupId>
    <artifactId>pairwise-tree-generator</artifactId>
    <version>0.0.1</version>
</dependency>
//Get description Map
Map<String,Object> generationDescription = mapper.readValue(sourceDescriptionJson,new TypeReference<Map<String,Object>>() {});
//Get Properties for generation from source json (as example)
Properties properties = mapper.convertValue(generationDescription.get("properties"),Properties.class);
//Get description of possible field values
Map<String,List<Object>> jsonsDescription = mapper.convertValue(generationDescription.get("source"),new TypeReference<Map<String,List<Object>>>() {});
//Let's generate
final PairwiseJsonGenerator gen = new PairwiseJsonGenerator();
//Generated list of possible variants of JSONs
final List<Map<String, Object>> generated = gen.generate(jsonsDescription, properties);

Final cases (converted from tree of objects to json):

[
    {
        "fieldA": "Avalue1",
        "fieldC": null,
        "fieldB": null,
        "fieldD": [
            {
                "subFieldA": 1
            }
        ]
    },
    {
        "fieldA": "Avalue1",
        "fieldC": {
            "subFieldA": 1
        },
        "fieldB": null,
        "fieldD": [
            {
                "subFieldA": 1
            }
        ]
    }
]

License

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/

Версии библиотеки

Версия
0.0.1