Remove JSR305 annotations from yang-data-util
[yangtools.git] / yang / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / ModuleStringIdentityrefCodec.java
1 /*
2  * Copyright (c) 2016 Intel Corporation and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.util;
9
10 import static java.util.Objects.requireNonNull;
11
12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 import java.net.URI;
14 import java.util.Iterator;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19
20 public abstract class ModuleStringIdentityrefCodec extends AbstractModuleStringIdentityrefCodec {
21     // FIXME: 3.0.0: hide these fields
22     protected final SchemaContext context;
23     @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
24     protected final QNameModule parentModuleQname;
25
26     protected ModuleStringIdentityrefCodec(final @NonNull SchemaContext context,
27             final @NonNull QNameModule parentModule) {
28         this.context = requireNonNull(context);
29         this.parentModuleQname = requireNonNull(parentModule);
30     }
31
32     @Override
33     protected String prefixForNamespace(final URI namespace) {
34         final Iterator<Module> modules = context.findModules(namespace).iterator();
35         return modules.hasNext() ? modules.next().getName() : null;
36     }
37 }