aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/command/CommandType.java
blob: 56596fa413ec4098f3fc5edb1f22788189947044 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.traccar.command;

import org.traccar.model.Factory;

public enum CommandType implements Factory {
    STOP_POSITIONING(NoParameterCommand.class),
    FIX_POSITIONING(FixPositioningCommand.class),
    STOP_ENGINE(NoParameterCommand.class),
    RESUME_ENGINE(NoParameterCommand.class);

    private final Class<? extends GpsCommand> commandClass;

    CommandType(Class<? extends GpsCommand> commandClass) {
        this.commandClass = commandClass;
    }

    @Override
    public Object create() {
        try {
            return commandClass.newInstance();
        } catch (InstantiationException | IllegalAccessException error) {
            throw new RuntimeException(error);
        }
    }
}