All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.sisu.space.BeanScanning Maven / Gradle / Ivy

There is a newer version: 3.0.0-alpha-3
Show newest version
/*******************************************************************************
 * Copyright (c) 2010-present Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Stuart McCulloch (Sonatype, Inc.) - initial API and implementation
 *******************************************************************************/
package org.eclipse.sisu.space;

import java.util.Locale;
import java.util.Map;

/**
 * Common techniques for discovering bean implementations.
 * 
 * @see org.eclipse.sisu.space.SpaceModule
 */
public enum BeanScanning
{
    /**
     * Always scan
     */
    ON,

    /**
     * Never scan
     */
    OFF,

    /**
     * Scan once and cache results
     */
    CACHE,

    /**
     * Use local index (plug-ins)
     */
    INDEX,

    /**
     * Use global index (application)
     */
    GLOBAL_INDEX;

    /**
     * Selects the property named "org.eclipse.sisu.space.BeanScanning" and attempts to map its value to a
     * {@link BeanScanning} literal, ignoring case. Defaults to {@link BeanScanning#ON} for blank or null values.
     * 
     * @param properties The properties
     * @return Selected scanning option
     * @throws IllegalArgumentException if the property value cannot be mapped
     */
    public static BeanScanning select( final Map properties )
        throws IllegalArgumentException
    {
        final String option = (String) properties.get( BeanScanning.class.getName() );
        if ( null == option || option.trim().length() == 0 )
        {
            return BeanScanning.ON;
        }
        return Enum.valueOf( BeanScanning.class, option.toUpperCase( Locale.ENGLISH ) );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy