本文整理汇总了Java中java.util.EnumMap.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java EnumMap.entrySet方法的具体用法?Java EnumMap.entrySet怎么用?Java EnumMap.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.EnumMap
的用法示例。
在下文中一共展示了EnumMap.entrySet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.util.EnumMap; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class);
for (TestEnum e : TestEnum.values()) {
enumMap.put(e, e.name());
}
Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet();
HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet);
if (false == hashSet.equals(entrySet)) {
throw new RuntimeException("Test FAILED: Sets are not equal.");
}
if (hashSet.hashCode() != entrySet.hashCode()) {
throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");
}
}
示例2: createResolvedMetaData
import java.util.EnumMap; //导入方法依赖的package包/类
private DefaultLibraryLocalComponentMetadata createResolvedMetaData(BinarySpecInternal selectedBinary, String projectPath, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, EnumMap<UsageKind, List<PublishArtifact>> artifacts) {
DefaultLibraryLocalComponentMetadata metadata = newResolvedLibraryMetadata(selectedBinary.getId(), toStringMap(dependenciesPerUsage), projectPath);
for (Map.Entry<UsageKind, List<PublishArtifact>> entry : artifacts.entrySet()) {
UsageKind usage = entry.getKey();
List<PublishArtifact> publishArtifacts = entry.getValue();
metadata.addArtifacts(usage.getConfigurationName(), publishArtifacts);
}
return metadata;
}
示例3: toStringMap
import java.util.EnumMap; //导入方法依赖的package包/类
private <T> Map<String, T> toStringMap(EnumMap<? extends Enum<UsageKind>, T> enumMap) {
Map<String, T> map = new HashMap<String, T>(enumMap.size());
for (Map.Entry<? extends Enum<UsageKind>, T> tEntry : enumMap.entrySet()) {
UsageKind usageKind = UsageKind.valueOf(tEntry.getKey().name());
map.put(usageKind.getConfigurationName(), tEntry.getValue());
}
return map;
}
示例4: copyOfEnumMap
import java.util.EnumMap; //导入方法依赖的package包/类
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
Map<K, ? extends V> original) {
EnumMap<K, V> copy = new EnumMap<K, V>(original);
for (Map.Entry<?, ?> entry : copy.entrySet()) {
checkEntryNotNull(entry.getKey(), entry.getValue());
}
return ImmutableEnumMap.asImmutable(copy);
}
示例5: removeFishToken
import java.util.EnumMap; //导入方法依赖的package包/类
public void removeFishToken(EnumMap<FishTokenType, Integer> fishTokenToRemove) {
for (EnumMap.Entry<FishTokenType, Integer> entry : fishTokenToRemove.entrySet()) {
int newCount = fishTokenHand.get(entry.getKey()) - entry.getValue();
if (newCount < 0) {
throw new RuntimeException("FishToken count is below 0");
}
fishTokenHand.put(entry.getKey(), newCount);
}
}
示例6: copyOfEnumMap
import java.util.EnumMap; //导入方法依赖的package包/类
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
EnumMap<K, ? extends V> original) {
EnumMap<K, V> copy = new EnumMap<>(original);
for (Map.Entry<?, ?> entry : copy.entrySet()) {
checkEntryNotNull(entry.getKey(), entry.getValue());
}
return ImmutableEnumMap.asImmutable(copy);
}
示例7: copyOfEnumMap
import java.util.EnumMap; //导入方法依赖的package包/类
private static <K extends Enum<K>, V> ImmutableMap<K, V> copyOfEnumMap(
EnumMap<K, ? extends V> original) {
EnumMap<K, V> copy = new EnumMap<K, V>(original);
for (Map.Entry<?, ?> entry : copy.entrySet()) {
checkEntryNotNull(entry.getKey(), entry.getValue());
}
return ImmutableEnumMap.asImmutable(copy);
}
示例8: ChooseMultipleResourcesWindow
import java.util.EnumMap; //导入方法依赖的package包/类
public ChooseMultipleResourcesWindow(String title, Skin skin, EnumMap<ResourceKind, Integer> cards, int number) {
super(title, skin);
widgets = new ArrayList<>();
int tableWidth = 0;
// create widget for each kind
for (Entry<ResourceKind, Integer> entry : cards.entrySet()) {
if (entry.getValue() <= 0) {continue;}
ResourceWidget widget = new ResourceWidget(entry.getKey(), skin);
widget.setMaxResource(entry.getValue());
widgets.add(widget);
add(widget).padTop(10);
tableWidth += widget.getPrefWidth() + 10;
}
// create button to confirm choice
confirm = new TextButton("confirm", skin);
confirm.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (chooseCardsListener != null && getResourceCount() == number) {
chooseCardsListener.onMapChosen(getResources());
remove();
}
}
});
// set width and height
width = tableWidth;
int tableHeight = 100;
if (widgets.size() > 0) {
tableHeight += widgets.get(0).getPrefHeight();
}
height = tableHeight;
setWidth(width);
setHeight(height);
// add confirm button
row();
add(confirm).colspan(widgets.size()).padTop(10).align(Align.right);
// set position on screen
setPosition(Gdx.graphics.getWidth() / 2 - getWidth() / 2, Gdx.graphics.getHeight() / 2 - getHeight() / 2);
// enable moving the window
setMovable(true);
}