Package org.onosproject.rest
Class AbstractWebResource
- java.lang.Object
-
- org.onlab.rest.BaseResource
-
- org.onosproject.rest.AbstractWebResource
-
- All Implemented Interfaces:
CodecContext
- Direct Known Subclasses:
AbstractInjectionResource
public class AbstractWebResource extends BaseResource implements CodecContext
Abstract REST resource.
-
-
Constructor Summary
Constructors Constructor Description AbstractWebResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> JsonCodec<T>codec(java.lang.Class<T> entityClass)Returns the JSON codec for the specified entity class.protected <T> com.fasterxml.jackson.databind.node.ObjectNodeencodeArray(java.lang.Class<T> codecClass, java.lang.String field, java.lang.Iterable<T> items)Returns JSON object wrapping the array encoding of the specified collection of items.<T> TgetService(java.lang.Class<T> serviceClass)Returns reference to the specified service implementation.com.fasterxml.jackson.databind.ObjectMappermapper()Returns the JSON object mapper.com.fasterxml.jackson.databind.node.ArrayNodenewArray(com.fasterxml.jackson.databind.node.ObjectNode parent, java.lang.String key)Creates and returns a new child array within the specified parent and bound to the given key.com.fasterxml.jackson.databind.node.ObjectNodenewObject(com.fasterxml.jackson.databind.node.ObjectNode parent, java.lang.String key)Creates and returns a new child object within the specified parent and bound to the given key.-
Methods inherited from class org.onlab.rest.BaseResource
get, ok
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.onosproject.codec.CodecContext
decode, encode
-
-
-
-
Method Detail
-
mapper
public com.fasterxml.jackson.databind.ObjectMapper mapper()
Description copied from interface:CodecContextReturns the JSON object mapper.- Specified by:
mapperin interfaceCodecContext- Returns:
- object mapper
-
codec
public <T> JsonCodec<T> codec(java.lang.Class<T> entityClass)
Returns the JSON codec for the specified entity class.- Specified by:
codecin interfaceCodecContext- Type Parameters:
T- entity type- Parameters:
entityClass- entity class- Returns:
- JSON codec
-
encodeArray
protected <T> com.fasterxml.jackson.databind.node.ObjectNode encodeArray(java.lang.Class<T> codecClass, java.lang.String field, java.lang.Iterable<T> items)Returns JSON object wrapping the array encoding of the specified collection of items.- Type Parameters:
T- item type- Parameters:
codecClass- codec item classfield- field holding the arrayitems- collection of items to be encoded into array- Returns:
- JSON object
-
getService
public <T> T getService(java.lang.Class<T> serviceClass)
Description copied from interface:CodecContextReturns reference to the specified service implementation.- Specified by:
getServicein interfaceCodecContext- Type Parameters:
T- service type- Parameters:
serviceClass- service class- Returns:
- service implementation; null if no implementation available for the class
-
newObject
public com.fasterxml.jackson.databind.node.ObjectNode newObject(com.fasterxml.jackson.databind.node.ObjectNode parent, java.lang.String key)Creates and returns a new child object within the specified parent and bound to the given key.- Parameters:
parent- parent objectkey- key for the new child object- Returns:
- child object
-
newArray
public com.fasterxml.jackson.databind.node.ArrayNode newArray(com.fasterxml.jackson.databind.node.ObjectNode parent, java.lang.String key)Creates and returns a new child array within the specified parent and bound to the given key.- Parameters:
parent- parent objectkey- key for the new child array- Returns:
- child array
-
-