Allow AttributeRegistry to signal treat-as-withdraw
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / ParsedAttributes.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.bgp.parser.spi;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.util.Optional;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.protocol.bgp.parser.BGPTreatAsWithdrawException;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
17
18 /**
19  * Parsed {@link Attributes}, potentially indicating withdraw.
20  *
21  * @author Robert Varga
22  */
23 public final class ParsedAttributes {
24     private final @NonNull Attributes attributes;
25     private final @Nullable BGPTreatAsWithdrawException withdrawCause;
26
27     public ParsedAttributes(final @NonNull Attributes attributes,
28             final @Nullable BGPTreatAsWithdrawException withdrawCause) {
29         this.attributes = requireNonNull(attributes);
30         this.withdrawCause = withdrawCause;
31     }
32
33     public @NonNull Attributes getAttributes() {
34         return attributes;
35     }
36
37     public @NonNull Optional<BGPTreatAsWithdrawException> getWithdrawCause() {
38         return Optional.ofNullable(withdrawCause);
39     }
40 }