1 /*
2 * Copyright 2004-2025 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.ibatis.common.beans;
17
18 /**
19 * An abstract factory for getting Probe implementations.
20 */
21 public class ProbeFactory {
22
23 /** The Constant DOM. */
24 private static final Probe DOM = new DomProbe();
25
26 /** The Constant BEAN. */
27 private static final Probe BEAN = new ComplexBeanProbe();
28
29 /** The Constant GENERIC. */
30 private static final Probe GENERIC = new GenericProbe();
31
32 /**
33 * Private constructor to prevent instantiation.
34 */
35 private ProbeFactory() {
36 // Prevent instantiation
37 }
38
39 /**
40 * Factory method for getting a Probe object.
41 *
42 * @return An implementation of the Probe interface
43 */
44 public static Probe getProbe() {
45 return GENERIC;
46 }
47
48 /**
49 * Factory method for getting a Probe object that is the best choice for the type of object supplied by the object
50 * parameter.
51 *
52 * @param object
53 * The object to get a Probe for
54 *
55 * @return An implementation of the Probe interface
56 */
57 public static Probe getProbe(Object object) {
58 if (object instanceof org.w3c.dom.Document) {
59 return DOM;
60 }
61 return BEAN;
62 }
63
64 }