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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.types
;
15 import java
.util
.List
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
19 import org
.eclipse
.jdt
.annotation
.Nullable
;
20 import org
.eclipse
.linuxtools
.ctf
.core
.event
.scope
.IDefinitionScope
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.AbstractArrayDefinition
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.CompoundDeclaration
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
25 import com
.google
.common
.base
.Joiner
;
26 import com
.google
.common
.collect
.ImmutableList
;
29 * A CTF array definition
31 * Arrays are fixed-length. Their length is declared in the type declaration
32 * within the meta-data. They contain an array of "inner type" elements, which
33 * can refer to any type not containing the type of the array being declared (no
34 * circular dependency). The length is the number of elements in an array.
37 * @author Matthew Khouzam
41 public final class ArrayDefinition
extends AbstractArrayDefinition
{
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
47 private final ImmutableList
<Definition
> fDefinitions
;
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
57 * the parent declaration
58 * @param definitionScope
63 * the content of the array
65 public ArrayDefinition(CompoundDeclaration declaration
,
66 @Nullable IDefinitionScope definitionScope
,
68 List
<Definition
> definitions
) {
69 super(declaration
, definitionScope
, fieldName
);
70 @SuppressWarnings("null")
71 @NonNull ImmutableList
<Definition
> list
= ImmutableList
.copyOf(definitions
);
75 // ------------------------------------------------------------------------
76 // Getters/Setters/Predicates
77 // ------------------------------------------------------------------------
80 public List
<Definition
> getDefinitions() {
85 * Get the the number of elements in the array
87 * @return how many elements in the array
89 public int getLength() {
90 return fDefinitions
.size();
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
98 public String
toString() {
99 StringBuilder b
= new StringBuilder();
101 Joiner joiner
= Joiner
.on(", ").skipNulls(); //$NON-NLS-1$
102 b
.append(joiner
.join(fDefinitions
));
104 @SuppressWarnings("null")
105 @NonNull String ret
= b
.toString();