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>QApiAnonymousUnionDescriptor{name=BlockdevRef, data={definition=BlockdevOptions, reference=str}, innerTypes=null, fields=null}</pre> 017 */ 018@JsonInclude(JsonInclude.Include.NON_EMPTY) 019public class BlockdevRef extends QApiType implements QApiUnion { 020 021 // union { 022 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 023 @JsonProperty("definition") 024 @JsonUnwrapped 025 @CheckForNull 026 public BlockdevOptions definition; 027 @SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") 028 @JsonProperty("reference") 029 @JsonUnwrapped 030 @CheckForNull 031 public java.lang.String reference; 032 // } 033 034 @Nonnull 035 public static BlockdevRef definition(@Nonnull BlockdevOptions definition) { 036 BlockdevRef self = new BlockdevRef(); 037 self.definition = definition; 038 return self; 039 } 040 041 @Nonnull 042 public static BlockdevRef reference(@Nonnull java.lang.String reference) { 043 BlockdevRef self = new BlockdevRef(); 044 self.reference = reference; 045 return self; 046 } 047 048 /** This overrides @JsonUnwrapped. */ 049 @JsonValue 050 public Object toJsonValue() { 051 if (definition != null) 052 return definition; 053 if (reference != null) 054 return reference; 055 return null; 056 } 057 058 @Override 059 public java.util.List<java.lang.String> getFieldNames() { 060 java.util.List<java.lang.String> names = super.getFieldNames(); 061 names.add("definition"); 062 names.add("reference"); 063 return names; 064 } 065 066 @JsonIgnore 067 @Override 068 public Object getFieldByName(@Nonnull java.lang.String name) throws NoSuchFieldException { 069 if ("definition".equals(name)) 070 return definition; 071 if ("reference".equals(name)) 072 return reference; 073 return super.getFieldByName(name); 074 } 075 076 @Override 077 @JsonIgnore 078 public boolean isValidUnion() { 079 int count = 0; 080 if (definition != null) 081 count++; 082 if (reference != null) 083 count++; 084 return (count == 1); 085 } 086}