Coder Social home page Coder Social logo

bean-mirror's Introduction

Bean Mirror

Apache 2 License Actions Status codecov Maven Central JavaDoc

Bean Mirror is a fluent, type-safe reflection library for the latest Java versions.

Features

  • Fluent API
  • Type-safe
  • Modularized
  • Lightweight, no dependencies

Requirements

Versions Min JVM
2.0.0 17
1.1.0 11

Motivation

There are several reflection based libraries which allow the developers to easily manipulate objects during runtime. What separates this library is that it uses the newer API (java.lang.invoke) which allows faster code if used properly, compared to the classic java.lang.reflect package.

Because several additions have been added in Java 9 setting the minimum required Java version to anything lower is not feasible (it would not make sense to create another library, which would not be any different from the existing ones).

The project was inspired by jOOR. If you are using an older Java I suggest using that instead.

Examples

        // Get the name of the school principal by field access
        final String principalName = BeanMirror.of(school, MethodHandles.lookup())
                .field("principal", Principal.class)
                .get("name", String.class);
        // Create a setter function to set the value on any instance
        final BiConsumer<Student, Integer> setter = BeanMirror.of(Student.class, MethodHandles.lookup())
                .createSetter("startingYear", Integer.class);

        setter.accept(student, 2018);
        setter.accept(otherStudent, 2020);

Documentation

Javadoc

Gradle

implementation 'com.github.elopteryx:bean-mirror:2.0.0'

Maven

<dependency>
    <groupId>com.github.elopteryx</groupId>
    <artifactId>bean-mirror</artifactId>
    <version>2.0.0</version>
</dependency>

Find available versions on Maven Central Repository.

bean-mirror's People

Contributors

elopteryx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bean-mirror's Issues

No Licence

This Project has no license. Please consider adding one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.