org.refcodes.properties.ext.runtime.RuntimeProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refcodes-properties-ext-runtime Show documentation
Show all versions of refcodes-properties-ext-runtime Show documentation
Artifact for providing predefined configuration compositions common for
everyday application setups.
// /////////////////////////////////////////////////////////////////////////////
// REFCODES.ORG
// /////////////////////////////////////////////////////////////////////////////
// This code is copyright (c) by Siegfried Steiner, Munich, Germany and licensed
// under the following (see "http://en.wikipedia.org/wiki/Multi-licensing")
// licenses:
// -----------------------------------------------------------------------------
// GNU General Public License, v3.0 ("http://www.gnu.org/licenses/gpl-3.0.html")
// -----------------------------------------------------------------------------
// Apache License, v2.0 ("http://www.apache.org/licenses/TEXT-2.0")
// -----------------------------------------------------------------------------
// Please contact the copyright holding author(s) of the software artifacts in
// question for licensing issues not being covered by the above listed licenses,
// also regarding commercial licensing models or regarding the compatibility
// with other open source licenses.
// /////////////////////////////////////////////////////////////////////////////
package org.refcodes.properties.ext.runtime;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.text.ParseException;
import java.util.Collection;
import java.util.List;
import org.refcodes.cli.AmbiguousArgsException;
import org.refcodes.cli.ArgsSyntax;
import org.refcodes.cli.Example;
import org.refcodes.cli.Operand;
import org.refcodes.cli.Option;
import org.refcodes.cli.ParseArgsException;
import org.refcodes.cli.RootConditionAccessor.RootConditionBuilder;
import org.refcodes.cli.RootConditionAccessor.RootConditionMutator;
import org.refcodes.cli.SuperfluousArgsException;
import org.refcodes.cli.SyntaxNotation;
import org.refcodes.cli.UnknownArgsException;
import org.refcodes.mixin.SecretAccessor.SecretBuilder;
import org.refcodes.mixin.SecretAccessor.SecretMutator;
import org.refcodes.properties.EnvironmentProperties;
import org.refcodes.properties.ProfileProperties;
import org.refcodes.properties.ProfilePropertiesProjection;
import org.refcodes.properties.Properties;
import org.refcodes.properties.ResourceLoaderMixin;
import org.refcodes.properties.ResourceProperties;
import org.refcodes.properties.SystemProperties;
import org.refcodes.properties.TomlPropertiesBuilder;
import org.refcodes.properties.ext.cli.ArgsParserProperties;
import org.refcodes.runtime.ConfigLocator;
import org.refcodes.runtime.RuntimeUtility;
import org.refcodes.runtime.SystemContext;
import org.refcodes.textual.Font;
import org.refcodes.textual.TextBoxGrid;
/**
* {@link RuntimeProperties} are composed of various {@link Properties} flavors
* such as {@link ArgsParserProperties}, {@link SystemProperties},
* {@link EnvironmentProperties} and {@link ResourceProperties} with a
* precedence in this order, encapsulated by a
* {@link ProfilePropertiesProjection} in order for you, the developer, to
* conveniently harness the power of the {@link Properties} functionality. You
* may also add a {@link Properties} instance programmatically to manually
* provide properties (via {@link #withProperties(Properties)}). The later you
* add {@link Properties}, the lower their precedence. After construction the
* use {@link #withFile(java.io.File)}, {@link #withUrl(java.net.URL)} or the
* like to load the properties from external resources. After construction use
* {@link #withEvalArgs(String[])} or the like to parse the command line
* arguments (implementations might provide a constructor such as
* {@link RuntimePropertiesImpl#RuntimePropertiesImpl(String[])} for the command
* line arguments if you do not require a command syntax notation).
* {@link RuntimeProperties} represent a composition of the different
* {@link Properties} flavors, therefore providing functionality from the
* {@link ArgsParserProperties} as well as from the {@link ResourceProperties}
* types.
*/
public interface RuntimeProperties extends RootConditionMutator, RootConditionBuilder, SecretMutator, SecretBuilder, ArgsParserProperties, ResourceProperties, ResourceLoaderMixin, ProfileProperties {
static char[] DELIMITERS = TomlPropertiesBuilder.DELIMITERS;
/**
* Specifies the obfuscation mode to be used.
*
* @param aObfuscationMode The {@link SystemContext} specifies which level
* of obfuscation is to be used when encountering upon obfuscated
* properties: E.g. obfuscation may be bound to the host, the
* "secret" used for obfuscation being the same for all applications
* on the same host or obfuscation may be bound to the application,
* being different for different applications on the same host.
*/
void setObfuscationMode( SystemContext aObfuscationMode );
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withExample( Example aExample ) {
addExample( aExample );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withTextBoxGrid( TextBoxGrid aTextBoxGrid ) {
setTextBoxGrid( aTextBoxGrid );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withDescriptionEscapeCode( String aDescriptionEscCode ) {
setDescriptionEscapeCode( aDescriptionEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withCommandEscapeCode( String aCommandEscCode ) {
setCommandEscapeCode( aCommandEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withBannerEscapeCode( String aBannerEscCode ) {
setBannerEscapeCode( aBannerEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withLineSeparatorEscapeCode( String aLineSeparatorEscCode ) {
setLineSeparatorEscapeCode( aLineSeparatorEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withBannerBorderEscapeCode( String aBannerBorderEscCode ) {
setBannerBorderEscapeCode( aBannerBorderEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withEscapeCodesEnabled( boolean isEscCodeEnabled ) {
setEscapeCodesEnabled( isEscCodeEnabled );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withResetEscapeCode( String aResetEscCode ) {
setResetEscapeCode( aResetEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withParamEscapeCode( String aParamEscCode ) {
setParamEscapeCode( aParamEscCode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withOptionEscapeCode( String aOptionEscCode ) {
setOptionEscapeCode( aOptionEscCode );
return this;
}
/**
* Builder method for the obfuscation mode property returning the builder
* for applying multiple build operations.
*
* @param aObfuscationMode The obfuscation mode as of
* {@link #setObfuscationMode(SystemContext)}.
*
* @return The builder for applying multiple build operations.
*/
default RuntimeProperties withObfuscationMode( SystemContext aObfuscationMode ) {
setObfuscationMode( aObfuscationMode );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withRootArgsSyntax( ArgsSyntax aRootArgsSyntax ) {
setRootArgsSyntax( aRootArgsSyntax );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withRootOption( Option> aRootCondition ) {
setRootOption( aRootCondition );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withSecret( String aSecret ) {
setSecret( aSecret );
return this;
}
/**
* A hook for you to provide {@link Properties} programmatically. The later
* you add {@link Properties}, the lower their precedence.
*
* @param aProperties The {@link Properties} to be added.
*
* @return This instance as of the builder pattern to apply method chaining.
*/
RuntimeProperties withProperties( Properties aProperties );
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withFile( File aFile ) throws IOException, ParseException {
return withFile( aFile, DELIMITERS );
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withFilePath( String aFilePath ) throws IOException, ParseException {
return withFilePath( RuntimeUtility.getMainClass(), aFilePath, DELIMITERS );
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withFilePath( Class> aResourceClass, String aFilePath ) throws IOException, ParseException {
return withFilePath( aResourceClass, aFilePath, ConfigLocator.ALL, DELIMITERS );
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withUrl( URL aUrl ) throws IOException, ParseException {
return withUrl( aUrl, DELIMITERS );
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withFile( File aFile, ConfigLocator aConfigLocator ) throws IOException, ParseException {
return withFile( aFile, aConfigLocator, DELIMITERS );
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withInputStream( InputStream aInputStream ) throws IOException, ParseException {
return withInputStream( aInputStream, DELIMITERS );
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withTitle( String aTitle ) {
setTitle( aTitle );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withBannerFont( Font aBannerFont ) {
setBannerFont( aBannerFont );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withExample( String aDescription, Operand>... aOperands ) {
addExample( aDescription, aOperands );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withExamples( Collection aExample ) {
ArgsParserProperties.super.withExamples( aExample );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withExamples( Example[] aExample ) {
ArgsParserProperties.super.withExamples( aExample );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withBannerFontPalette( char[] aColorPalette ) {
setBannerFontPalette( aColorPalette );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withConsoleWidth( int aConsoleWidth ) {
setConsoleWidth( aConsoleWidth );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withCopyrightNote( String aCopyrightNote ) {
setCopyrightNote( aCopyrightNote );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withDescription( String aDescription ) {
setDescription( aDescription );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withErrorOut( PrintStream aErrorOut ) {
setErrorOut( aErrorOut );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withEvalArgs( List aArgs ) throws UnknownArgsException, AmbiguousArgsException, SuperfluousArgsException, ParseArgsException {
evalArgs( aArgs );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withEvalArgs( String aToPath, List aArgs ) throws UnknownArgsException, AmbiguousArgsException, SuperfluousArgsException, ParseArgsException {
evalArgs( aToPath, aArgs );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withEvalArgs( String aToPath, String[] aArgs ) throws UnknownArgsException, AmbiguousArgsException, SuperfluousArgsException, ParseArgsException {
evalArgs( aToPath, aArgs );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withEvalArgs( String[] aArgs ) throws UnknownArgsException, AmbiguousArgsException, SuperfluousArgsException, ParseArgsException {
evalArgs( aArgs );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withLicenseNote( String aLicenseNote ) {
setLicenseNote( aLicenseNote );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withLineBreak( String aLineBreak ) {
setLineBreak( aLineBreak );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withMaxConsoleWidth( int aMaxConsoleWidth ) {
setMaxConsoleWidth( aMaxConsoleWidth );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withName( String aName ) {
setName( aName );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withSeparatorLnChar( char aSeparatorChar ) {
setSeparatorLnChar( aSeparatorChar );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withStandardOut( PrintStream aStandardOut ) {
setStandardOut( aStandardOut );
return this;
}
/**
* {@inheritDoc}
*/
@Override
default RuntimeProperties withSyntaxNotation( SyntaxNotation aSyntaxNotation ) {
setSyntaxNotation( aSyntaxNotation );
return this;
}
/**
* The behavior of this method is implementation specific. See the javadoc
* of the implementation in question (such as
* {@link RuntimePropertiesImpl#toSerialized()}) for implementation details.
* {@inheritDoc}
*/
@Override
String toSerialized();
/**
* The behavior of this method is implementation specific. See the javadoc
* of the implementation in question (such as
* {@link RuntimePropertiesImpl#toSerialized()}) for implementation details.
* {@inheritDoc}
*/
@Override
String toSerialized( char aDelimiter );
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy