本文整理匯總了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");
}