[ 
https://issues.apache.org/jira/browse/BEAM-6240?focusedWorklogId=181868&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-181868
 ]

ASF GitHub Bot logged work on BEAM-6240:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Jan/19 16:06
            Start Date: 07/Jan/19 16:06
    Worklog Time Spent: 10m 
      Work Description: kanterov commented on pull request #7289: [BEAM-6240] 
Add a library of schema annotations for POJO and JavaBeans
URL: https://github.com/apache/beam/pull/7289#discussion_r245700197
 
 

 ##########
 File path: 
sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/utils/TestPOJOs.java
 ##########
 @@ -101,6 +104,249 @@ public int hashCode() {
   public static final Schema NESTED_NULLABLE_SCHEMA =
       Schema.builder().addNullableField("nested", 
FieldType.row(NULLABLES_SCHEMA)).build();
 
+  /** A POJO for testing static factory methods. */
+  @DefaultSchema(JavaFieldSchema.class)
+  public static class StaticCreationSimplePojo {
+    public final String str;
+    public final byte aByte;
+    public final short aShort;
+    public final int anInt;
+    public final long aLong;
+    public final boolean aBoolean;
+    public final DateTime dateTime;
+    public final Instant instant;
+    public final byte[] bytes;
+    public final ByteBuffer byteBuffer;
+    public final BigDecimal bigDecimal;
+    public final StringBuilder stringBuilder;
+
+    private StaticCreationSimplePojo(
+        String str,
+        byte aByte,
+        short aShort,
+        int anInt,
+        long aLong,
+        boolean aBoolean,
+        DateTime dateTime,
+        Instant instant,
+        byte[] bytes,
+        ByteBuffer byteBuffer,
+        BigDecimal bigDecimal,
+        StringBuilder stringBuilder) {
+      this.str = str;
+      this.aByte = aByte;
+      this.aShort = aShort;
+      this.anInt = anInt;
+      this.aLong = aLong;
+      this.aBoolean = aBoolean;
+      this.dateTime = dateTime;
+      this.instant = instant;
+      this.bytes = bytes;
+      this.byteBuffer = byteBuffer;
+      this.bigDecimal = bigDecimal;
+      this.stringBuilder = stringBuilder;
+    }
+
+    @SchemaCreate
+    public static StaticCreationSimplePojo of(
+        String str,
+        byte aByte,
+        short aShort,
+        int anInt,
+        long aLong,
+        boolean aBoolean,
+        DateTime dateTime,
+        Instant instant,
+        byte[] bytes,
+        ByteBuffer byteBuffer,
+        BigDecimal bigDecimal,
+        StringBuilder stringBuilder) {
+      return new StaticCreationSimplePojo(
+          str,
+          aByte,
+          aShort,
+          anInt,
+          aLong,
+          aBoolean,
+          dateTime,
+          instant,
+          bytes,
+          byteBuffer,
+          bigDecimal,
+          stringBuilder);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+      if (this == o) {
+        return true;
+      }
+      if (!(o instanceof StaticCreationSimplePojo)) {
+        return false;
+      }
+      StaticCreationSimplePojo that = (StaticCreationSimplePojo) o;
+      return aByte == that.aByte
+          && aShort == that.aShort
+          && anInt == that.anInt
+          && aLong == that.aLong
+          && aBoolean == that.aBoolean
+          && Objects.equals(str, that.str)
+          && Objects.equals(dateTime, that.dateTime)
+          && Objects.equals(instant, that.instant)
+          && Arrays.equals(bytes, that.bytes)
+          && Objects.equals(byteBuffer, that.byteBuffer)
+          && Objects.equals(bigDecimal, that.bigDecimal)
+          && Objects.equals(stringBuilder.toString(), 
that.stringBuilder.toString());
+    }
+
+    @Override
+    public int hashCode() {
+      int result =
+          Objects.hash(
+              str,
+              aByte,
+              aShort,
+              anInt,
+              aLong,
+              aBoolean,
+              dateTime,
+              instant,
+              byteBuffer,
+              bigDecimal,
+              stringBuilder);
+      result = 31 * result + Arrays.hashCode(bytes);
+      return result;
+    }
+  }
+
+  /** A POJO for testing annotations. */
+  @DefaultSchema(JavaFieldSchema.class)
+  public static class AnnotatedSimplePojo {
+    public final String str;
+
+    @FieldName("aByte")
+    public final byte theByte;
+
+    @FieldName("aShort")
+    public final short theShort;
+
+    public final int anInt;
+    public final long aLong;
+    public final boolean aBoolean;
+    public final DateTime dateTime;
+    public final Instant instant;
+    public final byte[] bytes;
+    public final ByteBuffer byteBuffer;
+    public final BigDecimal bigDecimal;
+    public final StringBuilder stringBuilder;
+    @SchemaIgnore public final Integer pleaseIgnore;
+
+    // Marked with SchemaCreate, so this will be called to construct instances.
+    @SchemaCreate
+    public AnnotatedSimplePojo(
 
 Review comment:
   Can you re-order parameters? As I understand, it's supposed to work.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 181868)
    Time Spent: 2h 20m  (was: 2h 10m)

> Allow users to annotate POJOs and JavaBeans for richer functionality
> --------------------------------------------------------------------
>
>                 Key: BEAM-6240
>                 URL: https://issues.apache.org/jira/browse/BEAM-6240
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Assignee: Reuven Lax
>            Priority: Major
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Desired annotations:
>   * SchemaIgnore - ignore this field
>   * FieldName - allow the user to explicitly specify a field name
>   * SchemaCreate - register a function to be used to create an object (so 
> fields can be final, and no default constructor need be assumed).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to