aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/http/commands/CommandType.java
blob: 12610dbcc817f122d20de296ed15e0f394825665 (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
26
27
28
package org.traccar.http.commands;

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 Class<? extends GpsCommand> commandClass;

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

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