001/* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005package org.anarres.qemu.qapi.common; 006 007import com.fasterxml.jackson.annotation.JsonIgnore; 008import com.fasterxml.jackson.annotation.JsonInclude; 009import com.fasterxml.jackson.annotation.JsonProperty; 010import javax.annotation.CheckForNull; 011import javax.annotation.Nonnull; 012 013/** 014 * A QApi Command. 015 * 016 * While the library provides a set of subclasses of QApiCommand generated from 017 * the JSON schema, arbitrary subclasses may be constructed and transmitted 018 * in order to access experimental features. 019 * 020 * @author shevek 021 */ 022public class QApiCommand<Argument, Response extends QApiResponse<?>> extends QApiObject { 023 024 @JsonProperty("execute") 025 private final String commandName; 026 @JsonIgnore 027 private transient final Class<Response> returnType; 028 @JsonProperty("arguments") 029 @JsonInclude(JsonInclude.Include.NON_NULL) 030 private final Argument argument; 031 032 public QApiCommand(@Nonnull String commandName, @Nonnull Class<Response> returnType, @CheckForNull Argument argument) { 033 this.commandName = commandName; 034 this.returnType = returnType; 035 this.argument = argument; 036 } 037 038 @Nonnull 039 public String getCommandName() { 040 return commandName; 041 } 042 043 @Nonnull 044 @JsonIgnore 045 public Class<Response> getReturnType() { 046 return returnType; 047 } 048 049 @CheckForNull 050 public Argument getArgument() { 051 return argument; 052 } 053}