Class OyFallbackSwap

  • All Implemented Interfaces:
    Objectionary

    public final class OyFallbackSwap
    extends Object
    implements Objectionary
    Fallback which can swap primary/secondary repos.

    The key purpose of this class is to allow dynamic determination of which Oy (fist or second) to use as primary and which as fallback based on given boolean property.

    For PullMojo this is used to bypass reading from cache by always checking remote first and only fallback to local in case of object miss:

         new PullMojo.FallbackSwapOy(
             < local >,
             < remote >,
             this.forceUpdate()
         );
     
    Since:
    1.0
    • Constructor Detail

      • OyFallbackSwap

        public OyFallbackSwap​(Objectionary first,
                              Objectionary second,
                              boolean swap)
        Ctor.
        Parameters:
        first - Initial primary
        second - Initial secondary
        swap - Whether to swap
      • OyFallbackSwap

        public OyFallbackSwap​(Objectionary first,
                              Objectionary second,
                              org.cactoos.Scalar<Boolean> swap)
        Ctor.
        Parameters:
        first - Initial primary
        second - Initial secondary
        swap - Whether to swap
    • Method Detail

      • get

        public org.cactoos.Input get​(String name)
                              throws IOException
        Description copied from interface: Objectionary
        Resolve object.
        Specified by:
        get in interface Objectionary
        Parameters:
        name - Object name.
        Returns:
        Object code.
        Throws:
        IOException - If fails to fetch.
      • contains

        public boolean contains​(String name)
                         throws IOException
        Description copied from interface: Objectionary
        Checks whether an Objectionary contains a provided object.
        Specified by:
        contains in interface Objectionary
        Parameters:
        name - Object name.
        Returns:
        Boolean: "true" if found, "false" if not.
        Throws:
        IOException - If fails to fetch.