1
2
3
4
5
6
7 package net.sf.tacos.model.impl;
8
9 import java.io.Serializable;
10 import net.sf.tacos.model.IKeyProvider;
11
12 import org.apache.commons.beanutils.BeanUtils;
13
14
15
16
17
18
19 public class BeanPropertyKeyProvider implements IKeyProvider {
20
21 private String property;
22
23 public BeanPropertyKeyProvider(String property) {
24 this.property = property;
25 }
26
27 public Serializable getKey(Object obj) {
28 try {
29 return BeanUtils.getProperty(obj, property);
30 } catch (Exception e) {
31 throw new RuntimeException("Error getting property", e);
32 }
33 }
34
35 }