[
https://issues.apache.org/jira/browse/BEAM-6240?focusedWorklogId=181867&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-181867
]
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_r245689019
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/annotations/SchemaCreate.java
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.schemas.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.annotations.Experimental.Kind;
+
+/**
+ * Can be put on a constructor or a static method, in which case that
constructor or method will be
+ * used to created instance of the class by Beam's schema code.
+ *
+ * <p>For example, the following Java POJO.
+ *
+ * <pre><code>
+ * {@literal @}DefaultSchema(JavaBeanSchema.class)
+ * class MyClass {
+ * public final String user;
+ * public final int age;
+ *
+ * {@literal @}SchemaCreate
+ * public MyClass(String user, int age) {
+ * this.user = user;
+ * this.age = age;
+ * }
+ * }
+ * </code></pre>
+ *
+ * <p>This tells Beam that this constructor can be used to construct
instances. Beam will match up
+ * the names of the constructor arguments to schema fields in order to decide
how to create the
+ * class from a Row.
+ *
+ * <p>This can also be used to annotate a static factory method on the class.
For example:
+ *
+ * <pre><code>
+ * {@literal @}DefaultSchema(JavaBeanSchema.class)
+ * class MyClass {
+ * public final String user;
+ * public final int age;
+ *
+ * private MyClass(String user, int age) { this.user = user; this.age = age;
}
+ *
+ * {@literal @}SchemaCreate
+ * public MyClass create(String user, int age) {
Review comment:
`s/public/public static/`
----------------------------------------------------------------
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: 181867)
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)