Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f43a81dcf797e814b58112f92b266fd4f9f4ba3f (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2009,2016 QNX Software Systems
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    QNX Software Systems (Alena Laskavaia)  - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.internal.core.model;

import org.eclipse.cdt.codan.core.model.IProblemCategory;
import org.eclipse.cdt.codan.core.model.IProblemElement;
import org.eclipse.cdt.codan.core.model.IProblemProfile;

/**
 * base class for category and problem
 */
public class CodanProblemElement implements IProblemElement {
	private IProblemProfile profile;
	private IProblemCategory parent;
	private boolean frozen = false;

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.cdt.codan.core.model.IProblemElement#getProfile()
	 */
	@Override
	public IProblemProfile getProfile() {
		return profile;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.cdt.codan.core.model.IProblemElement#getCategory()
	 */
	@Override
	public IProblemCategory getParentCategory() {
		return parent;
	}

	/**
	 * @param profile - parent profile
	 */
	public void setProfile(IProblemProfile profile) {
		checkSet();
		this.profile = profile;
	}

	/**
	 * @param parent - parent category
	 */
	public void setParentCategory(IProblemCategory parent) {
		checkSet();
		this.parent = parent;
	}

	@Override
	public Object clone() {
		try {
			CodanProblemElement prob = (CodanProblemElement) super.clone();
			return prob;
		} catch (CloneNotSupportedException e) {
			return this;
		}
	}

	protected void checkSet() {
		if (frozen)
			throw new IllegalStateException("Object is unmodifieble"); //$NON-NLS-1$
	}

	/**
	 * @param b
	 */
	protected void setFrozen(boolean b) {
		this.frozen = b;
	}

	/**
	 * @return
	 */
	protected boolean isFrozen() {
		return frozen;
	}
}

Back to the top