blob: 6b8f5b2a2e48e74790df7d8c9e271cc45f0012f8 [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM
4 * ================================================================================
5 * Copyright (C) 2018 AT&T
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20
21
22
23package org.onap.osam.job;
24
25import org.onap.osam.job.command.*;
26
27import java.util.Map;
28import java.util.stream.Collectors;
29import java.util.stream.Stream;
30
31public enum JobType {
32
33 HttpCall(HttpCallCommand.class),
34 AggregateState(AggregateStateCommand.class),
35 InProgressStatus(InProgressStatusCommand.class),
36 NoOp(NoOpCommand.class),
37 ServiceInstantiation(ServiceInstantiationCommand.class);
38
39 private static final Map<Class, JobType> REVERSE_MAP = Stream.of(values()).collect(Collectors.toMap(t -> t.getCommandClass(), t -> t));
40
41 private final Class commandClass;
42
43 <T extends JobCommand> JobType(Class<T> commandClass) {
44 this.commandClass = commandClass;
45 }
46
47 public Class getCommandClass() {
48 return commandClass;
49 }
50 static JobType jobTypeOf(Class commandClass) {
51 return REVERSE_MAP.get(commandClass);
52 }
53}