1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5
6package org.mockito.internal.util.reflection;
7
8/**
9 * Report on field initialization
10 */
11public class FieldInitializationReport {
12    private Object fieldInstance;
13    private boolean wasInitialized;
14    private boolean wasInitializedUsingConstructorArgs;
15
16    public FieldInitializationReport(Object fieldInstance, boolean wasInitialized, boolean wasInitializedUsingConstructorArgs) {
17        this.fieldInstance = fieldInstance;
18        this.wasInitialized = wasInitialized;
19        this.wasInitializedUsingConstructorArgs = wasInitializedUsingConstructorArgs;
20    }
21
22    /**
23     * Returns the actual field instance.
24     *
25     * @return the actual instance
26     */
27    public Object fieldInstance() {
28        return fieldInstance;
29    }
30
31    /**
32     * Indicate wether the field was created during the process or not.
33     *
34     * @return <code>true</code> if created, <code>false</code> if the field did already hold an instance.
35     */
36    public boolean fieldWasInitialized() {
37        return wasInitialized;
38    }
39
40    /**
41     * Indicate wether the field was created using constructor args.
42     *
43     * @return <code>true</code> if field was created using constructor parameters.
44     */
45    public boolean fieldWasInitializedUsingContructorArgs() {
46        return wasInitializedUsingConstructorArgs;
47    }
48
49    /**
50     * Returns the class of the actual instance in the field.
51     *
52     * @return Class of the instance
53     */
54    public Class<?> fieldClass() {
55        return fieldInstance != null ? fieldInstance.getClass() : null;
56    }
57}
58
59