Skip to main content
summaryrefslogtreecommitdiffstats
blob: 08c20d3b1d9684aff1dc84fef12f28e84bb1a236 (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
90
91
92
/*******************************************************************************
 * Copyright (c) 2009 Oracle. 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:
 *     Oracle - initial API and implementation
 *******************************************************************************/
package org.eclipse.jpt.common.core.internal.utility.translators;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.jpt.common.utility.internal.ArrayTools;
import org.eclipse.wst.common.internal.emf.resource.RootTranslator;
import org.eclipse.wst.common.internal.emf.resource.Translator;

/**
 * Root translator that contains a list of child translators and no special
 * behavior.
 */
public class SimpleRootTranslator
	extends RootTranslator
{
	protected Translator[] children;

	public SimpleRootTranslator(String domPathAndNames, EClass eClass) {
		super(domPathAndNames, eClass);
	}

	public SimpleRootTranslator(String domPathAndNames, EClass eClass, Translator[] children) {
		super(domPathAndNames, eClass);
		this.children = children;
	}

	/**
	 * Widen method access to 'public'.
	 */
	@Override
	public Translator[] getChildren() {
		return this.children;
	}

	protected Translator[] getChildren_() {
		return (this.children == null) ? EMPTY_TRANSLATOR_ARRAY : this.children;
	}
	protected static final Translator[] EMPTY_TRANSLATOR_ARRAY = new Translator[0];

	/**
	 * Set the translator's children.
	 * Return the translator.
	 */
	public void setChildren(Translator[] children) {
		this.children = children;
	}

	/**
	 * Add the specified translator to the translator's list of children.
	 * Return the translator for method chaining.
	 */
	public SimpleRootTranslator addChild(Translator translator) {
		this.children = ArrayTools.add(this.getChildren_(), translator);
		return this;
	}

	/**
	 * Add the specified translators to the translator's list of children.
	 * Return the translator for method chaining.
	 */
	public SimpleRootTranslator addChildren(Translator[] translators) {
		this.children = ArrayTools.addAll(this.getChildren_(), translators);
		return this;
	}

	/**
	 * Remove the specified translator from the translator's list of children.
	 * Return the translator for method chaining.
	 */
	public SimpleRootTranslator removeChild(Translator translator) {
		this.children = ArrayTools.remove(this.children, translator);
		return this;
	}

	/**
	 * Remove the specified translators from the translator's list of children.
	 * Return the translator for method chaining.
	 */
	public SimpleRootTranslator removeChildren(Translator[] translators) {
		this.children = ArrayTools.removeAll(this.children, (Object[]) translators);
		return this;
	}

}

Back to the top