import java.util.Collections;
import java.util.List;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.spec.util.FooChild;
-import org.opendaylight.mdsal.binding.spec.util.GroupingFoo;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.ChildOf;
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. 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.mdsal.binding.spec.reflect;
+
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+
+public interface FooChild extends ChildOf<GroupingFoo> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. 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.mdsal.binding.spec.reflect;
+
+public interface GroupingFoo {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.mdsal.binding.spec.util;
+
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * Various utility methods for bridging generated interfaces and human-written code. Methods in this class should be
+ * statically imported into user code, so that the resulting code is expressive:
+ *
+ * <code>
+ * import static org.opendaylight.yangtools.yang.binding.DataObjectUtils.nullToEmpty;
+ *
+ * FooWithList foo;
+ * for (ListItem item : nulltoEmpty(foo.getList())) {
+ * // ..
+ * }
+ * </code>
+ *
+ * @author Robert Varga
+ */
+@NonNullByDefault
+public final class DataObjectUtils {
+ private DataObjectUtils() {
+
+ }
+
+ /**
+ * Utility method for dealing with nullable Lists returned from Binding DTOs.
+ *
+ * @param input input list, may be null
+ * @return Input list or an empty list.
+ */
+ public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
+ return input != null ? input : ImmutableList.of();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.mdsal.binding.spec.util;
+import static org.junit.Assert.assertSame;
+import static org.opendaylight.mdsal.binding.spec.util.DataObjectUtils.nullToEmpty;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import java.util.List;
+import org.junit.Test;
+
+public class DataObjectUtilsTest {
+ @Test
+ public void nullToEmptyNullTest() {
+ assertSame(ImmutableList.of(), nullToEmpty(null));
+ }
+
+ @Test
+ public void nullToEmptyNonNullTest() {
+ final List<Object> list = Collections.singletonList(null);
+ assertSame(list, nullToEmpty(list));
+ }
+}