2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.nemo.intent.condition;
\r
11 import org.opendaylight.nemo.intent.IntentResolver;
\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.user.intent.operations.Operation;
\r
15 import java.util.Map;
\r
16 import java.util.concurrent.ConcurrentHashMap;
\r
19 * Created by j00212933 on 2015/11/23.
\r
21 public class ConditionManager implements IConditionManager {
\r
25 private Map<UserId, IConditionHandler> conditionHandlers = null;
\r
26 private IntentResolver intentResolver;
\r
28 public ConditionManager(IntentResolver intentResolver) {
\r
29 this.conditionHandlers = new ConcurrentHashMap<UserId, IConditionHandler>();
\r
30 this.intentResolver = intentResolver;
\r
33 public void handleOperation(UserId userId, Operation operation) {
\r
34 if (!conditionHandlers.containsKey(userId)) {
\r
35 conditionHandlers.put(userId, new ConditionHandlerImpl(intentResolver, userId));
\r
37 conditionHandlers.get(userId).handleCondition(operation);
\r
40 public void clear(UserId userId) {
\r
41 IConditionHandler conditionHandler = conditionHandlers.remove(userId);
\r
42 if (conditionHandler != null) {
\r
43 conditionHandler.clearCondition();
\r