Add invalid object parameter for use with semantic checks 94/2994/1
authorRobert Varga <rovarga@cisco.com>
Fri, 22 Nov 2013 10:30:21 +0000 (11:30 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 22 Nov 2013 10:45:08 +0000 (11:45 +0100)
Change-Id: I272a68d211b8986f2cdb9fb8b141785734e40669
Signed-off-by: Robert Varga <rovarga@cisco.com>
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/UnknownObject.java

index 01949612c06ab959d0b97f66ec7de42f9d622708..ddf1f26d7d65a84b8c56e44897f73f6d7e751657 100644 (file)
@@ -1,10 +1,10 @@
 /*
-* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
-*
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0 which accompanies this distribution,
-* and is available at http://www.eclipse.org/legal/epl-v10.html
-*/
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.protocol.pcep.spi;
 
 import java.util.Arrays;
@@ -16,17 +16,28 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
-public class UnknownObject implements Object {
+import com.google.common.base.Preconditions;
 
+/**
+ * Placeholder object. This object should be injected by in positions where an
+ * object is either completely unknown or has failed semantic validation.
+ */
+public final class UnknownObject implements Object {
+       private final Object invalidObject;
        private final Errors error;
-
        private final PCEPErrors e;
 
        public UnknownObject(final PCEPErrors error) {
+               this(error, null);
+       }
+
+       public UnknownObject(final PCEPErrors error, final Object invalidObject) {
+               this.e = Preconditions.checkNotNull(error);
+
                final PCEPErrorMapping mapping = PCEPErrorMapping.getInstance();
-               this.e = error;
                this.error = new ErrorsBuilder().setErrorObject(
                                new ErrorObjectBuilder().setType(mapping.getFromErrorsEnum(error).type).setValue(mapping.getFromErrorsEnum(error).value).build()).build();
+               this.invalidObject = invalidObject;
        }
 
        public List<Errors> getErrors() {
@@ -37,6 +48,10 @@ public class UnknownObject implements Object {
                return this.e;
        }
 
+       public Object getInvalidObject() {
+               return this.invalidObject;
+       }
+
        @Override
        public Class<? extends DataContainer> getImplementedInterface() {
                return Object.class;