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

📄 topology.java

📁 p2p仿真器。开发者可以工作在覆盖层中进行创造和测试逻辑算法或者创建和测试新的服务。PlanetSim还可以将仿真代码平稳转换为在Internet上的实验代码
💻 JAVA
字号:
package planet.generic.commonapi.factory;

/**
 * This class allow to the programmer specify all the topologies of the
 * networks. Actually only exists three topologies:
 * <ul>
 * <li><b>RANDOM ("Random")</b>: Where the Id of nodes are distributed randomly.</li>
 * <li><b>CIRCULAR ("Circular")</b>: Where the Id of nodes are distributed uniformly.</li>
 * <li><b>SERIALIZED ("Serialized")</b>: Where the entire ring are restored from serialized
 * state file.</li>
 * </ul>
 * @author Jordi Pujol
 * @see planet.commonapi.Id Id
 */
public class Topology {
	/**
	 * This topology specify that the Id of nodes are distributed randomly.
	 */
	public static final String RANDOM = "Random";

	/**
	 * This topology specify that the Id of nodes are distributed uniformly
	 * in the ring.
	 */
	public static final String CIRCULAR = "Circular";
	
	/**
	 * This topology specify that the entire ring are restored from serialized
	 * state file.
	 */
	public static final String SERIALIZED = "Serialized";
	
	/**
	 * Identify if the <b>topology</b> specified is valid or not.
	 * @param topology Topology to test if is valid.
	 * @return true if <b>topology</b> is valid. false in another case.
	 */
	public static boolean isValid(String topology) {
		return
            topology != null && (
			topology.equalsIgnoreCase(RANDOM)   ||
			topology.equalsIgnoreCase(CIRCULAR) ||
			topology.equalsIgnoreCase(SERIALIZED));
	}
	
	/**
	 * Inform when the specified <b>topology</b> is valid to
	 * build <b>new instances with sentence <i>new</i></b>.
	 * Actually, only the SERIALIZED topology is not valid.
	 * @param topology Topology to test.
	 * @return true if the topology is RANDOM or CIRCULAR. false
	 * in other case.
	 */
	public static boolean isValidForNew(String topology) {
		return 
			topology.equalsIgnoreCase(RANDOM) ||
			topology.equalsIgnoreCase(CIRCULAR);
	}
}

⌨️ 快捷键说明

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