/*
 * Copyright 2011, Mysema Ltd
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mysema.query.apt;

/**
 * VisitorConfig defines the entity type specific visiting configuration
 *
 * @author tiwe
 *
 */
public enum VisitorConfig {
    /**
     * visit both fields and getters
     */
    ALL(true, true, true),

    /**
     * visit fields only
     */
    FIELDS_ONLY(true, false, true),

    /**
     * visit methods only
     */
    METHODS_ONLY(false, true, true),

    /**
     * visit none
     */
    NONE(false, false, false);

    private final boolean visitFieldProperties, visitMethodProperties, visitConstructors;

    public static VisitorConfig get(boolean fields, boolean methods, VisitorConfig defaultConfig) {
        if (fields && methods) {
            return VisitorConfig.ALL;
        } else if (fields && !methods) {
            return VisitorConfig.FIELDS_ONLY;
        } else if (methods && !fields) {
            return VisitorConfig.METHODS_ONLY;
        } else {
            return defaultConfig;
        }
    }
    
    VisitorConfig(boolean fields, boolean methods, boolean constructors) {
        this.visitFieldProperties = fields;
        this.visitMethodProperties = methods;
        this.visitConstructors = constructors;
    }
    
    public boolean visitConstructors() {
        return visitConstructors;
    }

    public boolean visitFieldProperties() {
        return visitFieldProperties;
    }

    public boolean visitMethodProperties() {
        return visitMethodProperties;
    }

}

@@ -1137,16 +1137,150 @@
 ctors;%0A%0A
+    public static VisitorConfig get(boolean fields, boolean methods) %7B%0A        return get(fields, methods, VisitorConfig.ALL);%0A    %7D%0A%0A
     publ

Fix backwards compat