Example usage for java.util Map.Entry Map.Entry

List of usage examples for java.util Map.Entry Map.Entry

Introduction

In this page you can find the example usage for java.util Map.Entry Map.Entry.

Prototype

Map.Entry

Source Link

Usage

From source file:jetbrains.exodus.env.Reflect.java

public void spaceInfoFromUtilization() {
    spaceInfo(new Iterable<Map.Entry<Long, Long>>() {
        private final long[] addresses = env.getLog().getAllFileAddresses();

        @Override/*from  w  w  w  .ja  v  a 2s  .com*/
        public Iterator<Map.Entry<Long, Long>> iterator() {
            return new Iterator<Map.Entry<Long, Long>>() {
                private int i = addresses.length - 1;

                @Override
                public boolean hasNext() {
                    return i >= 0;
                }

                @Override
                public Map.Entry<Long, Long> next() {
                    final long key = addresses[i--];
                    final long fileFreeBytes = env.getGC().getFileFreeBytes(key);
                    final Long value = fileFreeBytes == Long.MAX_VALUE ? null
                            : log.getFileSize(key) - fileFreeBytes;
                    return new Map.Entry<Long, Long>() {
                        @Override
                        public Long getKey() {
                            return key;
                        }

                        @Override
                        public Long getValue() {
                            return value;
                        }

                        @Override
                        public Long setValue(Long value) {
                            throw new UnsupportedOperationException();
                        }
                    };
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    });
}

From source file:org.jboss.dashboard.workspace.PanelInstance.java

public Map<String, String> getTitle() {
    LocaleManager localeManager = LocaleManager.lookup();
    final String[] langs = localeManager.getPlatformAvailableLangs();
    Map<String, String> title = new AbstractMap<String, String>() {
        public Set<Entry<String, String>> entrySet() {
            return new AbstractSet<Entry<String, String>>() {
                public int size() {
                    return langs.length;
                }/*from ww w  . j  ava 2s. co  m*/

                public Iterator<Map.Entry<String, String>> iterator() {
                    return new Iterator<Map.Entry<String, String>>() {
                        int i = 0;

                        public void remove() {
                            throw new UnsupportedOperationException();
                        }

                        public boolean hasNext() {
                            return i < langs.length;
                        }

                        public Map.Entry<String, String> next() {
                            i++;
                            return new Map.Entry<String, String>() {
                                int index = i - 1;

                                public String getKey() {
                                    return langs[index];
                                }

                                public String getValue() {
                                    return getParameterValue(PARAMETER_TITLE, langs[index]);
                                }

                                public String setValue(String value) {
                                    throw new UnsupportedOperationException();
                                }
                            };
                        }
                    };
                }
            };
        }
    };
    return title;
}