blob: 4329f14dc594a21a10105e388326391c9be604f2 [file] [log] [blame]
Simon Hunt3ee7f742015-05-05 10:18:20 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Hunt3ee7f742015-05-05 10:18:20 -07003 *
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.
Simon Hunt3ee7f742015-05-05 10:18:20 -070015 */
16
17package org.onosproject.ui.table.cell;
18
19import org.onosproject.ui.table.CellFormatter;
20
21/**
22 * Base implementation of a {@link CellFormatter}. This class takes care of
23 * dealing with null inputs; subclasses should implement their format method
24 * knowing that the input is guaranteed to be non-null.
25 */
26public abstract class AbstractCellFormatter implements CellFormatter {
27
28 @Override
29 public String format(Object value) {
30 return value == null ? "" : nonNullFormat(value);
31 }
32
33 /**
34 * Formats the specified value into a string appropriate for displaying
35 * in a table cell. Note that value is guaranteed to be non-null.
36 *
37 * @param value the value
38 * @return the formatted string
39 */
40 protected abstract String nonNullFormat(Object value);
41}