com.epam.deltix.qsrv.util.json.parser.JsonPool Maven / Gradle / Ivy
/*
* Copyright 2024 EPAM Systems, Inc
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Licensed under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.epam.deltix.qsrv.util.json.parser;
import com.epam.deltix.util.collections.generated.ByteArrayList;
import com.epam.deltix.util.collections.generated.LongArrayList;
import com.epam.deltix.util.collections.generated.ObjectArrayList;
import com.epam.deltix.util.collections.generated.ObjectToObjectHashMap;
import org.apache.commons.io.output.StringBuilderWriter;
import java.util.LinkedList;
final class JsonPool {
private final LinkedList> mapsPool = new LinkedList<>();
private final LinkedList longListsPool = new LinkedList<>();
private final LinkedList> objectListsPool = new LinkedList<>();
private final LinkedList stringBuilderWritersPool = new LinkedList<>();
private final LinkedList byteListsPool = new LinkedList<>();
public ObjectToObjectHashMap getMap() {
if (mapsPool.isEmpty()) {
return new ObjectToObjectHashMap<>();
} else {
return mapsPool.pop();
}
}
public void returnToPool(ObjectToObjectHashMap map) {
map.clear();
mapsPool.add(map);
}
public LongArrayList getLongList() {
if (longListsPool.isEmpty()) {
return new LongArrayList();
} else {
return longListsPool.pop();
}
}
public void returnToPool(LongArrayList list) {
list.clear();
longListsPool.add(list);
}
public ByteArrayList getByteList() {
if (byteListsPool.isEmpty()) {
return new ByteArrayList();
} else {
return byteListsPool.pop();
}
}
public void returnToPool(ByteArrayList list) {
list.clear();
byteListsPool.add(list);
}
public ObjectArrayList
© 2015 - 2024 Weber Informatics LLC | Privacy Policy