Fix some null warnings
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / internal / tmf / core / statesystem / mipmap / MinMipmapFeature.java
CommitLineData
8e364f8e 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 Ericsson
8e364f8e
PT
3 *
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
8 *
9 * Contributors:
10 * Jean-Christian Kouamé - Initial API and implementation
11 * Patrick Tasse - Updates to mipmap feature
12 *******************************************************************************/
2bdf0193 13package org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;
8e364f8e 14
aa353506
AM
15import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
16
8e364f8e
PT
17import java.util.List;
18
e894a508
AM
19import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
20import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
21import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
22import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
23import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue.Type;
8e364f8e
PT
24
25/**
26 * The minimum mipmap feature.
27 *
28 * Each mipmap state value is the minimum numerical value of all the non-null
29 * lower-level state values it covers. The state value is of the same type as
30 * the base attribute.
31 */
32public class MinMipmapFeature extends TmfMipmapFeature {
33
34 /**
35 * Constructor
36 *
37 * @param baseQuark
38 * The quark for the attribute we want to mipmap
39 * @param mipmapQuark
40 * The quark of the mipmap feature attribute
41 * @param mipmapResolution
42 * The resolution that will be use in the mipmap
43 * @param ss
44 * The state system in which to insert the state changes
45 */
46 public MinMipmapFeature(final int baseQuark, final int mipmapQuark, final int mipmapResolution, final ITmfStateSystemBuilder ss) {
47 super(baseQuark, mipmapQuark, mipmapResolution, ss);
48 }
49
50 @Override
51 protected ITmfStateValue computeMipmapValue(List<ITmfStateInterval> lowerIntervals, long startTime, long endTime) {
52 ITmfStateValue minValue = null;
53 try {
54 for (ITmfStateInterval interval : lowerIntervals) {
55 ITmfStateValue value = interval.getStateValue();
56 if (value.getType() == Type.DOUBLE) {
57 if (minValue == null || value.unboxDouble() < minValue.unboxDouble()) {
58 minValue = value;
59 }
60 } else {
61 if (minValue == null || value.unboxLong() < minValue.unboxLong()) {
62 minValue = value;
63 }
64 }
65 }
66 } catch (StateValueTypeException e) {
67 e.printStackTrace();
68 }
aa353506 69 return checkNotNull(minValue);
8e364f8e
PT
70 }
71}
This page took 0.11641 seconds and 5 git commands to generate.