de.adito.propertly:propertly.parent

a listenable hierarchical data model

License

License

MIT License
GroupId

GroupId

de.adito.propertly
ArtifactId

ArtifactId

propertly.parent
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

pom
Description

Description

de.adito.propertly:propertly.parent
a listenable hierarchical data model
Project URL

Project URL

https://github.com/aditosoftware/propertly
Project Organization

Project Organization

ADITO Software GmbH
Source Code Management

Source Code Management

https://github.com/aditosoftware/propertly

Download propertly.parent

How to add to project

<!-- https://jarcasting.com/artifacts/de.adito.propertly/propertly.parent/ -->
<dependency>
    <groupId>de.adito.propertly</groupId>
    <artifactId>propertly.parent</artifactId>
    <version>1.0.3</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/de.adito.propertly/propertly.parent/
implementation 'de.adito.propertly:propertly.parent:1.0.3'
// https://jarcasting.com/artifacts/de.adito.propertly/propertly.parent/
implementation ("de.adito.propertly:propertly.parent:1.0.3")
'de.adito.propertly:propertly.parent:pom:1.0.3'
<dependency org="de.adito.propertly" name="propertly.parent" rev="1.0.3">
  <artifact name="propertly.parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='de.adito.propertly', module='propertly.parent', version='1.0.3')
)
libraryDependencies += "de.adito.propertly" % "propertly.parent" % "1.0.3"
[de.adito.propertly/propertly.parent "1.0.3"]

Dependencies

provided (1)

Group / Artifact Type Version
org.jetbrains : annotations Optional jar 16.0.3

test (2)

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

Project Modules

  • propertly.core
  • propertly.reactive
  • propertly.serialization

Propertly

Build Status

Propertly is a java framework for data structures similar to java beans. As with java beans everything is defined solely with java objects. The project is motivated by the many shortcomings java beans have.

Example of usage

A simple IPropertyPitProvider. Properties are first name, last name and age.

// Generics describe parent, self and children
public class StudentPropertyPitProvider 
    extends AbstractPPP<IPropertyPitProvider, StudentPropertyPitProvider, Object>
{
  // IPropertyDescription gives static access to an IProperty's meta data like name and type.
  public static final IPropertyDescription<StudentPropertyPitProvider, String> FIRST_NAME =
      PD.create(StudentPropertyPitProvider.class);

  public static final IPropertyDescription<StudentPropertyPitProvider, String> LAST_NAME =
      PD.create(StudentPropertyPitProvider.class);

  public static final IPropertyDescription<StudentPropertyPitProvider, Integer> AGE =
      PD.create(StudentPropertyPitProvider.class);


  // Getters and setters can of course still be used for easier access. 
  public String getFirstName()
  {
    // getValue and setValue is available at AbstractPPP. That class is used for easier access. 
    // Propertly can be used without inheriting from that class, too.
    return getValue(FIRST_NAME);
  }

  public void setFirstName(String pFirstName)
  {
    setValue(FIRST_NAME, pFirstName);
  }

  public String getLastName()
  {
    return getValue(LAST_NAME);
  }

  public void setLastName(String pLastName)
  {
    setValue(LAST_NAME, pLastName);
  }

  public Integer getAge()
  {
    return getValue(AGE);
  }

  public void setAge(Integer pAge)
  {
    setValue(AGE, pAge);
  }

}

Using the defined provider:

public class Sample
{

  public static void main(String[] args)
  {
    // Hierarchy is necessary to initialize the IPropertyPitProviders and for advanced features.
    Hierarchy<StudentPropertyPitProvider> hierarchy =
        new Hierarchy<>("student1", new StudentPropertyPitProvider());
    // The created student can be accessed from the hierarchy.
    StudentPropertyPitProvider student = hierarchy.getValue();
    // Listeners can be added.
    student.addStrongListener(new PropertyPitEventAdapter()
    {
      @Override
      public void propertyValueChanged(@NotNull IProperty pProperty, @Nullable Object pOldValue, @Nullable Object pNewValue, @NotNull Set pAttributes)
      {
        System.out.println(pProperty.getName() + "=" + pNewValue);
      }
    });

    // The following calls will cause
    //  FIRST_NAME=Nils
    //  LAST_NAME=Holgersson
    //  AGE=32
    // to be printed on console through the listener.
    student.setFirstName("Nils");
    student.setLastName("Holgersson");
    student.setAge(32);
  }

}

Comparison to java beans:

Design decisions:

  • No reflection. Interfaces are used to access models and fields. This way adaption is possible.
  • Models and fields are defined using interfaces so that composition can be applied.
  • Separation of store and access allows extensions.
  • Listeners can be used at field, model and structure level.
  • The tree can be navigated up and down.
  • Dynamic models where fields can be added and removed at runtime are possible.

Additionally java beans power is preserved:

  • Statically typed. Many errors can be noticed at compilation.
  • Getter and setter can be provided and used.

The main draw backs compared to java beans are:

  • Increased complexity.
  • Generics are sometimes nasty.

Class overview:

The most important objects in Propertly are IPropertyDescription, IProperty, IPropertyPit, IPropertyPitProvider and IHierarchy:

  • IPropertyDescription provides static meta data about an field.
  • IProperty gives access to a fields data and it's meta data.
  • IPropertyPit gives access to IProperty objects.
  • IPropertyPitProvider describes an IPropertyPit and gives access to it.
  • IHierarchy is the tree with IPropertyPitProvider objects as nodes.
de.adito.propertly

ADITO Software GmbH

Versions

Version
1.0.3
1.0.2
1.0.1
0.4.2
0.4.1
0.4