vlingo / xoom-schemata

The VLINGO XOOM Schema Registry.
https://vlingo.io
Mozilla Public License 2.0
17 stars 9 forks source link

Add support for array fields and array field default values #131

Closed wwerner closed 4 years ago

wwerner commented 4 years ago

Adds support for default array values of basic types.

Example:

event SalutationHappened {
    boolean[] booleanAttribute = {true, false, true}
    byte[] byteAttribute = {4, 3, 2, 1}
    char[] charAttribute = {'x', 'y', 'z'}
    double[] doubleAttribute = {0.23, 0.22, 0.21}
    float[] floatAttribute = {0.42f, 0.42f, 0.1f}
    int[] intAttribute = {4242, 424242, 42424242 }
    long[] longAttribute = {42L, 4242L, 424242L}
    short[] shortAttribute = {258, 259, 260}
    string[] stringAttribute = {"foo", "bar", "baz" }
}

⬇️

package Context.event;

import io.vlingo.lattice.model.DomainEvent;
import java.lang.String;

public final class SalutationHappened extends DomainEvent {
  public boolean[] booleanAttribute = new boolean[] { true, false, true };

  public byte[] byteAttribute = new byte[] { 4, 3, 2, 1 };

  public char[] charAttribute = new char[] { 'x', 'y', 'z' };

  public double[] doubleAttribute = new double[] { 0.23, 0.22, 0.21 };

  public float[] floatAttribute = new float[] { 0.42f, 0.42f, 0.1f };

  public int[] intAttribute = new int[] { 4242, 424242, 42424242 };

  public long[] longAttribute = new long[] { 42L, 4242L, 424242L };

  public short[] shortAttribute = new short[] { 258, 259, 260 };

  public String[] stringAttribute = new java.lang.String[] { "foo", "bar", "baz" };

  public SalutationHappened() {
  }

  public SalutationHappened(final boolean[] booleanAttribute, final byte[] byteAttribute,
      final char[] charAttribute, final double[] doubleAttribute, final float[] floatAttribute,
      final int[] intAttribute, final long[] longAttribute, final short[] shortAttribute,
      final String[] stringAttribute) {
    this.booleanAttribute = booleanAttribute; 
    this.byteAttribute = byteAttribute; 
    this.charAttribute = charAttribute; 
    this.doubleAttribute = doubleAttribute; 
    this.floatAttribute = floatAttribute; 
    this.intAttribute = intAttribute; 
    this.longAttribute = longAttribute; 
    this.shortAttribute = shortAttribute; 
    this.stringAttribute = stringAttribute; }
}

Closes #22

wwerner commented 4 years ago

@kmruiz, I'd love to get your review on this. It still needs some E2E tests, but the backend is done, I think.

One thing I couldn't figure out this evening is why in the default initializer the fully qualified class name is used: https://github.com/vlingo/vlingo-schemata/pull/131/files#diff-0b8241a93d764d58f6d4d496c090d219R90

If you have a pointer, cool, otherwise I'll figure it out later.