KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > templates > TemplateVariableType


1 /*******************************************************************************
2  * Copyright (c) 2006 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  *******************************************************************************/

11 package org.eclipse.jface.text.templates;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Arrays JavaDoc;
15 import java.util.Collections JavaDoc;
16 import java.util.List JavaDoc;
17
18 import org.eclipse.core.runtime.Assert;
19
20 /**
21  * Value object that represents the type of a template variable. A type is defined by its name and
22  * may have parameters.
23  *
24  * @since 3.3
25  */

26 public final class TemplateVariableType {
27
28     /** The name of the type. */
29     private final String JavaDoc fName;
30     /** The parameter list. */
31     private final List JavaDoc fParams;
32
33     TemplateVariableType(String JavaDoc name) {
34         this(name, new String JavaDoc[0]);
35     }
36
37     TemplateVariableType(String JavaDoc name, String JavaDoc[] params) {
38         Assert.isLegal(name != null);
39         Assert.isLegal(params != null);
40         fName= name;
41         fParams= Collections.unmodifiableList(new ArrayList JavaDoc(Arrays.asList(params)));
42     }
43
44     /**
45      * Returns the type name of this variable type.
46      *
47      * @return the type name of this variable type
48      */

49     public String JavaDoc getName() {
50         return fName;
51     }
52
53     /**
54      * Returns the unmodifiable and possibly empty list of parameters (element type: {@link String})
55      *
56      * @return the list of parameters
57      */

58     public List JavaDoc getParams() {
59         return fParams;
60     }
61
62     /*
63      * @see java.lang.Object#equals(java.lang.Object)
64      */

65     public boolean equals(Object JavaDoc obj) {
66         if (obj instanceof TemplateVariableType) {
67             TemplateVariableType other= (TemplateVariableType) obj;
68             return other.fName.equals(fName) && other.fParams.equals(fParams);
69         }
70         return false;
71     }
72
73     /*
74      * @see java.lang.Object#hashCode()
75      */

76     public int hashCode() {
77         return fName.hashCode() + fParams.hashCode();
78     }
79
80     /*
81      * @see java.lang.Object#toString()
82      * @since 3.3
83      */

84     public String JavaDoc toString() {
85         return fName + fParams.toString();
86     }
87 }
88
Popular Tags