A field in a schema
| 20 | * A field in a schema |
| 21 | */ |
| 22 | public class Field { |
| 23 | |
| 24 | public static final Object NO_DEFAULT = new Object(); |
| 25 | |
| 26 | final int index; |
| 27 | public final String name; |
| 28 | public final Type type; |
| 29 | public final Object defaultValue; |
| 30 | public final String doc; |
| 31 | final Schema schema; |
| 32 | |
| 33 | public Field(int index, String name, Type type, String doc, Object defaultValue, Schema schema) { |
| 34 | this.index = index; |
| 35 | this.name = name; |
| 36 | this.type = type; |
| 37 | this.doc = doc; |
| 38 | this.defaultValue = defaultValue; |
| 39 | this.schema = schema; |
| 40 | if (defaultValue != NO_DEFAULT) |
| 41 | type.validate(defaultValue); |
| 42 | } |
| 43 | |
| 44 | public Field(int index, String name, Type type, String doc, Object defaultValue) { |
| 45 | this(index, name, type, doc, defaultValue, null); |
| 46 | } |
| 47 | |
| 48 | public Field(String name, Type type, String doc, Object defaultValue) { |
| 49 | this(-1, name, type, doc, defaultValue); |
| 50 | } |
| 51 | |
| 52 | public Field(String name, Type type, String doc) { |
| 53 | this(name, type, doc, NO_DEFAULT); |
| 54 | } |
| 55 | |
| 56 | public Field(String name, Type type) { |
| 57 | this(name, type, ""); |
| 58 | } |
| 59 | |
| 60 | public Type type() { |
| 61 | return type; |
| 62 | } |
| 63 | |
| 64 | } |
nothing calls this directly
no outgoing calls
no test coverage detected