/* * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.annotations.Beta; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; /** * A {@link AbstractStatementSupport} specialized for global interning. This base class is useful when the argument can * be reasonably interned and it dominates the {@link EffectiveStatement} implementation. Typical examples include * {@code position} and {@code value} statements, which typically do not have substatements and are based on simple * types. * *
* Note: use of this base class implies context-independence.
*/
@Beta
public abstract class AbstractInternedStatementSupport,
E extends EffectiveStatement> extends AbstractStatementSupport {
private final LoadingCache declaredCache = CacheBuilder.newBuilder().weakValues()
.build(new CacheLoader() {
@Override
public D load(final A key) {
return createEmptyDeclared(key);
}
});
private final LoadingCache