2 * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
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
9 package org.opendaylight.neutron.northbound.api;
11 import java.lang.reflect.Field;
12 import java.util.List;
13 import org.opendaylight.neutron.spi.INeutronObject;
15 public interface INeutronRequest<T extends INeutronObject<T>> {
16 default T getSingleton() {
17 // return this.sinleton;
18 Class aClass = getClass();
20 Field field = aClass.getDeclaredField("singleton");
21 return (T) field.get(this);
22 } catch (IllegalAccessException | NoSuchFieldException e) {
23 throw new IllegalArgumentException(e);
27 default boolean isSingleton() {
28 // return this.sinleton != null;
29 Class aClass = getClass();
31 Field field = aClass.getDeclaredField("singleton");
32 return field.get(this) != null;
33 } catch (IllegalAccessException | NoSuchFieldException e) {
34 throw new IllegalArgumentException(e);
38 default List<T> getBulk() {
39 // return this.bulkRequest;
40 Class aClass = getClass();
42 Field field = aClass.getDeclaredField("bulkRequest");
43 return (List<T>) field.get(this);
44 } catch (IllegalAccessException | NoSuchFieldException e) {
45 throw new IllegalArgumentException(e);