Defining Entities

This is the manual for older MicroStream versions (Version < 5.0).

The new documentation (Version >= 5.0) is located at:

https://docs.microstream.one/

The entity types are just simple interfaces with value methods, which have following requirements:

  • A return type, no void

  • No parameters

  • No type parameters

  • No declared checked exceptions

You are not limited otherwise. Use any types you want. Inheritance and generics are supported as well.

Entities

public interface Beeing<B>
{
	public B partner();
}

There is one base type (Beeing), one feature interface (Named) and three entities (Animal, Pet, Human).

Generated Code

The code generator takes care of the three entities, and its output looks like this:

public class AnimalEntity extends EntityLayerIdentity implements Animal
{
	protected AnimalEntity()
	{
		super();
	}

	@Override
	protected Animal entityData()
	{
		return (Animal)super.entityData();
	}

	@Override
	public final String species()
	{
		return this.entityData().species();
	}

	@Override
	public final Animal partner()
	{
		return this.entityData().partner();
	}
}
public class PetEntity extends EntityLayerIdentity implements Pet
{
	protected PetEntity()
	{
		super();
	}

	@Override
	protected Pet entityData()
	{
		return (Pet)super.entityData();
	}

	@Override
	public final String species()
	{
		return this.entityData().species();
	}

	@Override
	public final Animal partner()
	{
		return this.entityData().partner();
	}

	@Override
	public final String name()
	{
		return this.entityData().name();
	}
}
public class HumanEntity extends EntityLayerIdentity implements Human
{
	protected HumanEntity()
	{
		super();
	}

	@Override
	protected Human entityData()
	{
		return (Human)super.entityData();
	}

	@Override
	public final Human partner()
	{
		return this.entityData().partner();
	}

	@Override
	public final String name()
	{
		return this.entityData().name();
	}
}

Last updated