Reference Guide

Table Of Contents
import com.hp.util.filter.EqualityCondition;
import com.hp.util.filter.StringCondition;
...
public class SwitchFilter {
private StringCondition nameCondition;
...
// Implement setters and getters for all conditions.
// Good practice to override toString()
}
The following listing depicts a usage example: Create a filter to retrieve all open flow switches with
a name that contains the text ‘My Switch.
Switch Filter Usage Example:
SwitchFilter filter = new SwitchFilter();
filter.setNameCondition(new StringCondition("My Switch",
StringCondition.Mode.CONTAINS));
Following a similar approach, create a Java enumeration to represent the sort possibilities in which
open flow switches can be retrieved. This helps decoupling the service consumer from the way
sorting is implemented in lower level layers (like column names in a database). The following
listing shows the Open Flow Switch sort possibilities and the next listing depicts a usage example:
When retrieving switches the primary order shall be the Name ascending.
SwitchSortKey.java:
package com.hp.hm.model;
public enum SwitchSortKey {
NAME
}
Switch Sort Specification Usage Example:
SortSpecification<SwitchSortKey> sort =
new SortSpecification<SwitchSortKey>();
sort.addSortComponent(SwitchSortKey. NAME, SortOrder.ASCENDING);
Model Objects Unit Test
The HP VAN SDN Controller Framework offers some utilities to facilitate writing unit tests.
Even though The Data Transfer Object [31] is a pattern while a JavaBean [32] is a specification,
consider a Data Transfer Object as a java bean which is transported across tiers. The Data
Transfer Object pattern is used as a light-weight method of transferring data between layers. Thus,
use the Bean Test utilities provided by the HP VAN SDN Controller Framework to test the transfer
objects. The following listing illustrates the utility classes provided by the HP VAN SDN Controller
Framework that can be used to test model objects. For the complete test code see the sample
154