2 * Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy
3 * http://www.e-taxonomy.eu
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 See LICENSE.TXT at the top of this package for the full license terms.
8 package eu
.etaxonomy
.cdm
.remote
.json
.processor
.matcher
;
12 import org
.apache
.logging
.log4j
.LogManager
;
13 import org
.apache
.logging
.log4j
.Logger
;
14 import org
.hibernate
.proxy
.HibernateProxy
;
16 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
18 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
19 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
23 import eu
.etaxonomy
.cdm
.model
.term
.TermBase
;
24 import net
.sf
.json
.processors
.JsonBeanProcessorMatcher
;
27 * can handle HibernateProxys
29 * @author a.kohlbecker
31 public class CdmProxyBeanProcessorMatcher
extends JsonBeanProcessorMatcher
{
33 private static final Logger logger
= LogManager
.getLogger();
36 public Object
getMatch(Class target
, Set set
) {
38 if (HibernateProxy
.class.isAssignableFrom(target
)) {
39 if(logger
.isDebugEnabled()){
40 logger
.debug("Found HibernateProxy object of class " + target
.getClass() + " returning " + HibernateProxy
.class);
42 return HibernateProxy
.class;
45 // TODO implement generically by making use of CdmBaseType
46 if (TaxonBase
.class.isAssignableFrom(target
)) {
47 return DEFAULT
.getMatch(TaxonBase
.class, set
);
49 if (TaxonName
.class.isAssignableFrom(target
)) {
50 return DEFAULT
.getMatch(TaxonName
.class, set
);
52 if (TermBase
.class.isAssignableFrom(target
)) {
53 return DEFAULT
.getMatch(TermBase
.class, set
);
55 if (TeamOrPersonBase
.class.isAssignableFrom(target
)) {
56 return DEFAULT
.getMatch(TeamOrPersonBase
.class, set
);
58 if (Media
.class.isAssignableFrom(target
)) {
59 return DEFAULT
.getMatch(Media
.class, set
);
61 if (Reference
.class.isAssignableFrom(target
)) {
62 return DEFAULT
.getMatch(Reference
.class, set
);
64 if (TypeDesignationBase
.class.isAssignableFrom(target
)) {
65 return DEFAULT
.getMatch(TypeDesignationBase
.class, set
);
67 if (DescriptionElementBase
.class.isAssignableFrom(target
)) {
68 return DEFAULT
.getMatch(DescriptionElementBase
.class, set
);
71 return DEFAULT
.getMatch(target
, set
);