class LdapUtils {

    public static LdapName newLdapName(Name name) {
        Assert.notNull(name, "name must not be null");
        if(name instanceof LdapName) {
            return (LdapName) name.clone();
        } else if (name instanceof CompositeName) {
            CompositeName compositeName = (CompositeName) name;

            try {
                return new LdapName(convertCompositeNameToString(compositeName));
            } catch (InvalidNameException e) {
                throw convertLdapException(e);
            }
        } else {
            LdapName result = emptyLdapName();
            try {
                result.addAll(0, name);
            } catch (InvalidNameException e) {
                throw convertLdapException(e);
            }

            return result;
        }
    }

    private  LdapUtils();

}