~ubuntu-branches/ubuntu/oneiric/libspin-java/oneiric

« back to all changes in this revision

Viewing changes to src/spin/demo/Assert.java

  • Committer: Bazaar Package Importer
  • Author(s): gregor herrmann
  • Date: 2007-01-15 16:29:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070115162948-olisrjfshcvqa7qu
Tags: upstream-1.4
ImportĀ upstreamĀ versionĀ 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Spin - transparent threading solution for non-freezing Swing applications.
 
3
 * Copyright (C) 2002 Sven Meier
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 */
 
19
package spin.demo;
 
20
 
 
21
import javax.swing.SwingUtilities;
 
22
 
 
23
/**
 
24
 * Utility class to assert correct thread handling.
 
25
 */
 
26
public class Assert {
 
27
 
 
28
  /**
 
29
   * No instance.
 
30
   */
 
31
  private Assert() {}
 
32
 
 
33
  /**
 
34
   * Must be executed on the EDT.
 
35
   */  
 
36
  public static void isEDT() {
 
37
    if (!SwingUtilities.isEventDispatchThread()) {
 
38
      throw new Error("assertion failed: not on EDT");
 
39
    }
 
40
  }
 
41
  
 
42
  /**
 
43
   * Must not be executed on the EDT.
 
44
   */  
 
45
  public static void isNotEDT() {
 
46
    if (SwingUtilities.isEventDispatchThread()) {
 
47
      throw new Error("assertion failed: on EDT");
 
48
    }
 
49
  }
 
50
}