Class ProjectInfo

java.lang.Object
eu.bandm.tools.annotations.ProjectInfo

public abstract class ProjectInfo extends Object
Access point for project context information.

Information is stored in the form of a properties file that is accessed at runtime as a resource. This resource must be present as a file at the top of the class file tree of the involved class loader.

A default name for the properties file is fixed as PROJECT_INFO_FILENAME. It is possible, but not recommended, to specify a different name.

Since:
1.2
See Also:
  • Field Details

    • PROJECT_INFO_FILENAME

      public static final String PROJECT_INFO_FILENAME
      The default name of the properties file where project context information is stored.
      See Also:
  • Method Details

    • getProperty

      public static String getProperty(Class<?> tool, String propertyName, String defaultValue)
      Queries the value of a tool-specific project context property.

      This operation fails silently and returns the given default value if the property file is not available as a resource, cannot be loaded, or does not contain the expected property.

      Parameters:
      tool - the main class of the tool
      propertyName - the unqualified name of the property
      defaultValue - the default value for the property
      Returns:
      the value of the property with the given name qualified by the name of the given class, or the given default value if not available.
    • getProperty

      public static String getProperty(@Opt @Opt ClassLoader classLoader, String propertyName, String defaultValue)
      Queries the value of a project context property.

      This operation fails silently and returns the given default value if the property file is not available as a resource, cannot be loaded, or does not contain the expected property.

      Parameters:
      classLoader - the class loader from which to obtain the resource file, or null for the bootstrap class loader
      propertyName - the qualified name of the property
      defaultValue - the default value for the property
      Returns:
      the value of the property with the given name, or the given default value if not available.
    • getProperty

      public static String getProperty(@Opt @Opt ClassLoader classLoader, String projectInfoFilename, String propertyName, String defaultValue)
      Queries the value of a project context property.

      This operation fails silently and returns the given default value if the property file is not available as a resource, cannot be loaded, or does not contain the expected property.

      Parameters:
      classLoader - the class loader from which to obtain the resource file, or null for the bootstrap class loader
      projectInfoFilename - the relative name of the of the properties file where project context information is stored
      propertyName - the qualified name of the property
      defaultValue - the default value for the property
      Returns:
      the value of the property with the given name, or the given default value if not available.
      Since:
      1.3