1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.ctf
.core
.event
.scope
;
15 import java
.util
.concurrent
.ConcurrentHashMap
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.jdt
.annotation
.Nullable
;
21 * A node of a lexical scope
23 * @author Matthew Khouzam
25 public class LexicalScope
implements ILexicalScope
{
27 private final @NonNull String fName
;
28 private final @NonNull String fPath
;
29 private final Map
<String
, ILexicalScope
> fChildren
= new ConcurrentHashMap
<>();
32 * Hidden constructor for the root node only
36 protected LexicalScope() {
37 fPath
= ""; //$NON-NLS-1$
38 fName
= ""; //$NON-NLS-1$
42 * The scope constructor
45 * The parent node, can be null, but shouldn't
47 * the name of the field
50 public LexicalScope(ILexicalScope parent
, @NonNull String name
) {
52 fPath
= parent
.getPath().isEmpty() ? fName
: parent
.getPath() + '.' + fName
;
53 parent
.addChild(name
, this);
60 public void addChild(String name
, ILexicalScope child
) {
61 fChildren
.put(name
, child
);
65 public @NonNull String
getName() {
73 public @Nullable ILexicalScope
getChild(String name
) {
74 return fChildren
.get(name
);
81 public @NonNull String
getPath() {
85 // for debugging purposes
87 public String
toString() {
92 public synchronized int hashCode() {
95 hash
= prime
* (prime
+ fName
.hashCode()) + fPath
.hashCode();
101 public boolean equals(@Nullable Object obj
) {
108 if (getClass() != obj
.getClass()) {
111 LexicalScope other
= (LexicalScope
) obj
;
112 if (!fName
.equals(other
.fName
)) {
115 return fPath
.equals(other
.fPath
);
This page took 0.047903 seconds and 5 git commands to generate.