import com.google.common.cache.LoadingCache;
import org.opendaylight.yangtools.yang.common.QName;
-public class QNameFactory {
+public final class QNameFactory {
private static final int MAX_QNAME_CACHE_SIZE = 10000;
- private static final LoadingCache<String, QName> CACHE = CacheBuilder.newBuilder()
- .maximumSize(MAX_QNAME_CACHE_SIZE)
- .softValues()
- .build(
- new CacheLoader<String, QName>() {
+ private QNameFactory() {
+ }
+
+ private static final LoadingCache<String, QName> CACHE = CacheBuilder.newBuilder().maximumSize(MAX_QNAME_CACHE_SIZE)
+ .softValues().build(new CacheLoader<String, QName>() {
@Override
public QName load(String key) {
return QName.create(key);
}
- }
- );
-
+ });
public static QName create(String name) {
return CACHE.getUnchecked(name);
return codedStringMap.get(input.readInt());
} else if (valueType == TokenTypes.IS_STRING_VALUE) {
String value = input.readUTF().intern();
- codedStringMap.put(Integer.valueOf(codedStringMap.size()), value);
+ codedStringMap.put(codedStringMap.size(), value);
return value;
}
return readObjSet();
case ValueTypes.BOOL_TYPE :
- return Boolean.valueOf(input.readBoolean());
+ return input.readBoolean();
case ValueTypes.BYTE_TYPE :
- return Byte.valueOf(input.readByte());
+ return input.readByte();
case ValueTypes.INT_TYPE :
- return Integer.valueOf(input.readInt());
+ return input.readInt();
case ValueTypes.LONG_TYPE :
- return Long.valueOf(input.readLong());
+ return input.readLong();
case ValueTypes.QNAME_TYPE :
return readQName();
case ValueTypes.SHORT_TYPE :
- return Short.valueOf(input.readShort());
+ return input.readShort();
case ValueTypes.STRING_TYPE :
return input.readUTF();
public static final ThreadLocal<NormalizedNodeDataOutput> REUSABLE_WRITER_TL = new ThreadLocal<>();
public static final ThreadLocal<NormalizedNodeDataInput> REUSABLE_READER_TL = new ThreadLocal<>();
+ private SerializationUtils() {
+ }
+
public interface Applier<T> {
void apply(T instance, YangInstanceIdentifier path, NormalizedNode<?, ?> node);
}
static {
final Builder<Class<?>, Byte> b = ImmutableMap.builder();
- b.put(String.class, Byte.valueOf(STRING_TYPE));
- b.put(Byte.class, Byte.valueOf(BYTE_TYPE));
- b.put(Integer.class, Byte.valueOf(INT_TYPE));
- b.put(Long.class, Byte.valueOf(LONG_TYPE));
- b.put(Boolean.class, Byte.valueOf(BOOL_TYPE));
- b.put(QName.class, Byte.valueOf(QNAME_TYPE));
- b.put(Short.class, Byte.valueOf(SHORT_TYPE));
- b.put(BigInteger.class, Byte.valueOf(BIG_INTEGER_TYPE));
- b.put(BigDecimal.class, Byte.valueOf(BIG_DECIMAL_TYPE));
- b.put(byte[].class, Byte.valueOf(BINARY_TYPE));
+ b.put(String.class, STRING_TYPE);
+ b.put(Byte.class, BYTE_TYPE);
+ b.put(Integer.class, INT_TYPE);
+ b.put(Long.class, LONG_TYPE);
+ b.put(Boolean.class, BOOL_TYPE);
+ b.put(QName.class, QNAME_TYPE);
+ b.put(Short.class, SHORT_TYPE);
+ b.put(BigInteger.class, BIG_INTEGER_TYPE);
+ b.put(BigDecimal.class, BIG_DECIMAL_TYPE);
+ b.put(byte[].class, BINARY_TYPE);
TYPES = b.build();
}
import com.google.common.base.Preconditions;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import java.io.IOException;
import java.io.ObjectOutputStream;
id = SLICER_ID_COUNTER.getAndIncrement();
this.logContext = builder.logContext + "_slicer-id-" + id;
- CacheBuilder<Identifier, SlicedMessageState<ActorRef>> cacheBuilder = CacheBuilder.newBuilder().removalListener(
- (RemovalListener<Identifier, SlicedMessageState<ActorRef>>) notification -> stateRemoved(notification));
+ CacheBuilder<Identifier, SlicedMessageState<ActorRef>> cacheBuilder =
+ CacheBuilder.newBuilder().removalListener(notification -> stateRemoved(notification));
if (builder.expireStateAfterInactivityDuration > 0) {
cacheBuilder = cacheBuilder.expireAfterAccess(builder.expireStateAfterInactivityDuration,
builder.expireStateAfterInactivityUnit);
}
-
stateCache = cacheBuilder.build();
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
private Collection<File> getSnapshotFiles(final String persistenceId) {
String encodedPersistenceId = encode(persistenceId);
- File[] files = snapshotDir.listFiles((FilenameFilter) (dir, name) -> {
+ File[] files = snapshotDir.listFiles((dir, name) -> {
int persistenceIdEndIndex = name.lastIndexOf('-', name.lastIndexOf('-') - 1);
return PERSISTENCE_ID_START_INDEX + encodedPersistenceId.length() == persistenceIdEndIndex
&& name.startsWith(encodedPersistenceId, PERSISTENCE_ID_START_INDEX) && !name.endsWith(".tmp");