2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.parser.spi;
10 import io.netty.buffer.ByteBuf;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
14 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
18 * Common interface for attribute parser implementation.
20 public interface AttributeParser {
22 * Parses attribute from ByteBuf buffer.
24 * @param buffer Encoded attribute body in ByteBuf.
25 * @param builder Path attributes builder. Guaranteed to contain all valid attributes whose type is numerically
26 * lower than this attribute's type.
28 void parseAttribute(@Nonnull ByteBuf buffer, @Nonnull AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException;
31 * Invokes {@link #parseAttribute(ByteBuf, AttributesBuilder)}, so the constraint is omitted. Override for specific parser behavior.
33 * @param buffer Encoded attribute body in ByteBuf.
34 * @param builder Path attributes builder. Guaranteed to contain all valid attributes whose type is numerically
35 * lower than this attribute's type.
36 * @param constraint Peer specific constraints.
37 * @throws BGPDocumentedException
38 * @throws BGPParsingException
40 default void parseAttribute(@Nonnull final ByteBuf buffer, @Nonnull final AttributesBuilder builder, @Nullable final PeerSpecificParserConstraint constraint)
41 throws BGPDocumentedException, BGPParsingException {
42 parseAttribute(buffer, builder);