public class DeviceInfoAdapter extends Object implements DeviceInfo
Constructor and Description |
---|
DeviceInfoAdapter() |
Modifier and Type | Method and Description |
---|---|
DeviceInfo |
evolve()
A request to "evolve" this device info instance to reflect current
information that may have been collected.
|
String |
exportData()
Exports the contents of the device info into a string form.
|
<T extends Facet> |
getFacet(Class<T> facetClass)
Returns an implementation of the specified facet class, or null if that
facet is not supported by this provider.
|
Set<Class<? extends Facet>> |
getFacetClasses()
Returns the set of facet classes for the facets that this provider
provides.
|
Set<String> |
getFacetClassNames()
Returns the set of facet class names for the facets that this provider
provides.
|
int |
getGeneration()
Get the generation number of the device info.
|
String |
getTypeName()
Returns the name of the device type backing this instance.
|
boolean |
importData(String data)
Imports the contents of the device info from the specified
export-encoded string.
|
boolean |
isSupported(Class<? extends Facet> facetClass)
Returns true if the specified facet class is supported by this
provider.
|
public Set<Class<? extends Facet>> getFacetClasses()
FacetProvider
getFacetClasses
in interface FacetProvider
public Set<String> getFacetClassNames()
FacetProvider
FacetProvider.getFacetClasses()
and populate the returned set with the result
of calling Class.getName()
on each class.getFacetClassNames
in interface FacetProvider
public boolean isSupported(Class<? extends Facet> facetClass)
FacetProvider
public boolean isSupported(Class<? extends Facet> facetClass) {
return FacetProvider.getFacetClasses()
().contains(facetClass);
}
isSupported
in interface FacetProvider
facetClass
- a facet classpublic <T extends Facet> T getFacet(Class<T> facetClass)
FacetProvider
getFacet
in interface FacetProvider
T
- Facet typefacetClass
- the class of the required facetpublic String getTypeName()
DeviceInfo
getTypeName
in interface DeviceInfo
public DeviceInfo evolve()
DeviceInfo
If the device info contains additional information to warrant further evolution then an altered or a different device info instance will be returned, whose generation number will be greater than the original device info generation number. Otherwise, the same device info instance may be returned with its generation number unchanged to indicate that no evolution occurred.
A recommended pattern of use is
DeviceInfo info = ... int originalGeneration = info.getGeneration(); ... // Attempt to evolve the underlying device type when we think more // information about the underlying device may available to to // further narrow the specific of the device type. info = info.evolve(); if (originalGeneration < info.getGeneration()) // Device info has evolved ... else // Device info did not evolve any further ...
evolve
in interface DeviceInfo
public int getGeneration()
DeviceInfo
DeviceInfoProvider.create()
methods.getGeneration
in interface DeviceInfo
public String exportData()
DeviceInfo
exportData
in interface DeviceInfo
DeviceInfo.importData(String)
public boolean importData(String data)
DeviceInfo
There is no mandate to be able to import data exported from a device info of a different type.
importData
in interface DeviceInfo
data
- string previously encoded via DeviceInfo.exportData()
Copyright © 2015. All Rights Reserved.