Module qtjambi
Package io.qt.core

Class QScope

java.lang.Object
io.qt.core.QScope
All Implemented Interfaces:
AutoCloseable

public final class QScope extends Object implements AutoCloseable
QScope is an object life-time manager to be used in a try-with-resource block. All object created with this scope are cleaned up (disposed) at the end of the scope.

Example:

try(QScope scope = new QScope()){
    QDialog dialog = scope.create(QDialog::new);
    dialog.exec();
}
// dialog is disposed
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Factory for argument-less constructors
    static interface 
    Factory for one argument taking constructors
    static interface 
    Factory for two arguments taking constructors
    static interface 
    Factory for 3 arguments taking constructors
    static interface 
    Factory for 4 arguments taking constructors
    static interface 
    Factory for 5 arguments taking constructors
    static interface 
    Factory for 6 arguments taking constructors
    static interface 
    Factory for 7 arguments taking constructors
    static interface 
    Factory for 8 arguments taking constructors
    static interface 
    Factory for 9 arguments taking constructors
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    capture(Runnable action)
    Let given action be performed at the end of the scope.
    <T> T
    capture(Consumer<T> cleanup, T object)
    The given object is managed by the scope, i.e.
    <T extends QtObjectInterface>
    T
    capture(T object)
    The given object is managed by the scope, i.e.
    boolean
    cleanup(Object object)
    Forces the object's cleanup.
    void
    Performs a cleanup on all
    <O extends QtObjectInterface>
    O
    create(QScope.Factory<O> factory)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A>
    O
    create(QScope.Factory1<A,O> factory, A arg0)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B>
    O
    create(QScope.Factory2<A,B,O> factory, A arg0, B arg1)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C>
    O
    create(QScope.Factory3<A,B,C,O> factory, A arg0, B arg1, C arg2)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C, D>
    O
    create(QScope.Factory4<A,B,C,D,O> factory, A arg0, B arg1, C arg2, D arg3)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C, D, E>
    O
    create(QScope.Factory5<A,B,C,D,E,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C, D, E, F>
    O
    create(QScope.Factory6<A,B,C,D,E,F,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C, D, E, F, G>
    O
    create(QScope.Factory7<A,B,C,D,E,F,G,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C, D, E, F, G, H>
    O
    create(QScope.Factory8<A,B,C,D,E,F,G,H,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7)
    Creates a new object being managed by this scope.
    <O extends QtObjectInterface, A, B, C, D, E, F, G, H, I>
    O
    create(QScope.Factory9<A,B,C,D,E,F,G,H,I,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8)
    Creates a new object being managed by this scope.
    <O> O
    create(Consumer<O> cleanup, QScope.Factory<O> factory)
    Creates a new object being managed by this scope with cleanup function.
    <O, A> O
    create(Consumer<O> cleanup, QScope.Factory1<A,O> factory, A arg0)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B> O
    create(Consumer<O> cleanup, QScope.Factory2<A,B,O> factory, A arg0, B arg1)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C>
    O
    create(Consumer<O> cleanup, QScope.Factory3<A,B,C,O> factory, A arg0, B arg1, C arg2)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C, D>
    O
    create(Consumer<O> cleanup, QScope.Factory4<A,B,C,D,O> factory, A arg0, B arg1, C arg2, D arg3)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C, D, E>
    O
    create(Consumer<O> cleanup, QScope.Factory5<A,B,C,D,E,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C, D, E, F>
    O
    create(Consumer<O> cleanup, QScope.Factory6<A,B,C,D,E,F,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C, D, E, F, G>
    O
    create(Consumer<O> cleanup, QScope.Factory7<A,B,C,D,E,F,G,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C, D, E, F, G, H>
    O
    create(Consumer<O> cleanup, QScope.Factory8<A,B,C,D,E,F,G,H,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7)
    Creates a new object being managed by this scope with cleanup function.
    <O, A, B, C, D, E, F, G, H, I>
    O
    create(Consumer<O> cleanup, QScope.Factory9<A,B,C,D,E,F,G,H,I,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8)
    Creates a new object being managed by this scope with cleanup function.
    boolean
    release(Object object)
    Removes the given object from this scope.

    Methods inherited from class java.lang.Object

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

    • QScope

      public QScope()
      Default constructor
  • Method Details

    • close

      @QtUninvokable public void close()
      Performs a cleanup on all
      Specified by:
      close in interface AutoCloseable
    • release

      @QtUninvokable public boolean release(Object object)
      Removes the given object from this scope.
      Parameters:
      object -
      Returns:
      success
    • cleanup

      @QtUninvokable public boolean cleanup(Object object)
      Forces the object's cleanup.
      Parameters:
      object -
      Returns:
      success
    • capture

      @QtUninvokable public Runnable capture(Runnable action)
      Let given action be performed at the end of the scope.
      Parameters:
      action -
    • capture

      @QtUninvokable public <T extends QtObjectInterface> T capture(T object)
      The given object is managed by the scope, i.e. disposed at its closing.
      Parameters:
      object -
      Returns:
      object
    • capture

      @QtUninvokable public <T> T capture(Consumer<T> cleanup, T object)
      The given object is managed by the scope, i.e. cleaned up at its closing.
      Parameters:
      cleanup -
      object -
      Returns:
      object
    • create

      public <O extends QtObjectInterface> O create(QScope.Factory<O> factory)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A> O create(QScope.Factory1<A,O> factory, A arg0)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B> O create(QScope.Factory2<A,B,O> factory, A arg0, B arg1)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C> O create(QScope.Factory3<A,B,C,O> factory, A arg0, B arg1, C arg2)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C, D> O create(QScope.Factory4<A,B,C,D,O> factory, A arg0, B arg1, C arg2, D arg3)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C, D, E> O create(QScope.Factory5<A,B,C,D,E,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C, D, E, F> O create(QScope.Factory6<A,B,C,D,E,F,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C, D, E, F, G> O create(QScope.Factory7<A,B,C,D,E,F,G,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C, D, E, F, G, H> O create(QScope.Factory8<A,B,C,D,E,F,G,H,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O extends QtObjectInterface, A, B, C, D, E, F, G, H, I> O create(QScope.Factory9<A,B,C,D,E,F,G,H,I,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8)
      Creates a new object being managed by this scope.
      Parameters:
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O> O create(Consumer<O> cleanup, QScope.Factory<O> factory)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A> O create(Consumer<O> cleanup, QScope.Factory1<A,O> factory, A arg0)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B> O create(Consumer<O> cleanup, QScope.Factory2<A,B,O> factory, A arg0, B arg1)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C> O create(Consumer<O> cleanup, QScope.Factory3<A,B,C,O> factory, A arg0, B arg1, C arg2)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C, D> O create(Consumer<O> cleanup, QScope.Factory4<A,B,C,D,O> factory, A arg0, B arg1, C arg2, D arg3)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C, D, E> O create(Consumer<O> cleanup, QScope.Factory5<A,B,C,D,E,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C, D, E, F> O create(Consumer<O> cleanup, QScope.Factory6<A,B,C,D,E,F,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C, D, E, F, G> O create(Consumer<O> cleanup, QScope.Factory7<A,B,C,D,E,F,G,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C, D, E, F, G, H> O create(Consumer<O> cleanup, QScope.Factory8<A,B,C,D,E,F,G,H,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object
    • create

      public <O, A, B, C, D, E, F, G, H, I> O create(Consumer<O> cleanup, QScope.Factory9<A,B,C,D,E,F,G,H,I,O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8)
      Creates a new object being managed by this scope with cleanup function.
      Parameters:
      cleanup - the destroyer function
      factory - constructor
      Returns:
      new scoped object