All Downloads are FREE. Search and download functionalities are using the official Maven repository.

yakworks.api.ResultTrait.groovy Maven / Gradle / Ivy

There is a newer version: 3.14
Show newest version
/*
* Copyright 2021 original authors
* SPDX-License-Identifier: Apache-2.0
*/
package yakworks.api

import groovy.transform.CompileStatic

import yakworks.message.Msg
import yakworks.message.MsgKey

/**
 * Groovy Trait impl for Result, provides the simple builder methods
 *
 * @author Joshua Burnett (@basejump)
 * @since 1
 */
@CompileStatic
trait ResultTrait implements GenericResult {
    String defaultCode //= 'result.ok'
    Boolean ok = true
    ApiStatus status = HttpStatus.OK
    /** backing field for the getMsg */
    MsgKey msgKey
    String title
    Object payload

    MsgKey getMsg() {
        if(msgKey == null) msgKey = Msg.key(getDefaultCode())
        return msgKey
    }

    void setMsg(MsgKey v) { msgKey = v }

    @Override
    String toString() {
        return ResultUtils.resultToString(this)
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy