Reflection utils

A utility library to handle Java reflection with ease

Лицензия

Лицензия

Группа

Группа

com.github.ekryd.reflection-utils
Идентификатор

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

reflection-utils
Последняя версия

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

1.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Reflection utils
A utility library to handle Java reflection with ease
Ссылка на сайт

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

https://github.com/Ekryd/reflection-utils
Система контроля версий

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

https://github.com/Ekryd/reflection-utils

Скачать reflection-utils

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

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

Зависимости

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3

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

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

Reflection-utils Icon

Build Status Coverage Status Maven Central Coverity

This library will make it easier to get and set internal fields in classes using java reflection. The library is optimized for convenience and not for speed, so it works best with unit tests.

Mocking is great! Sometimes the easiest way to insert mocks are by Java reflection. Especially if you cannot use constructor arguments or setter methods.

Example of how to use the ReflectionHelper in a test

    @Test
    public void storeMethodShouldSaveEntity() throws Exception {
        // Setup entities
        EntityHandler handler = new EntityHandlerImpl();        
        StoreDao storeDao = mock(StoreDao.class);
        
        // *** This is the ReflectionHelper! You don't need to know the name of field nor the type, just set the instance ***
        new ReflectionHelper(handler).setField(storeDao);
        
        // Perform method
        handler.store();

        // Verify save method
        verify(storeDao).save();
    }

See more

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

Версия
1.1.0
1.0.2
1.0.0
0.0.5
0.0.4