001/** 002 * Autogenerated by Avro 003 * 004 * DO NOT EDIT DIRECTLY 005 */ 006package org.apache.hadoop.io.serializer.avro; 007@SuppressWarnings("all") 008@org.apache.avro.specific.AvroGenerated 009public class AvroRecord extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { 010 public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"AvroRecord\",\"namespace\":\"org.apache.hadoop.io.serializer.avro\",\"fields\":[{\"name\":\"intField\",\"type\":\"int\"}]}"); 011 public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } 012 @Deprecated public int intField; 013 014 /** 015 * Default constructor. Note that this does not initialize fields 016 * to their default values from the schema. If that is desired then 017 * one should use <code>newBuilder()</code>. 018 */ 019 public AvroRecord() {} 020 021 /** 022 * All-args constructor. 023 */ 024 public AvroRecord(java.lang.Integer intField) { 025 this.intField = intField; 026 } 027 028 public org.apache.avro.Schema getSchema() { return SCHEMA$; } 029 // Used by DatumWriter. Applications should not call. 030 public java.lang.Object get(int field$) { 031 switch (field$) { 032 case 0: return intField; 033 default: throw new org.apache.avro.AvroRuntimeException("Bad index"); 034 } 035 } 036 // Used by DatumReader. Applications should not call. 037 @SuppressWarnings(value="unchecked") 038 public void put(int field$, java.lang.Object value$) { 039 switch (field$) { 040 case 0: intField = (java.lang.Integer)value$; break; 041 default: throw new org.apache.avro.AvroRuntimeException("Bad index"); 042 } 043 } 044 045 /** 046 * Gets the value of the 'intField' field. 047 */ 048 public java.lang.Integer getIntField() { 049 return intField; 050 } 051 052 /** 053 * Sets the value of the 'intField' field. 054 * @param value the value to set. 055 */ 056 public void setIntField(java.lang.Integer value) { 057 this.intField = value; 058 } 059 060 /** Creates a new AvroRecord RecordBuilder */ 061 public static org.apache.hadoop.io.serializer.avro.AvroRecord.Builder newBuilder() { 062 return new org.apache.hadoop.io.serializer.avro.AvroRecord.Builder(); 063 } 064 065 /** Creates a new AvroRecord RecordBuilder by copying an existing Builder */ 066 public static org.apache.hadoop.io.serializer.avro.AvroRecord.Builder newBuilder(org.apache.hadoop.io.serializer.avro.AvroRecord.Builder other) { 067 return new org.apache.hadoop.io.serializer.avro.AvroRecord.Builder(other); 068 } 069 070 /** Creates a new AvroRecord RecordBuilder by copying an existing AvroRecord instance */ 071 public static org.apache.hadoop.io.serializer.avro.AvroRecord.Builder newBuilder(org.apache.hadoop.io.serializer.avro.AvroRecord other) { 072 return new org.apache.hadoop.io.serializer.avro.AvroRecord.Builder(other); 073 } 074 075 /** 076 * RecordBuilder for AvroRecord instances. 077 */ 078 public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<AvroRecord> 079 implements org.apache.avro.data.RecordBuilder<AvroRecord> { 080 081 private int intField; 082 083 /** Creates a new Builder */ 084 private Builder() { 085 super(org.apache.hadoop.io.serializer.avro.AvroRecord.SCHEMA$); 086 } 087 088 /** Creates a Builder by copying an existing Builder */ 089 private Builder(org.apache.hadoop.io.serializer.avro.AvroRecord.Builder other) { 090 super(other); 091 if (isValidValue(fields()[0], other.intField)) { 092 this.intField = data().deepCopy(fields()[0].schema(), other.intField); 093 fieldSetFlags()[0] = true; 094 } 095 } 096 097 /** Creates a Builder by copying an existing AvroRecord instance */ 098 private Builder(org.apache.hadoop.io.serializer.avro.AvroRecord other) { 099 super(org.apache.hadoop.io.serializer.avro.AvroRecord.SCHEMA$); 100 if (isValidValue(fields()[0], other.intField)) { 101 this.intField = data().deepCopy(fields()[0].schema(), other.intField); 102 fieldSetFlags()[0] = true; 103 } 104 } 105 106 /** 107 * Gets the value of the 'intField' field. 108 */ 109 public java.lang.Integer getIntField() { 110 return intField; 111 } 112 113 /** 114 * Sets the value of the 'intField' field. 115 * @param value the value to set. 116 */ 117 public org.apache.hadoop.io.serializer.avro.AvroRecord.Builder setIntField(int value) { 118 validate(fields()[0], value); 119 this.intField = value; 120 fieldSetFlags()[0] = true; 121 return this; 122 } 123 124 /** 125 * Checks whether the 'intField' field has been set. 126 */ 127 public boolean hasIntField() { 128 return fieldSetFlags()[0]; 129 } 130 131 132 /** 133 * Clears the value of the 'intField' field. 134 */ 135 public org.apache.hadoop.io.serializer.avro.AvroRecord.Builder clearIntField() { 136 fieldSetFlags()[0] = false; 137 return this; 138 } 139 140 @Override 141 public AvroRecord build() { 142 try { 143 AvroRecord record = new AvroRecord(); 144 record.intField = fieldSetFlags()[0] ? this.intField : (java.lang.Integer) defaultValue(fields()[0]); 145 return record; 146 } catch (Exception e) { 147 throw new org.apache.avro.AvroRuntimeException(e); 148 } 149 } 150 } 151}