Example usage for java.util LinkedHashMap LinkedHashMap

List of usage examples for java.util LinkedHashMap LinkedHashMap

Introduction

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

Prototype

public LinkedHashMap() 

Source Link

Document

Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

Usage

From source file:com.hp.alm.ali.idea.translate.filter.MultipleItemsTranslatedResolver.java

@Override
public String resolveDisplayValue(String value, final ValueCallback onValue) {
    final Map<String, String> map = new LinkedHashMap<String, String>();
    final String[] split = value.split(";");
    synchronized (map) { // avoid unstable tests by enforcing order
        for (final String idStr : split) {
            if (NO_VALUE.equals(idStr)) {
                setValue(split, map, idStr, NO_VALUE_DESC, onValue);
                continue;
            }//from   ww w  .j  a  va 2  s . c  o m
            String result = translator.translate(idStr, new ValueCallback() {
                @Override
                public void value(String value) {
                    setValue(split, map, idStr, value, onValue);
                }
            });
            if (result != null) {
                setValue(split, map, idStr, result, onValue);
            }
        }
        String resolvedValue;
        if (map.size() == split.length) {
            resolvedValue = resolve(split, map);
        } else {
            resolvedValue = "Loading...";
        }
        onValue.value(resolvedValue);
        return resolvedValue;
    }
}

From source file:com.kzk.stsm.business.entities.repositories.VarietyRepository.java

public VarietyRepository() {

    super();/*  w  w w .j a  v a  2 s  .c  om*/

    this.varietiesById = new LinkedHashMap<Integer, Variety>();

    final Variety var1 = new Variety();
    var1.setId(Integer.valueOf(1));
    var1.setName("Thymus vulgaris");
    this.varietiesById.put(var1.getId(), var1);

    final Variety var2 = new Variety();
    var2.setId(Integer.valueOf(2));
    var2.setName("Thymus x citriodorus");
    this.varietiesById.put(var2.getId(), var2);

    final Variety var3 = new Variety();
    var3.setId(Integer.valueOf(3));
    var3.setName("Thymus herba-barona");
    this.varietiesById.put(var3.getId(), var3);

    final Variety var4 = new Variety();
    var4.setId(Integer.valueOf(4));
    var4.setName("Thymus pseudolaginosus");
    this.varietiesById.put(var4.getId(), var4);

    final Variety var5 = new Variety();
    var5.setId(Integer.valueOf(5));
    var5.setName("Thymus serpyllum");
    this.varietiesById.put(var5.getId(), var5);

}

From source file:Main.java

public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map, boolean decesnding) {
    int s2 = 1;/*  w w  w  . j  a  v a2s. c  om*/
    if (decesnding)
        s2 = -1;
    final int sign = s2;

    List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());

    Collections.sort(list, new Comparator<Map.Entry<K, V>>() {

        @Override
        public int compare(Entry<K, V> o1, Entry<K, V> o2) {
            return sign * o1.getValue().compareTo(o2.getValue());
        }
    });

    Map<K, V> sorted = new LinkedHashMap<>();
    for (Map.Entry<K, V> entry : list) {
        sorted.put(entry.getKey(), entry.getValue());
    }

    return sorted;
}

From source file:com.opengamma.analytics.financial.provider.curve.CurveBuildingBlock.java

/**
 * Constructor from a map. A new map is created.
 * @param block The curve block. Not null.
 *//*  ww w . j  av a  2  s .  c  o m*/
public CurveBuildingBlock(final LinkedHashMap<String, Pair<Integer, Integer>> block) {
    ArgumentChecker.notNull(block, "Curve building block");
    _unit = new LinkedHashMap<>();
    _unit.putAll(block);
}

From source file:cherry.foundation.type.EnumCodeUtil.java

public static <C, E extends Code<C>> Map<C, E> getMap(Class<E> type) {
    checkArgument(type.getEnumConstants() != null, "%s does not represent an enum type.", type.getSimpleName());
    Map<C, E> map = new LinkedHashMap<>();
    for (E e : type.getEnumConstants()) {
        map.put(e.code(), e);//from  ww w.j ava2  s  .  c o  m
    }
    return map;
}

