Example usage for com.google.common.base Verify verifyNotNull

List of usage examples for com.google.common.base Verify verifyNotNull

Introduction

In this page you can find the example usage for com.google.common.base Verify verifyNotNull.

Prototype

public static <T> T verifyNotNull(@Nullable T reference, @Nullable String errorMessageTemplate,
        @Nullable Object... errorMessageArgs) 

Source Link

Document

Ensures that reference is non-null, throwing a VerifyException with a custom message otherwise.

Usage

From source file:org.opendaylight.yangtools.yang.data.codec.xml.SchemaAwareXMLStreamWriterUtils.java

@Override
TypeDefinition<?> getBaseTypeForLeafRef(final SchemaNode schemaNode, final LeafrefTypeDefinition type) {
    final TypeDefinition<?> ret = SchemaContextUtil.getBaseTypeForLeafRef(type, schemaContext, schemaNode);
    return Verify.verifyNotNull(ret, "Unable to find base type for leafref node '%s'.", schemaNode.getPath());
}

From source file:org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshotMetadata.java

final Object writeReplace() {
    return Verify.verifyNotNull(externalizableProxy(), "Null externalizable proxy from %s", getClass());
}

From source file:org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase.java

/**
 * Constructor./*w  ww  .  j a  va 2  s.c o  m*/
 *
 * @param ctx
 *            context of statement.
 */
protected DeclaredEffectiveStatementBase(StmtContext<A, D, ?> ctx) {
    super(ctx);

    this.argument = ctx.getStatementArgument();
    this.statementSource = ctx.getStatementSource();

    /*
     * Share original instance of declared statement between all effective
     * statements which have been copied or derived from this original
     * declared statement.
     */
    @SuppressWarnings("unchecked")
    final StatementContextBase<A, D, ?> originalCtx = (StatementContextBase<A, D, ?>) ctx.getOriginalCtx();
    if (originalCtx != null) {
        ctx = originalCtx;
    }
    declaredInstance = Verify.verifyNotNull(ctx.buildDeclared(),
            "Statement %s failed to build declared statement", ctx);
}

From source file:org.opendaylight.yangtools.yang.parser.stmt.rfc6020.StmtNamespaceContext.java

private String localNamespaceURI() {
    if (localNamespaceURI == null) {
        localNamespaceURI = Verify.verifyNotNull(
                ctx.getPublicDefinition().getStatementName().getNamespace().toString(),
                "Local namespace URI not found in %s", ctx);
    }/*  w ww.j a v a  2 s .  c om*/
    return localNamespaceURI;
}

From source file:org.opendaylight.controller.cluster.datastore.persisted.AbstractVersionedShardDataTreeSnapshot.java

@Override
public final Optional<NormalizedNode<?, ?>> getRootNode() {
    return Optional
            .of(Verify.verifyNotNull(rootNode(), "Snapshot %s returned non-present root node", getClass()));
}

From source file:com.iblsoft.iwxxm.webservice.validator.XmlCatalogResolver.java

@Override
public String resolveIdentifier(XMLResourceIdentifier xmlResourceIdentifier) throws IOException, XNIException {
    if (xmlResourceIdentifier == null || !(xmlResourceIdentifier instanceof XSDDescription)
            || xmlResourceIdentifier.getNamespace() == null) {
        return super.resolveIdentifier(xmlResourceIdentifier);
    }/*from  w  w  w.j a  v a 2s.  c  om*/
    XSDDescription desc = (XSDDescription) xmlResourceIdentifier;
    String id = super.resolveIdentifier(xmlResourceIdentifier);

    String expandedSystemId = id;
    if (expandedSystemId == null) {
        expandedSystemId = xmlResourceIdentifier.getExpandedSystemId();
    }

    Verify.verifyNotNull(expandedSystemId,
            "Identifier %s is not resolved, check if xsi:schemaLocation and xmlns:xsi attributes are correctly defined.",
            desc.getNamespace());
    if (!expandedSystemId.startsWith("file:")) {
        Log.INSTANCE.warn("Identifier {} is not resolved to local path (resolved to {})",
                desc.getTargetNamespace(), expandedSystemId);
        if (!allowRemoteResources) {
            throw new VerifyException(String.format(
                    "Identifier %s is not resolved to local path (resolved to %s). Only resources stored in local catalog are enbaled.",
                    desc.getNamespace(), expandedSystemId));
        }
    }

    if (Log.INSTANCE.isDebugEnabled()) {
        Log.INSTANCE.debug("Resolved identifier: namespace: {} publicId={] systemId={} to {}",
                xmlResourceIdentifier.getNamespace(), desc.getPublicId(), desc.getLiteralSystemId(),
                expandedSystemId);
    }
    return id;
}

From source file:com.google.devtools.build.lib.analysis.TargetContext.java

/**
 * Returns the prerequisite with the given label and configuration. Throws a RuntimeException if
 * no such prerequisite exists./* w w  w .jav a  2s .c  o  m*/
 */
TransitiveInfoCollection findDirectPrerequisite(Label label, BuildConfiguration config) {
    return Verify.verifyNotNull(maybeFindDirectPrerequisite(label, config),
            "Could not find prerequisite %s in the expected configuration", label);
}

From source file:org.opendaylight.protocol.bgp.rib.impl.RIBSupportContextImpl.java

@Override
public void createEmptyTableStructure(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId) {
    final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes
            .mapEntryBuilder();/*from   w  w  w  .  j a v a  2  s  . c  o  m*/
    tb.withNodeIdentifier((NodeIdentifierWithPredicates) tableId.getLastPathArgument());
    tb.withChild(EMPTY_TABLE_ATTRIBUTES);

    // tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
    final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) tableId.getLastPathArgument();
    for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
        tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
    }

    final ChoiceNode routes = this.ribSupport.emptyRoutes();
    Verify.verifyNotNull(routes, "Null empty routes in %s", this.ribSupport);
    Verify.verify(Routes.QNAME.equals(routes.getNodeType()),
            "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);

    tx.put(LogicalDatastoreType.OPERATIONAL, tableId, tb.withChild(routes).build());
}

From source file:org.opendaylight.yangtools.yang.data.impl.schema.tree.AbstractModifiedNodeBasedCandidateNode.java

@Override
@Nonnull//from  w w  w.  j a  v a2s .c o m
public ModificationType getModificationType() {
    return Verify.verifyNotNull(mod.getModificationType(), "Node %s does not have resolved modification type",
            mod);
}

From source file:com.lyndir.lhunath.opal.security.ACL.java

/**
 * The subject's permission is either the one set for him through {@link #setSubjectPermission(Subject, Permission)} or the default
 * permission/*ww w  .  j  a  v  a 2 s. co m*/
 * of
 * this ACL.
 *
 * @param subject The subject whose permission to look up. {@code null} represents an anonymous subject.
 *
 * @return The permission granted to the given subject by this access control.
 */
public Permission getSubjectPermission(final Subject subject) {

    if (isSubjectPermissionDefault(subject))
        return getDefaultPermission();

    return Verify.verifyNotNull(subjectPermissions.get(subject), "Permission for %s is unset.", subject);
}