01: package org.osbl.client;
02:
03: import org.conform.*;
04: import org.conform.format.*;
05:
06: class FormatModifier implements Modifier {
07: public FormatModifier(BeanMetaProvider beanMetaProvider) {
08: }
09:
10: public void modify(BeanMeta beanMeta) throws ModifierException {
11: if (beanMeta.getFormat() != null)
12: return;
13:
14: Format format = getFormat(beanMeta);
15: if (format != null)
16: beanMeta.setFormat(format);
17: }
18:
19: private Format getFormat(BeanMeta beanMeta) {
20: boolean name = beanMeta.getProperty("name") != null;
21: boolean key = beanMeta.getProperty("key") != null;
22:
23: if (name && key)
24: return new CallGetterFormat("getName", "getKey");
25:
26: if (name)
27: return new CallGetterFormat("getName");
28:
29: if (key)
30: return new CallGetterFormat("getKey");
31:
32: return null;
33: }
34: }
|