Search in sources :

Example 6 with UnrecognizedAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributes in project bgpcep by opendaylight.

the class NonTransitiveAttributesFilterHandler method filterAttributes.

private static Attributes filterAttributes(final Attributes attributes) {
    final AttributesBuilder builder = new AttributesBuilder().setCNextHop(attributes.getCNextHop()).setOrigin(attributes.getOrigin()).setAsPath(attributes.getAsPath()).setCommunities(attributes.getCommunities());
    final Map<UnrecognizedAttributesKey, UnrecognizedAttributes> oldAtt = attributes.getUnrecognizedAttributes();
    if (oldAtt != null) {
        // TODO: consider using Maps.filterValues(attributes.getUnrecognizedAttributes(),
        // UnrecognizedAttributes::isTransitive)) ?
        builder.setUnrecognizedAttributes(attributes.getUnrecognizedAttributes().values().stream().filter(UnrecognizedAttributes::getTransitive).collect(ImmutableMap.toImmutableMap(UnrecognizedAttributes::key, Function.identity())));
    }
    final List<ExtendedCommunities> oldExt = attributes.getExtendedCommunities();
    if (oldExt != null) {
        builder.setExtendedCommunities(oldExt.stream().filter(ExtendedCommunity::getTransitive).collect(Collectors.toList()));
    }
    return builder.build();
}
Also used : UnrecognizedAttributesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributesKey) ExtendedCommunities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities) ExtendedCommunity(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ExtendedCommunity) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributes)

Aggregations

UnrecognizedAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributes)5 UnrecognizedAttributesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributesKey)4 Test (org.junit.Test)2 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)2 UnrecognizedAttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.UnrecognizedAttributesBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)1 UnrecognizedAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)1 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities)1 ExtendedCommunity (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ExtendedCommunity)1 Uint8 (org.opendaylight.yangtools.yang.common.Uint8)1