本文整理汇总了Java中java.awt.datatransfer.DataFlavor.hashCode方法的典型用法代码示例。如果您正苦于以下问题:Java DataFlavor.hashCode方法的具体用法?Java DataFlavor.hashCode怎么用?Java DataFlavor.hashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.DataFlavor
的用法示例。
在下文中一共展示了DataFlavor.hashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEqualsHashCodeConsistency
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
private static void testEqualsHashCodeConsistency() {
for (DataFlavor flavor1 : dataFlavors) {
for (DataFlavor flavor2 : dataFlavors) {
if ((flavor1.equals(flavor2) && flavor1.hashCode() != flavor2.hashCode())) {
throw new RuntimeException(
String.format("Equals and hash code not consistent for %s and %s", flavor1, flavor2));
}
}
}
}
示例2: main
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
boolean passed = true;
try {
df1 = new DataFlavor( "application/postscript" );
df2 = new DataFlavor( "application/*" );
} catch (ClassNotFoundException e1) {
throw new RuntimeException("Could not create DataFlavors. This should never happen.");
} catch (IllegalArgumentException e2) {
passed = false;
}
if (df1.hashCode() != df2.hashCode()) {
passed = false;
}
dim1 = new Dimension(3, 18);
dim2 = new Dimension(3, 18);
if (dim1.hashCode() != dim2.hashCode()) {
passed = false;
}
insets1 = new Insets(3, 4, 7, 11);
insets2 = new Insets(3, 4, 7, 11);
if (insets1.hashCode() != insets2.hashCode()) {
passed = false;
}
cm1 = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
ColorModelBits, true, true,
Transparency.OPAQUE, 0);
cm2 = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
ColorModelBits, true, true,
Transparency.OPAQUE, 0);
if (cm1.hashCode() != cm2.hashCode()) {
passed = false;
}
if (!passed)
throw new RuntimeException("Test FAILED");
}