added scm-core library

This commit is contained in:
Sebastian Sdorra
2010-09-08 10:30:08 +02:00
parent 9513d731bd
commit f1619a098a
7 changed files with 26 additions and 2 deletions

View File

@@ -1,217 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "groups")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "name", "members" })
public class Group implements Serializable
{
/** Field description */
private static final long serialVersionUID = 1752369869345245872L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public Group() {}
/**
* Constructs ...
*
*
* @param name
*/
public Group(String name)
{
this.name = name;
this.members = new ArrayList<String>();
}
/**
* Constructs ...
*
*
* @param name
* @param members
*/
public Group(String name, List<String> members)
{
this.name = name;
this.members = members;
}
/**
* Constructs ...
*
*
* @param name
* @param members
*/
public Group(String name, String... members)
{
this.name = name;
this.members = new ArrayList<String>();
if (Util.isNotEmpty(members))
{
this.members.addAll(Arrays.asList(members));
}
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param member
*
* @return
*/
public boolean add(String member)
{
return members.add(member);
}
/**
* Method description
*
*/
public void clear()
{
members.clear();
}
/**
* Method description
*
*
* @param member
*
* @return
*/
public boolean remove(String member)
{
return members.remove(member);
}
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
StringBuilder msg = new StringBuilder();
msg.append(name).append(" [");
if (Util.isNotEmpty(members))
{
Iterator<String> it = members.iterator();
while (it.hasNext())
{
msg.append(it.next());
if (it.hasNext())
{
msg.append(",");
}
}
}
return msg.append("]").toString();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public List<String> getMembers()
{
return members;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param members
*/
public void setMembers(List<String> members)
{
this.members = members;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlElement(name = "members")
private List<String> members;
/** Field description */
private String name;
}

View File

@@ -1,176 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name = "repositories")
@XmlType(propOrder =
{
"type", "name", "contact", "description"
})
public class Repository implements Serializable
{
/** Field description */
private static final long serialVersionUID = 3486560714961909711L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public Repository() {}
/**
* Constructs ...
*
*
* @param type
* @param name
*/
public Repository(String type, String name)
{
this.type = type;
this.name = name;
}
/**
* Constructs ...
*
*
* @param type
* @param name
* @param contact
* @param description
*/
public Repository(String type, String name, String contact,
String description)
{
this.type = type;
this.name = name;
this.contact = contact;
this.description = description;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getContact()
{
return contact;
}
/**
* Method description
*
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public String getType()
{
return type;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param contact
*/
public void setContact(String contact)
{
this.contact = contact;
}
/**
* Method description
*
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
* Method description
*
*
* @param type
*/
public void setType(String type)
{
this.type = type;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String contact;
/** Field description */
private String description;
/** Field description */
private String name;
/** Field description */
private String type;
}

View File

@@ -1,91 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm;
/**
*
* @author Sebastian Sdorra
*/
public class RepositoryType
{
/**
* Constructs ...
*
*/
public RepositoryType() {}
/**
* Constructs ...
*
*
* @param name
* @param displayName
*/
public RepositoryType(String name, String displayName)
{
this.name = name;
this.displayName = displayName;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getDisplayName()
{
return displayName;
}
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param displayName
*/
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
/**
* Method description
*
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String displayName;
/** Field description */
private String name;
}

View File

@@ -1,98 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.util;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
*/
public class Util
{
/**
* Method description
*
*
* @param value
*
* @return
*/
public static boolean isEmpty(String value)
{
return (value == null) || (value.trim().length() == 0);
}
/**
* Method description
*
*
* @param collection
*
* @return
*/
public static boolean isEmpty(Collection<?> collection)
{
return (collection == null) || collection.isEmpty();
}
/**
* Method description
*
*
* @param array
*
* @return
*/
public static boolean isEmpty(Object[] array)
{
return (array == null) || (array.length == 0);
}
/**
* Method description
*
*
* @param value
*
* @return
*/
public static boolean isNotEmpty(String value)
{
return (value != null) && (value.trim().length() > 0);
}
/**
* Method description
*
*
* @param collection
*
* @return
*/
public static boolean isNotEmpty(Collection<?> collection)
{
return (collection != null) &&!collection.isEmpty();
}
/**
* Method description
*
*
* @param array
*
* @return
*/
public static boolean isNotEmpty(Object[] array)
{
return (array != null) && (array.length > 0);
}
}