org.hibernate.boot.model.source.internal.hbm.CommaSeparatedStringHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.boot.model.source.internal.hbm;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* @author Steve Ebersole
*/
public class CommaSeparatedStringHelper {
private CommaSeparatedStringHelper() {
}
public static Set split(String values) {
if ( values == null || values.isEmpty() ) {
return Collections.emptySet();
}
HashSet set = new HashSet();
Collections.addAll( set, values.split( "\\s*,\\s*" ) );
return set;
}
public static Set splitAndCombine(Set x, String values) {
if ( x.isEmpty() && (values == null || values.isEmpty()) ) {
return Collections.emptySet();
}
HashSet set = new HashSet();
set.addAll( x );
if ( values != null && !values.isEmpty() ) {
Collections.addAll( set, values.split( "\\s*,\\s*" ) );
}
return set;
}
}