Java Code Examples for com.github.davidmoten.rx.jdbc.annotations.Column#value()
The following examples show how to use
com.github.davidmoten.rx.jdbc.annotations.Column#value() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoMapCache.java From rxjava-jdbc with Apache License 2.0 | 6 votes |
private static Map<String, Col> getMethodCols(Class<?> cls) { Map<String, Col> methodCols = new HashMap<String, Col>(); for (Method method : cls.getMethods()) { String name = method.getName(); Column column = method.getAnnotation(Column.class); if (column != null) { checkHasNoParameters(method); // TODO check method has a mappable return type String col = column.value(); if (col.equals(Column.NOT_SPECIFIED)) col = Util.camelCaseToUnderscore(name); methodCols.put(name, new NamedCol(col, method.getReturnType())); } else { Index index = method.getAnnotation(Index.class); if (index != null) { // TODO check method has a mappable return type checkHasNoParameters(method); methodCols.put(name, new IndexedCol(index.value(), method.getReturnType())); } } } return methodCols; }
Example 2
Source File: DynamicProxyTest.java From rxjava-jdbc with Apache License 2.0 | 6 votes |
public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { Column a = m.getAnnotation(Column.class); final String column; if (a == null || a.value().equals(Column.NOT_SPECIFIED)) column = null; else column = a.value(); String name = m.getName(); if (name.equals("id")) { return 123; } else if (name.equals("name")) { return "fred " + m.getAnnotation(Index.class).value(); } else if (name.equals("description")) { return "he's the business! " + column; } else if (name.equals("nonNullNumber")) return null; else throw new RuntimeException("unexpected"); }