001/*
002Copyright 2022 The OpenFunction Authors.
003
004Licensed under the Apache License, Version 2.0 (the "License");
005you may not use this file except in compliance with the License.
006You may obtain a copy of the License at
007
008    http://www.apache.org/licenses/LICENSE-2.0
009
010Unless required by applicable law or agreed to in writing, software
011distributed under the License is distributed on an "AS IS" BASIS,
012WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013See the License for the specific language governing permissions and
014limitations under the License.
015*/
016
017package dev.openfunction.functions;
018
019import java.nio.ByteBuffer;
020import java.util.Map;
021
022public class Out {
023    /**
024     * code is return code of the user function
025     */
026    private int code;
027
028    /**
029     * error is the error returned by the user function.
030     */
031    private Error error;
032
033    /**
034     * data is the return data of the user function
035     */
036    private ByteBuffer data;
037    /**
038     * metadata is the metadata of the event
039     */
040    private Map<String, String> metadata;
041
042    public Out() {
043    }
044
045    public Out(int code, Error error, ByteBuffer data, Map<String, String> metadata) {
046        this.code = code;
047        this.error = error;
048        this.data = data;
049        this.metadata = metadata;
050    }
051
052    public int getCode() {
053        return code;
054    }
055
056    public Out setCode(int code) {
057        this.code = code;
058        return this;
059    }
060
061    public ByteBuffer getData() {
062        return data;
063    }
064
065    public Out setData(ByteBuffer data) {
066        this.data = data;
067        return this;
068    }
069
070    public Map<String, String> getMetadata() {
071        return metadata;
072    }
073
074    public Out setMetadata(Map<String, String> metadata) {
075        this.metadata = metadata;
076        return this;
077    }
078
079    public Error getError() {
080        return error;
081    }
082
083    public Out setError(Error error) {
084        this.error = error;
085        return this;
086    }
087}