All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.aipark.api.parkingarea.MapEntry Maven / Gradle / Ivy

Go to download

AIPARK offers detailed parking information for more than 1.8 Mio parking areas in Germany with nationwide coverage. Additionally, accurate occupancy predictions are derived using data from a network of more than 5 million smartphones. Use the AIPARK API Explorer application to try out and test the interface. Please send a request via email if you are a developer and require an API key. We'll be in touch with you shortly. This application is provided via a demo backend environment. Please note that API load tests do not reflect the performance of the productive system. Mail: [email protected]

There is a newer version: 30.06
Show newest version
package de.aipark.api.parkingarea;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by torgen on 27.09.17.
 */
@SuppressWarnings("unused")
public class MapEntry {
    private List> entryList;

    public MapEntry() {
        entryList = new ArrayList>();
    }


    /**
     * can be used when special SortedList is necessary, e.g. for Schedules because order is important for displaying
     */
    public MapEntry(List> entryListInstance){
        this.entryList = entryListInstance;
    }

    public Map convertToMap() {
        Map map = new HashMap();
        if (entryList != null) {
            for (Entry entry : entryList) {
                map.put(entry.key, entry.value);
            }
        }
        return map;
    }

    public static  MapEntry convertFromMap(Map map) {
        MapEntry mapEntry = new MapEntry();
        if (map != null) {
            for (Map.Entry entry : map.entrySet()) {
                mapEntry.entryList.add(new MapEntry.Entry(entry.getKey(), entry.getValue()));
            }
        }
        return mapEntry;
    }

    public List> getEntryList() {
        return entryList;
    }

    public void setEntryList(List> entryList) {
        this.entryList = entryList;
    }

    public V findValueForKey(K key) {
        for (MapEntry.Entry entry : entryList) {
            if (entry.getKey().equals(key)) {
                return entry.getValue();
            }
        }
        return null;
    }

    @Override
    public boolean equals(Object obj) {
        if (!obj.getClass().equals(MapEntry.class)) {
            return false;
        }
        MapEntry other = (MapEntry) obj;
        List otherList = other.getEntryList();
        return this.getEntryList().containsAll(otherList) && otherList.containsAll(this.entryList);
    }

    @Override
    public int hashCode() {
        return entryList.hashCode();
    }

    @Override
    public String toString() {
        return "MapEntry{" +
                "entryList=" + entryList +
                '}';
    }

    static public class Entry {
        private K key;
        private V value;

        public Entry() {
        }

        public Entry(K key, V value) {
            this.key = key;
            this.value = value;
        }

        public K getKey() {
            return key;
        }

        public void setKey(K key) {
            this.key = key;
        }

        public V getValue() {
            return value;
        }

        public void setValue(V value) {
            this.value = value;
        }

        @Override
        public boolean equals(Object obj) {
            if (!obj.getClass().equals(Entry.class)) {
                return false;
            }
            Entry other = (Entry) obj;
            if (!key.getClass().equals(other.getKey().getClass())) {
                return false;
            }
            if (!value.getClass().equals(other.getValue().getClass())) {
                return false;
            }
            return key.equals(other.getKey()) && value.equals(other.getValue());
        }

        @Override
        public int hashCode() {
            return (key + "" + value).hashCode();
        }

        @Override
        public String toString() {
            return "Entry{" +
                    "key=" + key +
                    ", value=" + value +
                    '}';
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy