Permalink
Browse files

AVRO-1205. Java: Add stereotype annotation to generated classes. Cont…

…ributed by Sharmarke Aden.

git-svn-id: https://svn.apache.org/repos/asf/avro/trunk@1412352 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent a2a7aea commit a8a905895a6a8a71617158bf4059f15905b3dd71 @cutting cutting committed Nov 21, 2012
View
@@ -21,6 +21,11 @@ Trunk (not yet released)
AVRO-1202. Java & Python: Add "Getting Started" guides.
(Skye Wanderman-Milne via cutting)
+ AVRO-1205. Java: Add stereotype annotation to generated classes.
+ All classes generated by the specific compiler now have the
+ annotation org.apache.avro.specific.AvroGenerated.
+ (Sharmarke Aden via cutting)
+
IMPROVEMENTS
AVRO-1169. Java: Reduce memory footprint of resolver.
@@ -0,0 +1,32 @@
+/**
+ * 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.avro.specific;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that an annotated class is an Avro generated class. All Avro
+ * generated classes will be annotated with this annotation.
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AvroGenerated {
+}
@@ -25,6 +25,7 @@ package $schema.getNamespace();
#foreach ($annotation in $this.javaAnnotations($schema))
@$annotation
#end
+@org.apache.avro.specific.AvroGenerated
public enum ${this.mangle($schema.getName())} {
#foreach ($symbol in ${schema.getEnumSymbols()})${this.mangle($symbol)}#if ($velocityHasNext), #end#end
;
@@ -26,6 +26,7 @@ package $schema.getNamespace();
@$annotation
#end
@org.apache.avro.specific.FixedSize($schema.getFixedSize())
+@org.apache.avro.specific.AvroGenerated
public class ${this.mangle($schema.getName())} extends org.apache.avro.specific.SpecificFixed {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}");
@@ -26,6 +26,7 @@ package $protocol.getNamespace();
#foreach ($annotation in $this.javaAnnotations($protocol))
@$annotation
#end
+@org.apache.avro.specific.AvroGenerated
public interface $this.mangle($protocol.getName()) {
public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse("${this.javaEscape($protocol.toString())}");
#foreach ($e in $protocol.getMessages().entrySet())
@@ -25,6 +25,7 @@ package $schema.getNamespace();
#foreach ($annotation in $this.javaAnnotations($schema))
@$annotation
#end
+@org.apache.avro.specific.AvroGenerated
public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends org.apache.avro.specific.SpecificExceptionBase#else extends org.apache.avro.specific.SpecificRecordBase#end implements org.apache.avro.specific.SpecificRecord {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}");
#foreach ($field in $schema.getFields())
@@ -5,6 +5,7 @@
*/
package avro.examples.baseball;
@SuppressWarnings("all")
+@org.apache.avro.specific.AvroGenerated
public class Player extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Player\",\"namespace\":\"avro.examples.baseball\",\"fields\":[{\"name\":\"number\",\"type\":\"int\"},{\"name\":\"first_name\",\"type\":\"string\"},{\"name\":\"last_name\",\"type\":\"string\"},{\"name\":\"position\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"enum\",\"name\":\"Position\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}}}]}");
@Deprecated public int number;
@@ -5,6 +5,7 @@
*/
package avro.examples.baseball;
@SuppressWarnings("all")
+@org.apache.avro.specific.AvroGenerated
public enum Position {
P, C, B1, B2, B3, SS, LF, CF, RF, DH ;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"Position\",\"namespace\":\"avro.examples.baseball\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}");

0 comments on commit a8a9058

Please sign in to comment.