You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "dennis lucero (JIRA)" <ji...@apache.org> on 2013/12/03 16:35:35 UTC

[jira] [Commented] (AVRO-1400) Introduce annotation to specify default values

    [ https://issues.apache.org/jira/browse/AVRO-1400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13837799#comment-13837799 ] 

dennis lucero commented on AVRO-1400:
-------------------------------------

Your patch lacks the definition for the AvroDefault annotation. Using my own definition noted below, the code seems legit for me.

{code:java}
package org.apache.avro.reflect;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Sets the given default value as JSON String for the annotated field.
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface AvroDefault {
    String value();
}
{code}

> Introduce annotation to specify default values
> ----------------------------------------------
>
>                 Key: AVRO-1400
>                 URL: https://issues.apache.org/jira/browse/AVRO-1400
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.5
>            Reporter: dennis lucero
>              Labels: annotation, features, reflection, schema
>         Attachments: AVRO-1400.patch
>
>
> It would be nice if there was an annotation in org.apache.avro.reflect to specify default values for schemata derived reflectively, allowing for proper schema evolution.
> I suggest the following:
> {code:java}
> @AvroDefault(1)
> int someNum;
> @Nullable
> @AvroDefault(null)
> AnotherRecord myRec;
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)