Richard Uhler | cda4f2e | 2016-09-09 09:56:20 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.ahat.heapdump; |
| 18 | |
Richard Uhler | f629cfd | 2016-12-12 13:11:26 +0000 | [diff] [blame] | 19 | public class FieldValue implements Diffable<FieldValue> { |
Richard Uhler | cda4f2e | 2016-09-09 09:56:20 +0100 | [diff] [blame] | 20 | private final String mName; |
| 21 | private final String mType; |
| 22 | private final Value mValue; |
Richard Uhler | f629cfd | 2016-12-12 13:11:26 +0000 | [diff] [blame] | 23 | private FieldValue mBaseline; |
| 24 | private final boolean mIsPlaceHolder; |
Richard Uhler | cda4f2e | 2016-09-09 09:56:20 +0100 | [diff] [blame] | 25 | |
| 26 | public FieldValue(String name, String type, Value value) { |
| 27 | mName = name; |
| 28 | mType = type; |
| 29 | mValue = value; |
Richard Uhler | f629cfd | 2016-12-12 13:11:26 +0000 | [diff] [blame] | 30 | 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 Uhler | cda4f2e | 2016-09-09 09:56:20 +0100 | [diff] [blame] | 49 | } |
| 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 Uhler | f629cfd | 2016-12-12 13:11:26 +0000 | [diff] [blame] | 71 | |
| 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 Uhler | cda4f2e | 2016-09-09 09:56:20 +0100 | [diff] [blame] | 83 | } |