blob: 3f65cd30304483c6fc2ab8d311a41fdf50016b45 [file] [log] [blame]
Richard Uhlercda4f2e2016-09-09 09:56:20 +01001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.ahat.heapdump;
18
Richard Uhlerf629cfd2016-12-12 13:11:26 +000019public class FieldValue implements Diffable<FieldValue> {
Richard Uhlercda4f2e2016-09-09 09:56:20 +010020 private final String mName;
21 private final String mType;
22 private final Value mValue;
Richard Uhlerf629cfd2016-12-12 13:11:26 +000023 private FieldValue mBaseline;
24 private final boolean mIsPlaceHolder;
Richard Uhlercda4f2e2016-09-09 09:56:20 +010025
26 public FieldValue(String name, String type, Value value) {
27 mName = name;
28 mType = type;
29 mValue = value;
Richard Uhlerf629cfd2016-12-12 13:11:26 +000030 mBaseline = this;
31 mIsPlaceHolder = false;
32 }
33
34 /**
35 * Construct a place holder FieldValue
36 */
37 private FieldValue(FieldValue baseline) {
38 mName = baseline.mName;
39 mType = baseline.mType;
40 mValue = Value.getBaseline(baseline.mValue);
41 mBaseline = baseline;
42 mIsPlaceHolder = true;
43 }
44
45 static FieldValue newPlaceHolderFieldValue(FieldValue baseline) {
46 FieldValue field = new FieldValue(baseline);
47 baseline.setBaseline(field);
48 return field;
Richard Uhlercda4f2e2016-09-09 09:56:20 +010049 }
50
51 /**
52 * Returns the name of the field.
53 */
54 public String getName() {
55 return mName;
56 }
57
58 /**
59 * Returns a description of the type of the field.
60 */
61 public String getType() {
62 return mType;
63 }
64
65 /**
66 * Returns the value of this field.
67 */
68 public Value getValue() {
69 return mValue;
70 }
Richard Uhlerf629cfd2016-12-12 13:11:26 +000071
72 public void setBaseline(FieldValue baseline) {
73 mBaseline = baseline;
74 }
75
76 @Override public FieldValue getBaseline() {
77 return mBaseline;
78 }
79
80 @Override public boolean isPlaceHolder() {
81 return mIsPlaceHolder;
82 }
Richard Uhlercda4f2e2016-09-09 09:56:20 +010083}