Immutable Object Graph Instantiator

Library for instantiating graphs of objects

License

License

GroupId

GroupId

br.com.caelum
ArtifactId

ArtifactId

iogi
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Immutable Object Graph Instantiator
Library for instantiating graphs of objects
Project URL

Project URL

https://github.com/rafaeldff/Iogi
Source Code Management

Source Code Management

https://github.com/rafaeldff/Iogi

Download iogi

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
com.thoughtworks.paranamer : paranamer jar 2.5
com.google.guava : guava jar 11.0.2
net.vidageek : mirror jar 1.6.1

test (6)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-core jar 1.3
org.jmock : jmock jar 2.5.1
org.hamcrest : hamcrest-library jar 1.3
org.jmock : jmock-legacy jar 2.5.1
javassist : javassist jar 3.12.1.GA

Project Modules

There are no modules declared in this project.

Immutable Object Graph Instantiation

Build Status

What is Iogi

Iogi is a small library for instantiating objects (and graphs therof) in Java. It's primary motivation is to help with unmarshalling request parameters in Web applications.

The project was born as a spin-off of the VRaptor Web Framework. Many frameworks use OGLN to construct objects, but, as it's name atests, OGNL is most useful as a language for navigating object graphs. As such, it is oriented around properties as getter/setter pairs. Iogi, on the other hand, is able to instantiate objects through constructor parameters or setters. Iogi also supports dependency injection, so you can inject arbitrary objects (perhaps with the help of a DI framework) into your domain objects as they are instantiated.

Sample code

Here are some sample classes that you might want to instantiate:

public static class House {
    private Cat cat;

    public void setCat(final Cat cat) {
        this.cat = cat;
    }

    public Cat getCat() {
        return cat;
    }
}

public static class Cat {
    private Leg firstLeg;

    public void setFirstLeg(final Leg firstLeg) {
        this.firstLeg = firstLeg;
    }

    public Leg getFirstLeg() {
        return firstLeg;
    }
}

public static class Leg {
    private Integer id;

    public void setId(final Integer id) {
        this.id = id;
    }

}

And here is how you can instantiate them with Iogi:

final Target<House> target = Target.create(House.class, "house");
final Parameter parameter = new Parameter("house.cat.firstLeg.id", "42");
final House house = iogi.instantiate(target, parameter);
assertThat(house.cat.firstLeg.id, is(equalTo(42)));

Installing with Maven

Altough some old versions can be found in mvnrepository, Iogi is currently distributed through sonatype repositories. So, if you are using maven, you can simply add the following dependency to your pom.xml:

<dependency>
	<groupId>br.com.caelum</groupId>
	<artifactId>iogi</artifactId>
	<version>1.0.0</version>
</dependency>

And add sonatype repository:

<repository>
	<id>sonatype-oss-public</id>
	<url>http://oss.sonatype.org/content/groups/public/</url>
	<releases>
		<enabled>true</enabled>
	</releases>
	<snapshots>
		<enabled>true</enabled>
	</snapshots>
</repository>

Versions

Version
1.0.1
1.0.0
0.9.2
0.9.1
0.9.0