public static <K1, V1> Pair<K1, V1> of(K1 first, V1 second) { return new Pair<K1, V1>(first, second); }
static public MutableDataHolder addRenderTypeEquivalence(final MutableDataHolder options, final String rendererType, final String supportedRendererType) { if (!isCompatibleRendererType(options, rendererType, supportedRendererType)) { // need to add final List<Pair<String, String>> equivalence = RENDERER_TYPE_EQUIVALENCE.getFrom(options); final ArrayList<Pair<String, String>> newEquivalence = new ArrayList<>(equivalence); newEquivalence.add(new Pair<String, String>(rendererType, supportedRendererType)); options.set(RENDERER_TYPE_EQUIVALENCE, newEquivalence); } return options; }
@Override public Pair<Integer, Integer> getLineColumnAtIndex(final int index) { int iMax = length(); if (index < 0 || index > iMax) { throw new IllegalArgumentException("Index: " + index + " out of range [0, " + iMax + "]"); } boolean hadCr = false; boolean hadEOL = true; int line = 0; int col = 0; for (int i = 0; i < index; i++) { char c1 = charAt(i); if (c1 == '\r') { col = 0; line++; hadCr = true; } else if (c1 == '\n') { if (!hadCr) { line++; } col = 0; hadCr = false; } else { col++; } } return new Pair<>(line, col); }
private Object removingValue(int index, V v) { assert !myInKeyUpdate; myInKeyUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(index, new Pair<K, V>((K)null, v)); } Object r = myKeySet.removeIndexHosted(index); myInKeyUpdate = false; return r; }
private Object removingKey(int index, K k) { assert !myInValueUpdate; myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(index, new Pair<K, V>(k, null)); } Object r = myValueSet.removeIndexHosted(index); myInValueUpdate = false; return r; }
@SuppressWarnings("unchecked") @Override public Pair<T, List<ParsedOption<T>>> parseOption(BasedSequence optionText, T options, MessageProvider provider) { if (optionText.isEmpty()) { return new Pair<T, List<ParsedOption<T>>>(setOptions(options), (List<ParsedOption<T>>)Collections.<ParsedOption<T>>singletonList(new ParsedOption(optionText, this, ParsedOptionStatus.VALID))); } else { if (provider == null) provider = MessageProvider.DEFAULT; String message = provider.message(KEY_OPTION_0_PARAMETERS_1_IGNORED, OPTION_0_PARAMETERS_1_IGNORED, myOptionName, optionText); return new Pair<T, List<ParsedOption<T>>>(setOptions(options), (List<ParsedOption<T>>)Collections.<ParsedOption<T>>singletonList(new ParsedOption(optionText, this, ParsedOptionStatus.IGNORED, Collections.singletonList(new ParserMessage(optionText, ParsedOptionStatus.IGNORED, message))))); } }
@SuppressWarnings("unchecked") private void addingKey(int index, K k, Object v) { assert !myInValueUpdate; myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.adding(index, new Pair<K, V>(k, (V) v), null); } if (v == null) myValueSet.addNulls(index); else myValueSet.add((V) v); myInValueUpdate = false; }
@SuppressWarnings("unchecked") private void addingValue(int index, V v, Object k) { assert !myInKeyUpdate; myInKeyUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.adding(index, new Pair<K, V>((K) k, v), null); } if (k == null) myKeySet.addNulls(index); else myKeySet.add((K) k); myInKeyUpdate = false; }
private boolean removeEntryIndex(int index, K k, V v) { int keyIndex = myKeySet.indexOf(k); int valueIndex = myValueSet.indexOf(v); if (keyIndex != valueIndex) { throw new IllegalStateException("keySet[" + keyIndex + "]=" + k + " and valueSet[" + valueIndex + "]=" + v + " are out of sync"); } if (index != -1 && keyIndex != index) { throw new IllegalStateException("removeEntryIndex " + index + " does not match keySet[" + keyIndex + "]=" + k + " and valueSet[" + valueIndex + "]=" + v + " are out of sync"); } if (keyIndex != -1) { myInKeyUpdate = true; myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(keyIndex, new Pair<K, V>(k, v)); } myKeySet.removeHosted(k); myValueSet.removeHosted(v); myInValueUpdate = false; myInKeyUpdate = false; return true; } return false; }
public V removeKey(Object o) { myInKeyUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { int index = myKeySet.indexOf(o); if (index != -1) { myHost.removing(index, new Pair<K, V>((K) o, myValueSet.isValidIndex(index) ? myValueSet.getValue(index) : null)); } } V r = (V) myKeySet.removeHosted(o); myInKeyUpdate = false; return r; }
public K removeValue(Object o) { myInValueUpdate = true; int index = myValueSet.indexOf(o); if (myHost != null && !myHost.skipHostUpdate()) { if (index != -1) { myHost.removing(index, new Pair<K, V>(myKeySet.isValidIndex(index) ? myKeySet.getValue(index) : null, (V) o)); } } K r = (K) myValueSet.removeHosted(o); myInValueUpdate = false; return r; }
myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.adding(myKeySet.getValueList().size(), new Pair<K, V>(k, v), null); myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.adding(valueIndex, new Pair<K, V>(k, v), null); myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.adding(keyIndex, new Pair<K, V>(k, v), null);
return new Pair<T, List<ParsedOption<T>>>(result, parsedOptions);
return new Pair<TocOptions, List<ParsedOption<TocOptions>>>(result, (List<ParsedOption<TocOptions>>)Collections.<ParsedOption<TocOptions>>singletonList(new ParsedOption(optionText, this, parserParams.status, parserParams.messages)));
static public MutableDataHolder addRenderTypeEquivalence(final MutableDataHolder options, final String rendererType, final String supportedRendererType) { if (!isCompatibleRendererType(options, rendererType, supportedRendererType)) { // need to add final List<Pair<String, String>> equivalence = RENDERER_TYPE_EQUIVALENCE.getFrom(options); final ArrayList<Pair<String, String>> newEquivalence = new ArrayList<>(equivalence); newEquivalence.add(new Pair<String, String>(rendererType, supportedRendererType)); options.set(RENDERER_TYPE_EQUIVALENCE, newEquivalence); } return options; }
private Object removingKey(int index, K k) { assert !myInValueUpdate; myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(index, new Pair<K, V>(k, null)); } Object r = myValueSet.removeIndexHosted(index); myInValueUpdate = false; return r; }
private Object removingValue(int index, V v) { assert !myInKeyUpdate; myInKeyUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(index, new Pair<K, V>((K)null, v)); } Object r = myKeySet.removeIndexHosted(index); myInKeyUpdate = false; return r; }
@SuppressWarnings("unchecked") @Override public Pair<T, List<ParsedOption<T>>> parseOption(BasedSequence optionText, T options, MessageProvider provider) { if (optionText.isEmpty()) { return new Pair<T, List<ParsedOption<T>>>(setOptions(options), (List<ParsedOption<T>>)Collections.<ParsedOption<T>>singletonList(new ParsedOption(optionText, this, ParsedOptionStatus.VALID))); } else { if (provider == null) provider = MessageProvider.DEFAULT; String message = provider.message(KEY_OPTION_0_PARAMETERS_1_IGNORED, OPTION_0_PARAMETERS_1_IGNORED, myOptionName, optionText); return new Pair<T, List<ParsedOption<T>>>(setOptions(options), (List<ParsedOption<T>>)Collections.<ParsedOption<T>>singletonList(new ParsedOption(optionText, this, ParsedOptionStatus.IGNORED, Collections.singletonList(new ParserMessage(optionText, ParsedOptionStatus.IGNORED, message))))); } }
public V removeKey(Object o) { myInKeyUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { int index = myKeySet.indexOf(o); if (index != -1) { myHost.removing(index, new Pair<K, V>((K) o, myValueSet.isValidIndex(index) ? myValueSet.getValue(index) : null)); } } V r = (V) myKeySet.removeHosted(o); myInKeyUpdate = false; return r; }