private Predicate getExportDestinationFilter()

in activemq-kahadb-exporter/src/main/java/org/apache/activemq/cli/kahadb/exporter/KahaDBExporter.java [122:149]


    private Predicate<ActiveMQDestination> getExportDestinationFilter(final ActiveMQDestination destPattern) {
        //We need to check each composite destination individually
        final List<ActiveMQDestination> nonComposite = destPattern.isComposite()
                ? Arrays.asList(destPattern.getCompositeDestinations()) : Arrays.asList(destPattern);

        return (e) -> {
            boolean match = false;
            for (ActiveMQDestination d : nonComposite) {
                String destString = d.getPhysicalName();
                //don't match a.b when using a.b.>
                if (destPattern.isPattern() && destString.length() > 1 && destString.endsWith(DestinationFilter.ANY_DESCENDENT)) {
                    final String startsWithString = destString.substring(0, destString.length() - 2);
                    match = e.getPhysicalName().startsWith(startsWithString) && !e.getPhysicalName().equals(startsWithString);
                //non wildcard should be an exact match
                } else if (!destPattern.isPattern()) {
                    match = e.getPhysicalName().equals(destString);
                } else {
                    match = true;
                }
                if (match) {
                    break;
                }
            }

            return match;
        };

    }