Peter Penzov
Peter Penzov

Reputation: 1668

Return String from enum

I want to use this enum structure in order to return string.

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;
    }
}

When I use Exchanges.PROCESSING I get error:

Syntax error, insert "VariableDeclarators" to complete 
 LocalVariableDeclaration

How I can fix this issue?

Upvotes: 1

Views: 224

Answers (1)

Lorelorelore
Lorelorelore

Reputation: 3393

channel.exchangeDeclare(String exchange , BuiltinExchangeType obj)

should be

channel.exchangeDeclare(Exchanges exchange , BuiltinExchangeType obj)

or you should change the method call

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

to

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

Upvotes: 3

Related Questions