Add yang generated packages in .gitignore
[groupbasedpolicy.git] / groupbasedpolicy / src / main / java / org / opendaylight / groupbasedpolicy / resolver / validator / validators / ActionInstanceValidator.java
1 package org.opendaylight.groupbasedpolicy.resolver.validator.validators;
2
3 /*
4  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5  *
6  * This program and the accompanying materials are made available under the
7  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
8  * and is available at http://www.eclipse.org/legal/epl-v10.html
9  */
10 import org.opendaylight.groupbasedpolicy.resolver.validator.AbstractValidator;
11 import org.opendaylight.groupbasedpolicy.resolver.validator.SimpleResult;
12
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.subject.feature.instances.ActionInstance;
14
15 /**
16  * Validator for {@link ActionInstance}
17  */
18 public class ActionInstanceValidator extends AbstractValidator<ActionInstance> {
19
20     @Override
21     protected SimpleResult validateSelf(ActionInstance objectToValidate) {
22         org.opendaylight.groupbasedpolicy.resolver.ActionInstanceValidator action = getPolicyResolver().getActionInstanceValidator(objectToValidate.getActionDefinitionId());
23         if (action == null) {
24             return new SimpleResult(false, "Action not registered in PolicyResolver.");
25         }
26
27         boolean isValid = action.isValid(objectToValidate);
28
29         return new SimpleResult(isValid, "Validation result of " + action.getClass().getName() + " class.");
30     }
31
32     @Override
33     public Class<ActionInstance> getType() {
34         return ActionInstance.class;
35     }
36
37 }