001package org.anarres.qemu.qapi.api; 002 003import com.fasterxml.jackson.annotation.JsonIgnore; 004import com.fasterxml.jackson.annotation.JsonInclude; 005import com.fasterxml.jackson.annotation.JsonProperty; 006import com.fasterxml.jackson.annotation.JsonUnwrapped; 007import com.fasterxml.jackson.annotation.JsonValue; 008import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 009import javax.annotation.CheckForNull; 010import javax.annotation.Nonnull; 011import org.anarres.qemu.qapi.common.*; 012 013/** 014 * Autogenerated class. 015 * 016 * <pre>QApiUnionDescriptor{name=SchemaInfo, discriminator=meta-type, data={builtin=SchemaInfoBuiltin, enum=SchemaInfoEnum, array=SchemaInfoArray, object=SchemaInfoObject, alternate=SchemaInfoAlternate, command=SchemaInfoCommand, event=SchemaInfoEvent}, innerTypes=null, fields=null, discriminatorField=null}</pre> 017 */ 018@JsonInclude(JsonInclude.Include.NON_EMPTY) 019public class SchemaInfo extends SchemaInfoBase implements QApiUnion { 020 021 // union { 022 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 023 @JsonProperty("builtin") 024 @JsonUnwrapped 025 @CheckForNull 026 public SchemaInfoBuiltin builtin; 027 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 028 @JsonProperty("enum") 029 @JsonUnwrapped 030 @CheckForNull 031 public SchemaInfoEnum _enum; 032 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 033 @JsonProperty("array") 034 @JsonUnwrapped 035 @CheckForNull 036 public SchemaInfoArray array; 037 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 038 @JsonProperty("object") 039 @JsonUnwrapped 040 @CheckForNull 041 public SchemaInfoObject object; 042 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 043 @JsonProperty("alternate") 044 @JsonUnwrapped 045 @CheckForNull 046 public SchemaInfoAlternate alternate; 047 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 048 @JsonProperty("command") 049 @JsonUnwrapped 050 @CheckForNull 051 public SchemaInfoCommand command; 052 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 053 @JsonProperty("event") 054 @JsonUnwrapped 055 @CheckForNull 056 public SchemaInfoEvent event; 057 // } 058 059 @Nonnull 060 public static SchemaInfo builtin(@Nonnull SchemaInfoBuiltin builtin) { 061 SchemaInfo self = new SchemaInfo(); 062 self.metaType = SchemaMetaType.builtin; 063 self.builtin = builtin; 064 return self; 065 } 066 067 @Nonnull 068 public static SchemaInfo _enum(@Nonnull SchemaInfoEnum _enum) { 069 SchemaInfo self = new SchemaInfo(); 070 self.metaType = SchemaMetaType._enum; 071 self._enum = _enum; 072 return self; 073 } 074 075 @Nonnull 076 public static SchemaInfo array(@Nonnull SchemaInfoArray array) { 077 SchemaInfo self = new SchemaInfo(); 078 self.metaType = SchemaMetaType.array; 079 self.array = array; 080 return self; 081 } 082 083 @Nonnull 084 public static SchemaInfo object(@Nonnull SchemaInfoObject object) { 085 SchemaInfo self = new SchemaInfo(); 086 self.metaType = SchemaMetaType.object; 087 self.object = object; 088 return self; 089 } 090 091 @Nonnull 092 public static SchemaInfo alternate(@Nonnull SchemaInfoAlternate alternate) { 093 SchemaInfo self = new SchemaInfo(); 094 self.metaType = SchemaMetaType.alternate; 095 self.alternate = alternate; 096 return self; 097 } 098 099 @Nonnull 100 public static SchemaInfo command(@Nonnull SchemaInfoCommand command) { 101 SchemaInfo self = new SchemaInfo(); 102 self.metaType = SchemaMetaType.command; 103 self.command = command; 104 return self; 105 } 106 107 @Nonnull 108 public static SchemaInfo event(@Nonnull SchemaInfoEvent event) { 109 SchemaInfo self = new SchemaInfo(); 110 self.metaType = SchemaMetaType.event; 111 self.event = event; 112 return self; 113 } 114 115 @Override 116 public java.util.List<java.lang.String> getFieldNames() { 117 java.util.List<java.lang.String> names = super.getFieldNames(); 118 names.add("builtin"); 119 names.add("enum"); 120 names.add("array"); 121 names.add("object"); 122 names.add("alternate"); 123 names.add("command"); 124 names.add("event"); 125 return names; 126 } 127 128 @JsonIgnore 129 @Override 130 public Object getFieldByName(@Nonnull java.lang.String name) throws NoSuchFieldException { 131 if ("builtin".equals(name)) 132 return builtin; 133 if ("enum".equals(name)) 134 return _enum; 135 if ("array".equals(name)) 136 return array; 137 if ("object".equals(name)) 138 return object; 139 if ("alternate".equals(name)) 140 return alternate; 141 if ("command".equals(name)) 142 return command; 143 if ("event".equals(name)) 144 return event; 145 return super.getFieldByName(name); 146 } 147 148 @Override 149 @JsonIgnore 150 public boolean isValidUnion() { 151 int count = 0; 152 if (builtin != null) 153 count++; 154 if (_enum != null) 155 count++; 156 if (array != null) 157 count++; 158 if (object != null) 159 count++; 160 if (alternate != null) 161 count++; 162 if (command != null) 163 count++; 164 if (event != null) 165 count++; 166 return (count == 1); 167 } 168}