Reflection and Annotations
I'm writing a container class that holds input configuration data for a bioinformatics tool called Primer3 which takes its input as a BoulderIO document, which is of the format:
SEQUENCE=acttgtgtgagagtgc
TARGET=1,7
=
SEQUENCE=gggtgtgagattgg
NAME2=4,25
=
where only one option per line is permitted, and multiple records are separated by a single equals sign followed by a newline. I've encapsulated the data to be stored in a JavaBean:
public class DesignRequest {
private String sequence;
private Target target;
@Primer3Option (name = "SEQUENCE")
public String getSequence() {
return this.sequence;
}
}
The fact that Target is a compound type should be immaterial for this example.
My question is this. I'm fairly new to reflection and annotation features, so I'm planning how to write a Marshaller and Unmarshaller for this data type. Is there a standard way to access JavaBean properties through reflection, or do I just call request.getClass().getDeclaredMethods() and filter on the method names?
Also, since I'm annotating the accessor methods and not the mutator methods, if I want to access a bean property's mutator, so I have to manually look for a set* to complement it's get*?
Broad questions, I know, any help is appreciated.
SEQUENCE=acttgtgtgagagtgc
TARGET=1,7
=
SEQUENCE=gggtgtgagattgg
NAME2=4,25
=
where only one option per line is permitted, and multiple records are separated by a single equals sign followed by a newline. I've encapsulated the data to be stored in a JavaBean:
public class DesignRequest {
private String sequence;
private Target target;
@Primer3Option (name = "SEQUENCE")
public String getSequence() {
return this.sequence;
}
}
The fact that Target is a compound type should be immaterial for this example.
My question is this. I'm fairly new to reflection and annotation features, so I'm planning how to write a Marshaller and Unmarshaller for this data type. Is there a standard way to access JavaBean properties through reflection, or do I just call request.getClass().getDeclaredMethods() and filter on the method names?
Also, since I'm annotating the accessor methods and not the mutator methods, if I want to access a bean property's mutator, so I have to manually look for a set* to complement it's get*?
Broad questions, I know, any help is appreciated.
