129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2006, 2008 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.text.templates.TemplateVariableType;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17 import java.util.ArrayList;
|
|
18 import java.util.Arrays;
|
|
19 import java.util.Collections;
|
|
20 import java.util.List;
|
|
21
|
|
22 import dwtx.core.runtime.Assert;
|
|
23
|
|
24
|
|
25 /**
|
|
26 * Value object that represents the type of a template variable. A type is defined by its name and
|
|
27 * may have parameters.
|
|
28 *
|
|
29 * @since 3.3
|
|
30 * @noinstantiate This class is not intended to be instantiated by clients.
|
|
31 */
|
|
32 public final class TemplateVariableType {
|
|
33
|
|
34 /** The name of the type. */
|
|
35 private final String fName;
|
|
36 /** The parameter list. */
|
|
37 private final List fParams;
|
|
38
|
|
39 TemplateVariableType(String name) {
|
|
40 this(name, new String[0]);
|
|
41 }
|
|
42
|
|
43 TemplateVariableType(String name, String[] params) {
|
|
44 Assert.isLegal(name !is null);
|
|
45 Assert.isLegal(params !is null);
|
|
46 fName= name;
|
|
47 fParams= Collections.unmodifiableList(new ArrayList(Arrays.asList(params)));
|
|
48 }
|
|
49
|
|
50 /**
|
|
51 * Returns the type name of this variable type.
|
|
52 *
|
|
53 * @return the type name of this variable type
|
|
54 */
|
|
55 public String getName() {
|
|
56 return fName;
|
|
57 }
|
|
58
|
|
59 /**
|
|
60 * Returns the unmodifiable and possibly empty list of parameters (element type: {@link String})
|
|
61 *
|
|
62 * @return the list of parameters
|
|
63 */
|
|
64 public List getParams() {
|
|
65 return fParams;
|
|
66 }
|
|
67
|
|
68 /*
|
|
69 * @see java.lang.Object#equals(java.lang.Object)
|
|
70 */
|
|
71 public bool equals(Object obj) {
|
|
72 if (obj instanceof TemplateVariableType) {
|
|
73 TemplateVariableType other= (TemplateVariableType) obj;
|
|
74 return other.fName.equals(fName) && other.fParams.equals(fParams);
|
|
75 }
|
|
76 return false;
|
|
77 }
|
|
78
|
|
79 /*
|
|
80 * @see java.lang.Object#hashCode()
|
|
81 */
|
|
82 public int hashCode() {
|
|
83 return fName.hashCode() + fParams.hashCode();
|
|
84 }
|
|
85
|
|
86 /*
|
|
87 * @see java.lang.Object#toString()
|
|
88 * @since 3.3
|
|
89 */
|
|
90 public String toString() {
|
|
91 return fName + fParams.toString();
|
|
92 }
|
|
93 }
|