* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
module org.opendaylight.yangtools.yang.model.spi {
+ exports org.opendaylight.yangtools.yang.model.spi.meta;
exports org.opendaylight.yangtools.yang.model.spi.type;
requires transitive org.opendaylight.yangtools.yang.model.api;
requires org.opendaylight.yangtools.yang.common;
-// requires org.opendaylight.yangtools.util;
-// requires org.slf4j;
-
// Annotations
requires static transitive org.eclipse.jdt.annotation;
-// requires static com.github.spotbugs.annotations;
}
* 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.rfc7950.stmt;
+package org.opendaylight.yangtools.yang.model.spi.meta;
+import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.model.api.meta.ModelStatement;
-abstract class AbstractModelStatement<A> implements ModelStatement<A> {
-
+/**
+ * Abstract base class for {@link ModelStatement} implementations. It mostly provides static methods for efficiently
+ * storing lists.
+ *
+ * @param <A> Argument type ({@link Empty} if statement does not have argument.)
+ */
+// FIXME: 7.0.0: hide this class if possible
+@Beta
+public abstract class AbstractModelStatement<A> implements ModelStatement<A> {
/**
* Utility method for squashing singleton lists into single objects. This is a CPU/mem trade-off, which we are
* usually willing to make: for the cost of an instanceof check we can save one object and re-create it when needed.
protected static final <T> @NonNull ImmutableList<T> unmaskList(final @NonNull Object masked,
final @NonNull Class<T> type) {
return masked instanceof ImmutableList ? (ImmutableList<T>) masked
- // Yes, this is ugly code, which could use an explicit verify, that would just change the what sort
- // of exception we throw. ClassCastException is as good as VerifyException.
- : ImmutableList.of(type.cast(masked));
+ // Yes, this is ugly code, which could use an explicit verify, that would just change the what sort
+ // of exception we throw. ClassCastException is as good as VerifyException.
+ : ImmutableList.of(type.cast(masked));
}
protected static final @NonNull Object maskSet(final ImmutableSet<?> set) {
protected static final <T> @NonNull ImmutableSet<? extends T> unmaskSet(final @NonNull Object masked,
final @NonNull Class<T> type) {
return masked instanceof ImmutableSet ? (ImmutableSet<T>) masked
- // Yes, this is ugly code, which could use an explicit verify, that would just change the what sort
- // of exception we throw. ClassCastException is as good as VerifyException.
- : ImmutableSet.of(type.cast(masked));
+ // Yes, this is ugly code, which could use an explicit verify, that would just change the what sort
+ // of exception we throw. ClassCastException is as good as VerifyException.
+ : ImmutableSet.of(type.cast(masked));
}
-
}
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.spi.meta.AbstractModelStatement;
/**
* An abstract base class for {@link DeclaredStatement} implementations. This is a direct competition to
@Beta
// FIXME: 7.0.0: we should be able to promote this to model.spi.meta package.
public abstract class AbstractDeclaredStatement<A> extends AbstractModelStatement<A> implements DeclaredStatement<A> {
- protected AbstractDeclaredStatement() {
- }
-
@Override
public StatementSource getStatementSource() {
return StatementSource.DECLARATION;