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