Package org.cytoscape.work.properties
Interface TunablePropertySerializer
-
public interface TunablePropertySerializer
This is a type of tunable interceptor that converts the values annotated withTunable
annotations to and from a Properties object. The generated Properties can be used withCyProperty<Properties>
to save the values.
Example:
Produces the following key/value pairs:public class Foo { @Tunable public int x = 5; } public class Bar { @ContainsTunables public Foo foo = new Foo(); @Tunable public int y = 10; } Properties props = tunablePropertySerializer.toProperties(new Bar());
Values are converted to and from Strings using availablefoo.x=5 y=10
TunablePropertyHandler
s. By default the following types are supported:- "Basic" types
- Strings
- Enums
- primitive types (eg: int, double)
- wrappers for primitive types (eg: java.lang.Integer, java.lang.Double)
- ListSingleSelection<T> where T is a Basic type
- ListMultipleSelection<T> where T is a Basic type
- BoundedFloat
- BoundedDouble
- BoundedInteger
- BoundedLong
TunablePropertyHandlerFactory
OSGi service.
Note: Implementations of this interface are typically not thread safe. UseTunablePropertySerializerFactory
to create thread-local instances.Module:
work-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>work-api</artifactId> </dependency>
Cytoscape Backwards Compatibility (API Interface): We expect that this interface will be used but not implemented by developers using this interface. As such, we reserve the right to add methods to the interface as part of minor version upgrades. We will not remove methods for any changes other than major version upgrades. - "Basic" types
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
setTunables(Object objectWithTunables, Properties properties)
Takes the properties and applies them to the tunables in the object.Properties
toProperties(Object objectWithTunables)
Returns a Properties object where each property key is a qualified field name and the property value is the result of applying aTunablePropertyHandler
to the tunable value.
-
-
-
Method Detail
-
setTunables
void setTunables(Object objectWithTunables, Properties properties)
Takes the properties and applies them to the tunables in the object. Each property is converted from a String into a value of the type of the tunable. ATunablePropertyHandler
of the appropriate type must be available.- Parameters:
objectWithTunables
- Object with @Tunable annotations.properties
- Properties object.- Throws:
IllegalArgumentException
- If any of the property values cannot be parsed or contain an illegal value.
-
toProperties
Properties toProperties(Object objectWithTunables)
Returns a Properties object where each property key is a qualified field name and the property value is the result of applying aTunablePropertyHandler
to the tunable value.- Parameters:
objectWithTunables
- Object with @Tunable annotations.- Returns:
- Properties object.
-
-