Package net.sf.basedb.util.json
Class NameableConverter<T extends Nameable>
- java.lang.Object
-
- net.sf.basedb.util.json.NameableConverter<T>
-
- All Implemented Interfaces:
JsonConverter<T>
public class NameableConverter<T extends Nameable> extends Object implements JsonConverter<T>
Simple "converter" implementation that create JSON objects with the name and id ofNameable
items. Subclasses may implement thesetMore(JSONObject, Nameable)
method to add more properties to the JSON object.- Since:
- 3.3
- Author:
- nicklas
-
-
Constructor Summary
Constructors Constructor Description NameableConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
convert(T object)
Convert the given object to a JSON-compatible object.protected void
setMore(org.json.simple.JSONObject json, T object)
Can be used by subclasses to set more properties on the JSON object.
-
-
-
Method Detail
-
convert
public Object convert(T object)
Description copied from interface:JsonConverter
Convert the given object to a JSON-compatible object. The parameter may be null.- Specified by:
convert
in interfaceJsonConverter<T extends Nameable>
- Parameters:
object
- The objcet to convert- Returns:
- The JSON object
-
setMore
protected void setMore(org.json.simple.JSONObject json, T object)
Can be used by subclasses to set more properties on the JSON object. The default implementation does nothing.- Parameters:
json
- The JSON object that store the converted propertiesobject
- The object that is being converted
-
-