object2source

A library for generating the source code that creates an instance of the object that is submitted to the input.

Лицензия

Лицензия

Группа

Группа

com.github.tankist88
Идентификатор

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

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

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

0.0.10
Дата

Дата

Тип

Тип

jar
Описание

Описание

object2source
A library for generating the source code that creates an instance of the object that is submitted to the input.
Ссылка на сайт

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

https://github.com/tankist88/object2source
Система контроля версий

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

https://github.com/tankist88/object2source

Скачать object2source

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

<!-- https://jarcasting.com/artifacts/com.github.tankist88/object2source/ -->
<dependency>
    <groupId>com.github.tankist88</groupId>
    <artifactId>object2source</artifactId>
    <version>0.0.10</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.tankist88/object2source/
implementation 'com.github.tankist88:object2source:0.0.10'
// https://jarcasting.com/artifacts/com.github.tankist88/object2source/
implementation ("com.github.tankist88:object2source:0.0.10")
'com.github.tankist88:object2source:jar:0.0.10'
<dependency org="com.github.tankist88" name="object2source" rev="0.0.10">
  <artifact name="object2source" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.tankist88', module='object2source', version='0.0.10')
)
libraryDependencies += "com.github.tankist88" % "object2source" % "0.0.10"
[com.github.tankist88/object2source "0.0.10"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.apache.commons : commons-lang3 jar 3.4

test (4)

Идентификатор библиотеки Тип Версия
org.testng : testng jar 6.8
org.mockito : mockito-core jar 2.2.22
org.javassist : javassist jar 3.20.0-GA
cglib : cglib jar 2.2.2

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

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

object2source

Build Status Codecov Codacy Badge Maven Central

A library for generating the source code that creates an instance of the object that is submitted to the input. This means that using this library, you can reverse engineer objects from the JVM memory. The object2source can generate data provider methods for a variety of standard Java types. If you want to generate a method to get an instance of an arbitrary custom class, you can use the extension system. Now you can use extensions to generate instances of classes from the libraries of Google guava and YodaTime.

Links to the repository with extensions:

  1. https://github.com/tankist88/guava-extension
  2. https://github.com/tankist88/jodatime-extension

Example of usage

TestObj testObj = new TestObj();
ProviderResult pr = (new SourceGenerator()).createDataProviderMethod(testObj);

Print result:

for (ProviderInfo pi : pr.getProviders()) {
    System.out.println(pi.getMethodBody());
}

Example output:

private static TestObj getTestObj_240650537() {
    TestObj testObj = new TestObj();
    testObj.setNum(0);
    testObj.setCh(' ');
    testObj.setArr(getArray_483422889());
    testObj.setTestObjArr(getArray_1277181601());
    return testObj;
}

private static int[] getArray_483422889() {
    int[] array = new int[10];
    array[0] = 0;
    array[1] = 0;
    array[2] = 0;
    array[3] = 0;
    array[4] = 0;
    array[5] = 0;
    array[6] = 0;
    array[7] = 0;
    array[8] = 0;
    array[9] = 0;
    return array;
}

private static TestObj[] getArray_1277181601() {
    TestObj[] array = new TestObj[10];
    array[0] = null;
    array[1] = null;
    array[2] = null;
    array[3] = null;
    array[4] = null;
    array[5] = null;
    array[6] = null;
    array[7] = null;
    array[8] = null;
    array[9] = null;
    return array;
}

Register extensions

SourceGenerator sg = new SourceGenerator();
Extension ext = (Extension) Class.forName("org.example.MyCustomTypeExtension").newInstance();
sg.registerExtension(ext);

Create custom extension

To create custom extension you need create class that implements Extension interface.

Installation

mvn clean install

Contacts

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

Версия
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.1