*/
package org.opendaylight.controller.md.sal.dom.api;
+import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import java.util.Objects;
import javax.annotation.Nonnull;
* contexts concurrently.
*/
public abstract class DOMRpcIdentifier {
+
private static final class Global extends DOMRpcIdentifier {
private Global(final @Nonnull SchemaPath type) {
super(type);
@Override
public YangInstanceIdentifier getContextReference() {
- return null;
+ return YangInstanceIdentifier.EMPTY;
}
}
* @return A global RPC identifier, guaranteed to be non-null.
*/
public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type, final @Nullable YangInstanceIdentifier contextReference) {
- if (contextReference == null) {
+ if (contextReference == null || contextReference.isEmpty()) {
return new Global(type);
- } else {
- return new Local(type, contextReference);
}
+ return new Local(type, contextReference);
}
/**
*
* @return RPC context reference.
*/
- public abstract @Nullable YangInstanceIdentifier getContextReference();
+ public abstract @Nonnull YangInstanceIdentifier getContextReference();
@Override
public final int hashCode() {
@Override
public final String toString() {
- return com.google.common.base.Objects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", getContextReference()).toString();
+ return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", getContextReference()).toString();
}
}