/** * Creates a new instance of {@link Frame}. * * @param command the command, must not be {@code null} * @param headers the headers, must not be {@code null} * @param body the body */ public Frame(Command command, Map<String, String> headers, Buffer body) { Objects.requireNonNull(command, "The frame command must be set"); Objects.requireNonNull(headers, "The headers must be set to empty if none"); this.command = command; this.headers = headers; this.body = body; validate(); }
/** * Creates a new instance of {@link Frame} from its JSON representation. * * @param json the json form of the frame */ public Frame(JsonObject json) { this(); FrameConverter.fromJson(json, this); validate(); }
/** * Creates a new instance of {@link Frame} by copying the values from the {@code other} frame. The body of the * frame is copied. * * @param other the frame to copy. */ public Frame(Frame other) { this(); this.command = other.command; this.headers.putAll(headers); if (other.body != null) { this.body = other.body.copy(); } validate(); }