Skip to content

Commit

Permalink
Reformat using spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed May 26, 2023
1 parent 72c6f20 commit 0e3c0b1
Show file tree
Hide file tree
Showing 236 changed files with 13,014 additions and 17,264 deletions.
10 changes: 4 additions & 6 deletions modello-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>modello</artifactId>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello</artifactId>
<version>2.1.2-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>modello-core</artifactId>
<name>Modello Core</name>
<description>
Modello Core contains the basis for model description, reading, and plugins system.
</description>
<description>Modello Core contains the basis for model description, reading, and plugins system.</description>

<dependencies>
<dependency>
Expand Down
38 changes: 15 additions & 23 deletions modello-core/src/main/java/org/codehaus/modello/Modello.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,39 @@
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.modello.model.Model;
import org.codehaus.modello.model.ModelValidationException;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainer;

/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class Modello
{
public class Modello {
private PlexusContainer container;

private ModelloCore core;

public Modello()
throws ModelloException
{
try
{
public Modello() throws ModelloException {
try {
container = new DefaultPlexusContainer();

core = (ModelloCore) container.lookup( ModelloCore.ROLE );
}
catch ( Exception ex )
{
throw new ModelloException( "Error while starting plexus.", ex );
core = (ModelloCore) container.lookup(ModelloCore.ROLE);
} catch (Exception ex) {
throw new ModelloException("Error while starting plexus.", ex);
}
}

public void generate( Reader modelReader, String outputType, Properties parameters )
throws ModelloException, ModelValidationException
{
Model model = core.loadModel( modelReader );
public void generate(Reader modelReader, String outputType, Properties parameters)
throws ModelloException, ModelValidationException {
Model model = core.loadModel(modelReader);

core.generate( model, outputType, parameters );
core.generate(model, outputType, parameters);
}

public void translate( Reader reader, Writer writer, String outputType, Properties parameters )
throws ModelloException, ModelValidationException
{
Model model = core.translate( reader, outputType, parameters );
public void translate(Reader reader, Writer writer, String outputType, Properties parameters)
throws ModelloException, ModelValidationException {
Model model = core.translate(reader, outputType, parameters);

core.saveModel( model, writer );
core.saveModel(model, writer);
}
}
82 changes: 35 additions & 47 deletions modello-core/src/main/java/org/codehaus/modello/ModelloCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,114 +22,102 @@
* SOFTWARE.
*/

import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;

import java.io.File;
import java.util.Properties;

import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class ModelloCli
{
public class ModelloCli {
private static File modelFile;

private static String outputType;

private static Properties parameters;

public static void main( String[] args )
throws Exception
{
public static void main(String[] args) throws Exception {
Modello modello = new Modello();

parseArgumentsFromCommandLine( args );
parseArgumentsFromCommandLine(args);

modello.generate( ReaderFactory.newXmlReader( modelFile ), outputType, parameters );
modello.generate(ReaderFactory.newXmlReader(modelFile), outputType, parameters);
}

public static void parseArgumentsFromCommandLine( String[] args )
throws Exception
{
if ( args.length < 6 )
{
public static void parseArgumentsFromCommandLine(String[] args) throws Exception {
if (args.length < 6) {
usage();

System.exit( 1 );
System.exit(1);
}

modelFile = new File( args[0] );
modelFile = new File(args[0]);

outputType = args[1];

parameters = new Properties();

String outputDirectory = args[2];

if ( StringUtils.isEmpty( outputDirectory ) )
{
System.err.println( "Missing required parameter: output directory" );
if (StringUtils.isEmpty(outputDirectory)) {
System.err.println("Missing required parameter: output directory");

usage();

System.exit( 1 );
System.exit(1);
}

parameters.setProperty( ModelloParameterConstants.OUTPUT_DIRECTORY, outputDirectory );
parameters.setProperty(ModelloParameterConstants.OUTPUT_DIRECTORY, outputDirectory);

String modelVersion = args[ 3 ];
String modelVersion = args[3];

if ( StringUtils.isEmpty( modelVersion ) )
{
System.err.println( "Missing required parameter: model version" );
if (StringUtils.isEmpty(modelVersion)) {
System.err.println("Missing required parameter: model version");

usage();

System.exit( 1 );
System.exit(1);
}

parameters.setProperty( ModelloParameterConstants.VERSION, modelVersion );
parameters.setProperty(ModelloParameterConstants.VERSION, modelVersion);

String packageWithVersion = args[ 4 ];
String packageWithVersion = args[4];

if ( StringUtils.isEmpty( packageWithVersion ) )
{
System.err.println( "Missing required parameter: package with version" );
if (StringUtils.isEmpty(packageWithVersion)) {
System.err.println("Missing required parameter: package with version");

usage();

System.exit( 1 );
System.exit(1);
}

parameters.setProperty( ModelloParameterConstants.PACKAGE_WITH_VERSION, packageWithVersion );
parameters.setProperty(ModelloParameterConstants.PACKAGE_WITH_VERSION, packageWithVersion);

String javaSource = args[ 5 ];
String javaSource = args[5];

if ( StringUtils.isEmpty( javaSource ) )
{
System.err.println( "Missing required parameter: Java Source" );
if (StringUtils.isEmpty(javaSource)) {
System.err.println("Missing required parameter: Java Source");

usage();

System.exit( 1 );
System.exit(1);
}

parameters.setProperty( ModelloParameterConstants.OUTPUT_JAVA_SOURCE, javaSource );
parameters.setProperty(ModelloParameterConstants.OUTPUT_JAVA_SOURCE, javaSource);

if ( args.length > 6 )
{
parameters.setProperty( ModelloParameterConstants.ENCODING, args[6] );
if (args.length > 6) {
parameters.setProperty(ModelloParameterConstants.ENCODING, args[6]);
}
}

// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

private static void usage()
{
System.err.println( "Usage: modello <model> <outputType> <output directory> <modelVersion> <packageWithVersion>"
+ "<javaSource> [<encoding>]" );
private static void usage() {
System.err.println("Usage: modello <model> <outputType> <output directory> <modelVersion> <packageWithVersion>"
+ "<javaSource> [<encoding>]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class ModelloException
extends Exception
{
public class ModelloException extends Exception {
private static final long serialVersionUID = -8746896773615188345L;

public ModelloException( String msg )
{
super( msg );
public ModelloException(String msg) {
super(msg);
}

public ModelloException( String msg, Throwable cause )
{
super( msg, cause );
public ModelloException(String msg, Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class ModelloParameterConstants
{
public class ModelloParameterConstants {
public static final String VERSION = "modello.version";

public static final String OUTPUT_DIRECTORY = "modello.output.directory";
Expand All @@ -47,7 +46,7 @@ public class ModelloParameterConstants
public static final String ENCODING = "modello.output.encoding";

/**
* Replaces USE_JAVA5
* Replaces USE_JAVA5
* @since 2.0
*/
public static final String OUTPUT_JAVA_SOURCE = "modello.output.java.source";
Expand Down Expand Up @@ -78,7 +77,6 @@ public class ModelloParameterConstants
* @since 2.1
*/
public static final String XSD_ENFORCE_MANDATORY_ELEMENTS = "modello.xsd.enforce.mandatory.element";
private ModelloParameterConstants()
{
}

private ModelloParameterConstants() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class ModelloRuntimeException
extends RuntimeException
{
public class ModelloRuntimeException extends RuntimeException {
private static final long serialVersionUID = -637783066384319780L;

public ModelloRuntimeException( String msg )
{
super( msg );
public ModelloRuntimeException(String msg) {
super(msg);
}

public ModelloRuntimeException( String msg, Throwable cause )
{
super( msg, cause );
public ModelloRuntimeException(String msg, Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,27 @@
* SOFTWARE.
*/

import java.io.Reader;
import java.io.Writer;

import org.codehaus.modello.ModelloException;
import org.codehaus.modello.model.Model;
import org.codehaus.modello.model.ModelValidationException;
import org.codehaus.plexus.logging.AbstractLogEnabled;

import java.io.Reader;
import java.io.Writer;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public abstract class AbstractModelloCore
extends AbstractLogEnabled
implements ModelloCore
{
public abstract class AbstractModelloCore extends AbstractLogEnabled implements ModelloCore {
// ----------------------------------------------------------------------
// Partial ModelloCore implementation
// ----------------------------------------------------------------------

public Model input( Reader reader )
throws ModelloException, ModelValidationException
{
return loadModel( reader );
public Model input(Reader reader) throws ModelloException, ModelValidationException {
return loadModel(reader);
}

public void output( Model model, Writer writer )
throws ModelloException
{
saveModel( model, writer );
public void output(Model model, Writer writer) throws ModelloException {
saveModel(model, writer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,27 @@
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
@Component( role = GeneratorPluginManager.class )
public class DefaultGeneratorPluginManager
extends AbstractPluginManager<ModelloGenerator>
implements GeneratorPluginManager
{
@Component(role = GeneratorPluginManager.class)
public class DefaultGeneratorPluginManager extends AbstractPluginManager<ModelloGenerator>
implements GeneratorPluginManager {
@Requirement
private Map<String, ModelloGenerator> plugins;

public Map<String, ModelloGenerator> getPlugins()
{
public Map<String, ModelloGenerator> getPlugins() {
return plugins;
}

public ModelloGenerator getGeneratorPlugin( String generatorId )
{
ModelloGenerator generator = getPlugin( generatorId );
public ModelloGenerator getGeneratorPlugin(String generatorId) {
ModelloGenerator generator = getPlugin(generatorId);

if ( generator == null )
{
throw new ModelloRuntimeException( "No such generator plugin: '" + generatorId + "'." );
if (generator == null) {
throw new ModelloRuntimeException("No such generator plugin: '" + generatorId + "'.");
}

return generator;
}

public boolean hasGeneratorPlugin( String generatorId )
{
return hasPlugin( generatorId );
public boolean hasGeneratorPlugin(String generatorId) {
return hasPlugin(generatorId);
}
}
Loading

0 comments on commit 0e3c0b1

Please sign in to comment.