File: MyClass5c.java

package info (click to toggle)
libjibx-java 1.0.1-2
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 15,748 kB
  • ctags: 10,069
  • sloc: java: 29,151; xml: 7,963; makefile: 14
file content (44 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

package simple;

import java.util.ArrayList;

class MyClass5c extends MyClass5a
{
	/*package*/ boolean factory;
	private boolean preset;
	private boolean postset;
	private int value;
	
	private void preset(Object obj) {
		if (!(obj instanceof ArrayList)) {
			throw new IllegalStateException("factory called with wrong object");
		}
		preset = true;
		value = 1;
	}
	
	private void postset(Object obj) {
		if (!(obj instanceof ArrayList)) {
			throw new IllegalStateException("factory called with wrong object");
		}
		postset = true;
		if (value == 2) {
			value = 3;
		}
	}
	
	private void preget(Object obj) {
		if (!(obj instanceof ArrayList)) {
			throw new IllegalStateException("factory called with wrong object");
		}
		value = 2;
	}
	
	protected void verify() {
		if (!factory || !preset || !postset) {
			throw new IllegalStateException
				("factory, pre-set, or post-set method not called");
		}
	}
}