IProperty (@NotNull String key, @NotNull String value, @NotNull PropertyKeyValueFormat format) { final XmlTag entry = createPropertyTag(key, value); synchronized (myLock) { ensurePropertiesLoaded(); if (myAlphaSorted) { final XmlProperty dummyProperty = new XmlProperty(entry, this); final int insertIndex = Collections.binarySearch(myProperties, dummyProperty, (p1, p2) -> { final String k1 = p1.getKey(); final String k2 = p2.getKey(); return k1.compareTo(k2); }); final IProperty insertPosition; final IProperty inserted; if (insertIndex == -1) { inserted = addPropertyAfter(key, value, null, false); myProperties.add(0, inserted); } else { final int position = insertIndex < 0 ? -insertIndex - 2 : insertIndex; insertPosition = myProperties.get(position); inserted = addPropertyAfter(key, value, insertPosition, false); myProperties.add(position + 1, inserted); } return inserted; } else { return addPropertyAfter(key, value, null, true); } } }