Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B59FED4C2 for ; Tue, 28 May 2013 13:58:21 +0000 (UTC) Received: (qmail 28269 invoked by uid 500); 28 May 2013 13:58:21 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 27947 invoked by uid 500); 28 May 2013 13:58:20 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 27927 invoked by uid 99); 28 May 2013 13:58:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 13:58:20 +0000 Date: Tue, 28 May 2013 13:58:20 +0000 (UTC) From: "Vincenz Priesnitz (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AVRO-1328) Java: Additional annotations for reflection MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-1328?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vincenz Priesnitz updated AVRO-1328: ------------------------------------ Resolution: Duplicate Status: Resolved (was: Patch Available) This issue is contained in the followup issue AVRO-1341. > Java: Additional annotations for reflection > ------------------------------------------- > > Key: AVRO-1328 > URL: https://issues.apache.org/jira/browse/AVRO-1328 > Project: Avro > Issue Type: New Feature > Components: java > Reporter: Vincenz Priesnitz > Assignee: Vincenz Priesnitz > Priority: Minor > Labels: patch > Attachments: AVRO-1328.patch, Avro-1328 update.patch > > > I added three java annotations to the reflect package: @AvroIgnore, @AvroName and @AvroMetadata. > Fields with the @AvroIgnore annotation will be treated as if they had a transient modifier, i.e. they will not be written to or rad from avro files. > Java fields with the @AvroName("alt_name") annotation will be renamed in the induced schema. > When reading an avro file into a new class via reflection, the reflection reader will also look for fields in the schema with the avro name. > For example, schema 'example' could be read into the class 'exampleClass'. > {code} > class exampleClass { > @Avroname("foo") > int bar; > } > {code} > {code} > { > "type" : "record", > "name" : "example", > "fields" : [ {"name" : "foo", "type" : "int" } ] > } > {code} > The @AvroMetadata(key="KEY", value="VALUE") annotation allows you to put an arbitrary key : value pair at every node in the schema. > {code} > @AvroMetadata(key="classKey", value="classValue") > class exampleClass { > @AvroMetadata(key="fieldKey", value="fieldValue") > int foo; > > } > {code} > {code} > { > "type" : "record", > "name" : "example", > "fields" : [ {"name" : "foo", "type" : "int", "fieldKey" : "fieldValue" } ]; > "classKey" : "classValue" > } > {code} > I also extended the @Stringable annotation to java fields. > This way one can turn objects to strings where the annotation cannot be added to the class itself. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira