/*
* 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;
import java.util.List;

import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
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 {

	private final Errors error;

	private final PCEPErrors e;

	public UnknownObject(final PCEPErrors 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();
	}

	public List<Errors> getErrors() {
		return Arrays.asList(this.error);
	}

	public PCEPErrors getError() {
		return this.e;
	}

	@Override
	public Class<? extends DataContainer> getImplementedInterface() {
		return Object.class;
	}

	@Override
	public Boolean isIgnore() {
		return false;
	}

	@Override
	public Boolean isProcessingRule() {
		return false;
	}
}
/*
 * 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;
import java.util.List;

import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
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;

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.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() {
		return Arrays.asList(this.error);
	}

	public PCEPErrors getError() {
		return this.e;
	}

	public Object getInvalidObject() {
		return this.invalidObject;
	}

	@Override
	public Class<? extends DataContainer> getImplementedInterface() {
		return Object.class;
	}

	@Override
	public Boolean isIgnore() {
		return false;
	}

	@Override
	public Boolean isProcessingRule() {
		return false;
	}
}
Add invalid object parameter for use with semantic checks