From source file:org.terasoluna.tourreservation.app.searchtour.DepYearCodeList.java

@Override
public Map<String, String> asMap() {
    DateTime dateTime = dateFactory.newDateTime();
    DateTime nextYearDateTime = dateTime.plusYears(1);

    Map<String, String> depYearMap = new LinkedHashMap<String, String>();

    String thisYear = dateTime.toString("Y");
    String nextYear = nextYearDateTime.toString("Y");
    depYearMap.put(thisYear, thisYear);//from   ww w  .ja v a  2  s.  c o m
    depYearMap.put(nextYear, nextYear);

    return Collections.unmodifiableMap(depYearMap);
}

From source file:net.landora.animeinfo.anidb.AniDBCommand.java

public AniDBCommand(String command, boolean usesSessions) {
    this.command = command;
    this.usesSessions = usesSessions;

    arguments = new LinkedHashMap<String, String>();
}

From source file:controllers.FeatureController.java

@ModelAttribute
public void setInfo(Map<String, Object> model) {
    Map<String, Object> cmgRes = new LinkedHashMap();
    cmgRes.put("", "? ");
    for (Long l : featureService.getCmgs()) {
        if (l != null) {
            cmgRes.put(StringAdapter.getString(l), l);
        } else {/* w w w . j a v  a  2s. co  m*/
            cmgRes.put("0", "? ");
        }
    }
    model.put("cmgDict", cmgRes);
    Map<String, Object> ccoRes = new LinkedHashMap();
    ccoRes.put("", "? ");
    for (CarCompletionOption cco : featureService.getCcos()) {
        if (cco != null) {
            ccoRes.put(StringAdapter.getString(cco.getOldId()), cco.getTitle());
        } else {
            ccoRes.put("0", "? ");
        }
    }
    model.put("ccoDict", ccoRes);
}

From source file:com.app.model.m3.M3ConfigModel.java

public M3ConfigModel(int custId, int envId) {
    super();//w w w .j av  a2 s  .  com
    this.listUnderConfigSelect = new LinkedHashMap<String, M3ConfigurationInfo>();
    entity = new XMLEntityModel("environnment");
    entity.setIdLink(custId);
    entity.loadData(envId);
}

From source file:com.turt2live.xmail.api.Attachments.java

/**
 * Attempts to get an attachment from a JSON string. This will throw an IllegalArgumentException if
 * the json string is null or invalid.//w  ww.ja  v a  2  s  . com
 *
 * @param json the JSON string
 *
 * @return the attachment, or an UnknownAttachment if no match
 */
@SuppressWarnings("unchecked")
public static Attachment getAttachment(String json) {
    if (json == null) {
        throw new IllegalArgumentException();
    }
    JSONParser parser = new JSONParser();
    ContainerFactory containerFactory = new ContainerFactory() {
        @Override
        public List<Object> creatArrayContainer() {
            return new LinkedList<Object>();
        }

        @Override
        public Map<String, Object> createObjectContainer() {
            return new LinkedHashMap<String, Object>();
        }

    };

    Map<String, Object> map = new HashMap<String, Object>();

    try {
        Map<?, ?> json1 = (Map<?, ?>) parser.parse(json, containerFactory);
        Iterator<?> iter = json1.entrySet().iterator();

        // Type check
        while (iter.hasNext()) {
            Entry<?, ?> entry = (Entry<?, ?>) iter.next();
            if (!(entry.getKey() instanceof String)) {
                throw new IllegalArgumentException("Not in <String, Object> format");
            }
        }

        map = (Map<String, Object>) json1;
    } catch (ParseException e) {
        e.printStackTrace();
        return null;
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        return null;
    }
    XMail plugin = XMail.getInstance();
    Attachment a = plugin.getMailServer().attemptAttachmentDecode(map);
    if (a != null) {
        return a;
    }
    a = plugin.getAttachmentHandlerRegistry().getAttachmentFromHandler(json);
    return a == null ? new UnknownAttachment(json) : a;
}