从枚举返回字符串

时间:2018-06-14 10:05:57

标签: java

我想使用这个枚举结构来返回字符串。

public enum Exchanges {

    PROCESSING("processing");

    private final String type;

    Exchanges(final String type) {
        this.type = type;
    }

    public String getType() {
        return type;
    }

    @Override
    public String toString() {
        return type;
    }
}

当我使用Exchanges.PROCESSING时,我收到错误:

Syntax error, insert "VariableDeclarators" to complete 
 LocalVariableDeclaration

我如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

$model = 'App\Model\User';
$user=$model::where('id', $id)->first();

应该是

channel.exchangeDeclare(String exchange , BuiltinExchangeType obj)

或者您应该更改方法调用

channel.exchangeDeclare(Exchanges exchange , BuiltinExchangeType obj)

channel.exchangeDeclare(Exchanges.PROCESSING, BuiltinExchangeType.TOPIC);