Epiphy

Epiphy is a lightweight library for property based data model access.

License

License

Categories

Categories

Ant Build Tools Data
GroupId

GroupId

com.mantledillusion.data
ArtifactId

ArtifactId

epiphy
Last Version

Last Version

4.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Epiphy
Epiphy is a lightweight library for property based data model access.
Project URL

Project URL

http://www.mantledillusion.com
Source Code Management

Source Code Management

https://github.com/MantledIllusion/epiphy.git

Download epiphy

How to add to project

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

Dependencies

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.7.0

Project Modules

There are no modules declared in this project.

epiphy

Epiphy is a lightweight library for property based data model access.

Epiphytes are pseudo-parasitic plants. They live on the surface of other organisms in order to benefit from their environment, but do not break that organism's surface, leaving the host unharmed. This prevents the host from getting injuries and diseases from the symbiosis, effectively extending the epiphyte life's length.

Possible applications

There are 2 main applications for epiphy:

  • To prevent boilerplate code when handling very complex data models on a lot of different places in an application
  • To generalize code of frameworks that have to handle abstracted model structures provided by the framework user

Data Model Abstraction

A model is the reproduced structure for a specific type of data. Hence, models can come in any shape or form, but they are always made up of the same base elements:

  • simple values that hold raw data, such as integers or strings
  • complex types with sub elements of any type, such as POJOs
  • collections of elements of any type, such as lists or maps

As a result, abstracting models comes down to abstracting these element types and allowing arbitrary combinations of them, which is exactly what epiphy allows:

public class Pojo {

    public static final ModelProperty<Pojo, Integer> ID = ModelProperty.fromObject(Pojo::getValue);
    public static final ModelPropertyList<Pojo, OtherPojo> SUBOBJECTS = ModelPropertyList.fromObject(Pojo::getSubObjects);
    public static final ModelProperty<Pojo, OtherPojo> SUBOBJECT = SUBOBJECTS.append(ModelProperty.fromList());
    public static final ModelProperty<Pojo, String> SUBOBJECT_VALUE = SUBOBJECT.append(OtherPojo.VALUE);

    private Integer id;
    private List<OtherPojo> subObjects;

    ...
}

public class OtherPojo {

    public static final ModelProperty<OtherPojo, String> VALUE = ModelProperty.fromObject(OtherPojo::getValue);
    
    private String value;

    ...
}

Depending on its type, each property allows generalized operations on its model.

For example by using the Pojo.SUBOBJECT_VALUE property of the code above, it would be possible to stream through all OtherPojo.value field's values of a parent Pojo instance by simply calling:

Pojo.SUBOBJECT_VALUE.stream(pojoInstance).forEach(*code*)

In relation, the code without properties would be:

if (pojoInstance != null) {
    for (OtherPojo otherPojoInstance: pojoInstance.getSeubObjects()) {
        if (otherPojoInstance != null && otherPojoInstance.getValue() != null) {
            *code*
        }
    }
}

These simplifications will become more and more versatile the deeper and more complex a model is.

Versions

Version
4.0.0
4.0.0.BETA1
4.0.0.ALPHA8
4.0.0.ALPHA7
4.0.0.ALPHA6
4.0.0.ALPHA5
4.0.0.ALPHA4
4.0.0.ALPHA3
4.0.0.ALPHA2
4.0.0.ALPHA1
3.0.0
3.0.0.ALPHA1
2.1.0
2.0.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0