Rework TypedRowInvocationHandler invocation path
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / schema / typed / GetData.java
1 /*
2  * Copyright © 2019 PANTHEON.tech, s.r.o. 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 /*
9  * Copyright © 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
10  *
11  * This program and the accompanying materials are made available under the
12  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
13  * and is available at http://www.eclipse.org/legal/epl-v10.html
14  */
15 package org.opendaylight.ovsdb.lib.schema.typed;
16
17 import java.lang.reflect.Method;
18 import org.eclipse.jdt.annotation.NonNull;
19 import org.opendaylight.ovsdb.lib.notation.Column;
20 import org.opendaylight.ovsdb.lib.notation.Row;
21 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
22 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
23
24 final class GetData<T> extends MethodDispatch.StrictColumnPrototype<T> {
25     private static final class Invoker<T> extends MethodDispatch.ColumnInvoker<T> {
26         Invoker(final @NonNull GenericTableSchema tableSchema,
27                 final @NonNull ColumnSchema<GenericTableSchema, T> columnSchema) {
28             super(tableSchema, columnSchema);
29         }
30
31         @Override
32         Object invokeMethod(final Object proxy, final Object[] args) {
33             return null;
34         }
35
36         @Override
37         Object invokeRowMethod(final Row<GenericTableSchema> row, final Object proxy, final Object[] args) {
38             final Column<GenericTableSchema, T> column = row.getColumn(columnSchema());
39             return column == null ? null : column.getData();
40         }
41     }
42
43     GetData(final Method method, final String tableName, final String columnName) {
44         super(method, tableName, columnName);
45     }
46
47     @Override
48     Invoker<T> bindToImpl(final GenericTableSchema tableSchema,
49             final ColumnSchema<GenericTableSchema, T> columnSchema) {
50         return new Invoker<>(tableSchema, columnSchema);
51     }
52 }