All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.boot.model.source.internal.hbm.CommaSeparatedStringHelper Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * 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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy