Interface TunablePropertySerializer


public interface TunablePropertySerializer
This is a type of tunable interceptor that converts the values annotated with Tunable annotations to and from a Properties object. The generated Properties can be used with CyProperty<Properties> to save the values.

Example:

 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());
 
Produces the following key/value pairs:

 foo.x=5
 y=10
 
Values are converted to and from Strings using available TunablePropertyHandlers. 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
Support for additional types can be provided by registering a TunablePropertyHandlerFactory OSGi service.

Note: Implementations of this interface are typically not thread safe. Use TunablePropertySerializerFactory 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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setTunables(Object objectWithTunables, Properties properties)
    Takes the properties and applies them to the tunables in the object.
    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 a TunablePropertyHandler to the tunable value.
  • Method Details

    • 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. A TunablePropertyHandler 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 a TunablePropertyHandler to the tunable value.
      Parameters:
      objectWithTunables - Object with @Tunable annotations.
      Returns:
      Properties object.