Package omero.util

Class PrefixSubstituter<X extends java.lang.Comparable<X>>

  • Type Parameters:
    X - the type of sequences that have prefixes needing substituting

    public class PrefixSubstituter<X extends java.lang.Comparable<X>>
    extends java.lang.Object
    Efficiently applies prefix transformations from a set thereof.
    • Constructor Summary

      Constructors 
      Constructor Description
      PrefixSubstituter​(java.util.function.BiPredicate<X,​X> isPrefixOf, java.util.function.BiFunction<X,​X,​X> addPrefix, java.util.function.BiFunction<X,​X,​X> delPrefix)
      Construct a new prefix substituter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      X apply​(X item)
      Apply a prefix substitution if any applies.
      void put​(X from, X to)
      Add a prefix substitution to the applicable set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PrefixSubstituter

        public PrefixSubstituter​(java.util.function.BiPredicate<X,​X> isPrefixOf,
                                 java.util.function.BiFunction<X,​X,​X> addPrefix,
                                 java.util.function.BiFunction<X,​X,​X> delPrefix)
        Construct a new prefix substituter.
        Parameters:
        isPrefixOf - test if the first argument prefixes the second
        addPrefix - prefix the first argument to the second
        delPrefix - remove the first argument from the start of the second
    • Method Detail

      • put

        public void put​(X from,
                        X to)
        Add a prefix substitution to the applicable set.
        Parameters:
        from - the prefix to match
        to - the replacement prefix
      • apply

        public X apply​(X item)
        Apply a prefix substitution if any applies.
        Parameters:
        item - the sequence whose prefix may need substituting, not null
        Returns:
        the given sequence, has prefix substituted if any applied