
com.greenpepper.maven.plugin.Repository Maven / Gradle / Ivy
/*
* Copyright (c) 2007 Pyxis Technologies inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA,
* or see the FSF site: http://www.fsf.org.
*/
package com.greenpepper.maven.plugin;
import static com.greenpepper.util.CollectionUtil.toArray;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import com.greenpepper.repository.DocumentRepository;
/**
* Repository class.
*
* @author oaouattara
* @version $Id: $Id
*/
public class Repository
{
public final List suites;
public final List tests;
private String type;
private String root;
private String name;
private boolean isDefault;
private DocumentRepository documentRepository;
/**
* Constructor for Repository.
*/
public Repository()
{
suites = new ArrayList( );
tests = new ArrayList( );
}
/**
* addTest.
*
* @param uri a {@link java.lang.String} object.
*/
public void addTest(String uri)
{
tests.add( uri );
}
/**
* addSuite.
*
* @param uri a {@link java.lang.String} object.
*/
public void addSuite(String uri)
{
suites.add( uri );
}
/**
* Getter for the field tests
.
*
* @return an array of {@link java.lang.String} objects.
*/
public String[] getTests()
{
return toArray(tests);
}
/**
* Getter for the field suites
.
*
* @return an array of {@link java.lang.String} objects.
*/
public String[] getSuites()
{
return toArray(suites);
}
/**
* Setter for the field type
.
*
* @param type a {@link java.lang.String} object.
*/
public void setType(String type)
{
this.type = type;
}
/**
* Getter for the field type
.
*
* @return a {@link java.lang.String} object.
*/
public String getType()
{
return type;
}
/**
* Getter for the field root
.
*
* @return a {@link java.lang.String} object.
*/
public String getRoot()
{
return root;
}
/**
* Setter for the field root
.
*
* @param root a {@link java.lang.String} object.
*/
public void setRoot(String root)
{
this.root = root;
}
/**
* Getter for the field name
.
*
* @return a {@link java.lang.String} object.
*/
public String getName()
{
return name;
}
/**
* Setter for the field name
.
*
* @param name a {@link java.lang.String} object.
*/
public void setName(String name)
{
this.name = name;
}
/**
* newInstance.
*
* @return a {@link com.greenpepper.repository.DocumentRepository} object.
* @throws java.lang.Exception if any.
*/
public DocumentRepository newInstance() throws Exception {
Class> klass = Class.forName( type );
if (!DocumentRepository.class.isAssignableFrom(klass))
throw new IllegalArgumentException("Not a " + DocumentRepository.class.getName() + ": " + type );
Constructor> constructor = klass.getConstructor( String[].class );
return (DocumentRepository) constructor.newInstance( new Object[]{ new String[] { root } } );
}
/**
* Getter for the field documentRepository
.
*
* @return a {@link com.greenpepper.repository.DocumentRepository} object.
* @throws java.lang.Exception if any.
*/
public DocumentRepository getDocumentRepository() throws Exception {
if (documentRepository == null) {
documentRepository = newInstance();
}
return documentRepository;
}
/**
* isDefault.
*
* @return a boolean.
*/
public boolean isDefault() {
return isDefault;
}
/**
* setDefault.
*
* @param isDefault a boolean.
*/
public void setDefault(boolean isDefault) {
this.isDefault = isDefault;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy