public static Collection<Container> getContainersToStop(final ImageConfiguration image,
                                                            final String defaultContainerNamePattern,
                                                            final Date buildTimestamp,
                                                            final Collection<Container> containers) {

        String containerNamePattern = extractContainerNamePattern(image, defaultContainerNamePattern);

        // Only special treatment for indexed container names
        if (!containerNamePattern.contains(INDEX_PLACEHOLDER)) {
            return containers;
        }

        final String partiallyApplied =
            replacePlaceholders(
                containerNamePattern,
                image.getName(),
                image.getAlias(),
                buildTimestamp);

        return keepOnlyLastIndexedContainer(containers, partiallyApplied);

    }
public static Collection < Container > getContainersToStop ( final ImageConfiguration image , final String defaultContainerNamePattern , final Date buildTimestamp , final Collection < Container > containers ) { String containerNamePattern = extractContainerNamePattern ( image , defaultContainerNamePattern ) ; if ( ! containerNamePattern . contains ( INDEX_PLACEHOLDER ) ) { return containers ; } final String partiallyApplied = replacePlaceholders ( containerNamePattern , image . getName ( ) , image . getAlias ( ) , buildTimestamp ) ; return keepOnlyLastIndexedContainer ( containers , partiallyApplied ) ; }
Keep only the entry with the higest index if an indexed naming scheme for container has been chosen.
@param image the image from which to the the container pattern
@param buildTimestamp the timestamp for the build
@param containers the list of existing containers
@return a list with potentially lower indexed entries removed