⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pathutil.java

📁 一个hibernate的自动测试框架源码
💻 JAVA
字号:
package net.chrisrichardson.ormunit.hibernate;

import java.util.HashSet;
import java.util.Set;

/**
 * Utility methods for manipulating sets of dotted property names
 * @author cer
 *
 */
public class PathUtil {

	/**
	 * Return paths starting with the specified prefix with the prefix removed
	 * @param prefix
	 * @param propertyNames
	 * @return
	 */
	public static Set<String> getPathsStartingWith(String prefix, Set<String> propertyNames) {
		String prefixToChop = prefix + ".";
		Set<String> result = new HashSet<String>();
		for (String fieldName : propertyNames) {
			if (fieldName.startsWith(prefixToChop))
				result.add(fieldName.substring(prefixToChop.length()));
		}
		return result;
	}

	/**
	 * Return the properties that don't have sub-properties
	 * @param propertyNames
	 * @return
	 */
	public static Set<String> getPropertiesWithNonSubProps(Set<String> propertyNames) {
		Set<String> result = new HashSet<String>();
		for (String field : propertyNames) {
			int n = field.indexOf('.');
			if (n == -1)
				result.add(field);
		}
		return result;
	}

	/**
	 * Return the names of the top-level properties
	 * @param propertyNames
	 * @return
	 */
	public static Set<String> getRoots(Set<String> propertyNames) {
		Set<String> result = new HashSet<String>();
		for (String field : propertyNames) {
			int n = field.indexOf('.');
			if (n == -1)
				result.add(field);
			else
				result.add(field.substring(0, n));
	
		}
		return result;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -